aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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))