summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaura <the-ceo-of-antifa@protonmail.com>2023-01-17 23:19:46 +0100
committerLaura <the-ceo-of-antifa@protonmail.com>2023-01-17 23:19:46 +0100
commit2e4f14d2848d91aae83d60082dd6085431a663a8 (patch)
treeceee526cdf4b15a3719141ad00c31a57b2976825
parent09bc3834373cad1f8e44eeb05854f19b66e208f8 (diff)
downloadmiaowe-2e4f14d2848d91aae83d60082dd6085431a663a8.tar.gz
miaowe-2e4f14d2848d91aae83d60082dd6085431a663a8.zip
Case-insensitive commands
-rw-r--r--miaowe.hs31
1 files changed, 16 insertions, 15 deletions
diff --git a/miaowe.hs b/miaowe.hs
index 608ba44..82ad8aa 100644
--- a/miaowe.hs
+++ b/miaowe.hs
@@ -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