Archived
1
0
Fork 0
This repository has been archived on 2025-03-10. You can view files and clone it, but cannot push or open issues or pull requests.
hsbot/Hsbot/Message.hs
2011-05-01 03:28:28 +02:00

25 lines
622 B
Haskell

module Hsbot.Message
( answerMsg
, readMsg
, writeMsg
) where
import Control.Concurrent
import Control.Monad.State
import qualified Network.IRC as IRC
import Hsbot.Types
-- Plugin Utils
readMsg :: Plugin IO (Message)
readMsg = gets pluginChan >>= liftIO . readChan >>= return
writeMsg :: Message -> Plugin IO ()
writeMsg msg = gets pluginMaster >>= liftIO . flip writeChan msg
answerMsg :: IRC.Message -> String -> Plugin IO ()
answerMsg request msg =
case IRC.msg_params request of
sender:_ -> writeMsg . OutgoingMsg $ IRC.Message Nothing "PRIVMSG" [sender, msg]
[] -> return ()