aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2022-10-14 09:52:18 +0200
committerTom Smeding <tom@tomsmeding.com>2022-10-14 09:52:18 +0200
commitc006be894348c1302f99698d18d0e4d76bac160b (patch)
treeb4da3ed78c918ce90f7f0de41dc296c41112bd65 /src
parenta4636014ab24c810e491a5267042fd70e067c2c3 (diff)
Proper target for irc responses
Diffstat (limited to 'src')
-rw-r--r--src/IRC.hs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/IRC.hs b/src/IRC.hs
index 5a24909..ac88a78 100644
--- a/src/IRC.hs
+++ b/src/IRC.hs
@@ -56,10 +56,15 @@ noticeHandler = EventHandler
privmsgHandler :: (Text -> Bool) -> (Text -> IO [Text]) -> EventHandler s
privmsgHandler commandDetect msgFun = EventHandler
(\ev -> case ev ^. message of
- Privmsg target (Right text)
- | commandDetect text -> Just (target, text)
+ Privmsg _ (Right text)
+ | commandDetect text -> Just (ev ^. source, text)
_ -> Nothing)
- (\_ (target, text) -> do
+ (\_ (src, text) -> do
msgs <- liftIO $ msgFun text
- forM_ msgs $ \msg ->
- send $ Privmsg target (Right msg))
+ let mtarget = case src of
+ User name -> Just name
+ Channel ch _ -> Just ch
+ Server _ -> Nothing
+ forM_ mtarget $ \target ->
+ forM_ msgs $ \msg ->
+ send $ Privmsg target (Right msg))