add qotd support

master
opfez 2021-10-09 00:26:38 +02:00
parent 00c8f6d5d9
commit 6ee089a1a2
1 changed files with 11 additions and 4 deletions

15
Anna.hs
View File

@ -69,6 +69,7 @@ tokenDispatch (Just userName) (Just chn) ts = if elem "PRIVMSG" ts
| otherwise = case head tokens of
-- TODO: make reader monad for this? passing chn is a little tedious
"!greets" -> greets chn
"!qotd" -> qotd chn
"!rollcall" -> rollcall chn
"!anna" -> anna chn
_ -> return ()
@ -106,14 +107,20 @@ greets chn = do
displayLine = "o/ - " ++ (head contentLines) ++ " vs \\o - " ++ (head $ tail contentLines)
sendMessage chn displayLine
rollcall :: String -> Net ()
rollcall chn = sendMessage chn "Hello! I respond to !anna and !greets. My source code is available at https://git.tilde.town/opfez/anna"
anna = rollcall
qotd :: String -> Net ()
qotd chn = do
handle <- liftIO $ connectTo "127.0.0.1" 1717
text <- liftIO $ hGetContents handle
sendMessage chn text
return ()
-- TODO
timezone :: String -> String -> Net ()
timezone chn username = undefined
rollcall :: String -> Net ()
rollcall chn = sendMessage chn "Hello! I respond to !anna and !greets. My source code is available at https://git.tilde.town/opfez/anna"
anna = rollcall
-- Basic commands
write :: String -> String -> Net ()