From 6ee089a1a257a63f360927bde80cdb0ab80390d2 Mon Sep 17 00:00:00 2001 From: opfez Date: Sat, 9 Oct 2021 00:26:38 +0200 Subject: [PATCH] add qotd support --- Anna.hs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Anna.hs b/Anna.hs index 4ed6543..46e119b 100644 --- a/Anna.hs +++ b/Anna.hs @@ -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 ()