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 | otherwise = case head tokens of
-- TODO: make reader monad for this? passing chn is a little tedious -- TODO: make reader monad for this? passing chn is a little tedious
"!greets" -> greets chn "!greets" -> greets chn
"!qotd" -> qotd chn
"!rollcall" -> rollcall chn "!rollcall" -> rollcall chn
"!anna" -> anna chn "!anna" -> anna chn
_ -> return () _ -> return ()
@ -106,14 +107,20 @@ greets chn = do
displayLine = "o/ - " ++ (head contentLines) ++ " vs \\o - " ++ (head $ tail contentLines) displayLine = "o/ - " ++ (head contentLines) ++ " vs \\o - " ++ (head $ tail contentLines)
sendMessage chn displayLine sendMessage chn displayLine
rollcall :: String -> Net () qotd :: 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" qotd chn = do
anna = rollcall handle <- liftIO $ connectTo "127.0.0.1" 1717
text <- liftIO $ hGetContents handle
sendMessage chn text
return ()
-- TODO
timezone :: String -> String -> Net () timezone :: String -> String -> Net ()
timezone chn username = undefined 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 -- Basic commands
write :: String -> String -> Net () write :: String -> String -> Net ()