aboutsummaryrefslogtreecommitdiff
path: root/src/IRC.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2022-12-03 22:22:32 +0100
committerTom Smeding <tom@tomsmeding.com>2022-12-03 22:27:31 +0100
commit68f3d87a106002f9e46f5cb57c7f83048040dc5e (patch)
tree273f0fdb7dca60be49114fc0ec6a95da6dea4c7c /src/IRC.hs
parent607d1f2d30c35693cff51546f436931000ca9b89 (diff)
Paste
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