diff options
author | Laura <the-ceo-of-antifa@protonmail.com> | 2023-01-17 23:19:46 +0100 |
---|---|---|
committer | Laura <the-ceo-of-antifa@protonmail.com> | 2023-01-17 23:19:46 +0100 |
commit | 2e4f14d2848d91aae83d60082dd6085431a663a8 (patch) | |
tree | ceee526cdf4b15a3719141ad00c31a57b2976825 | |
parent | 09bc3834373cad1f8e44eeb05854f19b66e208f8 (diff) | |
download | miaowe-2e4f14d2848d91aae83d60082dd6085431a663a8.tar.gz miaowe-2e4f14d2848d91aae83d60082dd6085431a663a8.zip |
Case-insensitive commands
-rw-r--r-- | miaowe.hs | 31 |
1 files changed, 16 insertions, 15 deletions
@@ -202,23 +202,24 @@ getFortune = readCreateProcess ((shell "fortune | cowsay -b")) "" processCommand :: IrcChannel -> MircString -> IO () processCommand channel command | length (words command) < 5 = sendToChannel channel "You need to specify a command." - | (words command)!!4 == "Quit" = exitSuccess - | (words command)!!4 == "List" = listDirectory "." - >>= sendToChannel channel . - intercalate "\n" - | (words command)!!4 == "Code" = sendToChannel channel codeUrl - | (words command)!!4 == "Help" = sendToChannel channel helpString + | otherwise = case (words command)!!4 of + "quit" -> exitSuccess + "list" -> listDirectory "." + >>= sendToChannel channel . + intercalate "\n" + "code" -> sendToChannel channel codeUrl + "help" -> sendToChannel channel helpString #ifdef FORTUNE - | (words command)!!4 == "Fortune" = getFortune - >>= sendToChannel channel + "fortune" -> getFortune + >>= sendToChannel channel #endif - | otherwise = (if isInfixOf "/" ((words command)!!4) - then - sendToChannel channel - "Only PWD please." - else - trySendFile channel - ((words command)!!4)) + _ -> (if isInfixOf "/" ((words command)!!4) + then + sendToChannel channel + "Only PWD please." + else + trySendFile channel + ((words command)!!4)) mainLoop :: IrcChannel -> IO () mainLoop channel = waitForCommand |