From 68f3d87a106002f9e46f5cb57c7f83048040dc5e Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sat, 3 Dec 2022 22:22:32 +0100 Subject: Paste --- src/IRC.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/IRC.hs') 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 -- cgit v1.2.3-70-g09d2