From fa0bf06c910cd71c91d6b3fc50c7394dae668956 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sun, 8 May 2011 14:57:12 +0200 Subject: Added the ability to directly answer /msg. --- Hsbot/Message.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Hsbot') diff --git a/Hsbot/Message.hs b/Hsbot/Message.hs index d6697cd..825a649 100644 --- a/Hsbot/Message.hs +++ b/Hsbot/Message.hs @@ -18,8 +18,9 @@ writeMsg :: Message -> Plugin (Env IO) () writeMsg msg = asks pluginMaster >>= liftIO . flip writeChan msg answerMsg :: IRC.Message -> String -> Plugin (Env IO) () -answerMsg request msg = - case IRC.msg_params request of - sender:_ -> writeMsg . OutgoingMsg $ IRC.Message Nothing "PRIVMSG" [sender, msg] - [] -> return () +answerMsg _ [] = return () +answerMsg (IRC.Message (Just (IRC.NickName nick _ _)) _ (channel:_)) msg + | head channel == '#' = writeMsg . OutgoingMsg $ IRC.Message Nothing "PRIVMSG" [channel, msg] + | otherwise = writeMsg . OutgoingMsg $ IRC.Message Nothing "PRIVMSG" [nick, msg] +answerMsg _ _ = return () -- cgit v1.2.3