From dbf609a7e83e69abef13e5db57575ce101d5c9c5 Mon Sep 17 00:00:00 2001 From: Laura Date: Mon, 16 Jan 2023 19:13:43 +0100 Subject: Code and Help commands --- README.md | 2 ++ miaowe.hs | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 24508a3..09b6ff5 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ Miaowe includes no networking code of its own, but assumes stdin and stdout will Available commands: * List -- lists all files in PWD +* Code -- shows code URL +* Help -- helps * Quit -- quits To run: diff --git a/miaowe.hs b/miaowe.hs index 6ee36c2..f7fb8e6 100644 --- a/miaowe.hs +++ b/miaowe.hs @@ -41,6 +41,9 @@ data Image = Image { imgHeight :: Int } +codeUrl = "https://gitlab.com/laleanor/miaowe" +helpString = "Commands available: List; Code; Help. Anything else is interpreted as a file name." + ctrlC = [toEnum 03] :: String ctrlO = [toEnum 15] :: String ctrlV = [toEnum 22] :: String @@ -185,7 +188,10 @@ processCommand channel command | length (words command) < 5 = sendToChannel chan "You need to specify a command." | (words command)!!4 == "Quit" = exitSuccess | (words command)!!4 == "List" = listDirectory "." - >>= sendToChannel channel . intercalate "\n" + >>= sendToChannel channel . + intercalate "\n" + | (words command)!!4 == "Code" = sendToChannel channel codeUrl + | (words command)!!4 == "Help" = sendToChannel channel helpString | otherwise = (if isInfixOf "/" ((words command)!!4) then sendToChannel channel -- cgit v1.2.3