aboutsummaryrefslogtreecommitdiff
path: root/src/IRC.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/IRC.hs')
-rw-r--r--src/IRC.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/IRC.hs b/src/IRC.hs
index 9d9a320..8a956d1 100644
--- a/src/IRC.hs
+++ b/src/IRC.hs
@@ -13,7 +13,7 @@ import Lens.Micro
import System.IO (hFlush, stdout)
-connectIRC :: (Text -> Bool) -> (Text -> IO [Text]) -> IO ()
+connectIRC :: (Text -> Maybe a) -> (a -> Text -> IO [Text]) -> IO ()
connectIRC commandDetect msgFun = do
pass <- readFile "irc-password.txt"
let trim = reverse . dropWhile isSpace . reverse . dropWhile isSpace
@@ -55,14 +55,14 @@ noticeHandler = EventHandler
send $ Join (T.pack "#haskell")
send $ Join (T.pack "#haskell-offtopic"))
-privmsgHandler :: (Text -> Bool) -> (Text -> IO [Text]) -> EventHandler s
+privmsgHandler :: (Text -> Maybe a) -> (a -> Text -> IO [Text]) -> EventHandler s
privmsgHandler commandDetect msgFun = EventHandler
(\ev -> case ev ^. message of
Privmsg _ (Right text)
- | commandDetect text -> Just (ev ^. source, text)
+ | Just s <- commandDetect text -> Just (ev ^. source, text, s)
_ -> Nothing)
- (\_ (src, text) -> do
- msgs <- liftIO $ msgFun text
+ (\_ (src, text, s) -> do
+ msgs <- liftIO $ msgFun s text
let mtarget = case src of
User name -> Just name
Channel ch _ -> Just ch