diff options
| -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)) | 
