Added message command for inter handler messaging
This commit is contained in:
parent
fea56c17bf
commit
e054e51cf8
|
@ -80,6 +80,9 @@ readLineLoop mvBotStatus (lineChan, latch) bot@Bot { .. } timeoutDelay = do
|
|||
readLine :: Chan Line -> IO Line
|
||||
readLine = readChan
|
||||
|
||||
sendMessage :: Chan Line -> Message -> IO ()
|
||||
sendMessage = (. Line) . writeChan
|
||||
|
||||
listenerLoop :: Chan Line -> Chan Cmd -> Int -> IRC ()
|
||||
listenerLoop lineChan commandChan idleFor = do
|
||||
status <- get
|
||||
|
@ -122,7 +125,9 @@ listenerLoop lineChan commandChan idleFor = do
|
|||
mCmd <- runMsgHandler msgHandler botConfig message
|
||||
case mCmd of
|
||||
Nothing -> return ()
|
||||
Just cmd -> sendCommand commandChan (Cmd cmd)
|
||||
Just cmd -> case cmd of
|
||||
MessageCmd msg -> sendMessage lineChan msg
|
||||
_ -> sendCommand commandChan (Cmd cmd)
|
||||
|
||||
loadMsgHandlers :: BotConfig -> IO (Map MsgHandlerName MsgHandler)
|
||||
loadMsgHandlers botConfig@BotConfig { .. } =
|
||||
|
|
|
@ -108,4 +108,8 @@ messageLogger NickMsg { .. } = withLogFile $ \logFile ->
|
|||
TF.hprint logFile "[{}] ** {} CHANGED NICK TO {}\n" $
|
||||
TF.buildParams (fmtTime msgTime, userNick user, nick)
|
||||
|
||||
--messageLogger IdleMsg = const . liftIO $ do
|
||||
-- now <- getCurrentTime
|
||||
-- return . Just . MessageCmd $
|
||||
|
||||
messageLogger _ = const $ return Nothing
|
||||
|
|
|
@ -50,6 +50,7 @@ data Command =
|
|||
| NickCmd
|
||||
| UserCmd
|
||||
| JoinCmd
|
||||
| MessageCmd Message
|
||||
deriving (Show, Eq)
|
||||
|
||||
data BotConfig = BotConfig { server :: !Text
|
||||
|
|
Loading…
Reference in New Issue