diff options
author | Tom Smeding <tom@tomsmeding.com> | 2022-10-14 09:52:18 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2022-10-14 09:52:18 +0200 |
commit | c006be894348c1302f99698d18d0e4d76bac160b (patch) | |
tree | b4da3ed78c918ce90f7f0de41dc296c41112bd65 | |
parent | a4636014ab24c810e491a5267042fd70e067c2c3 (diff) |
Proper target for irc responses
-rw-r--r-- | src/IRC.hs | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -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)) |