Rewrote command handling, added the Quote module and cleaned input handling.
This commit is contained in:
parent
46d9dd301d
commit
53870767c3
9 changed files with 116 additions and 57 deletions
13
Hsbot/IRC.hs
13
Hsbot/IRC.hs
|
@ -5,11 +5,9 @@ module Hsbot.IRC
|
|||
|
||||
import Control.Concurrent.Chan
|
||||
import Control.Monad.State
|
||||
import qualified Data.Map as M
|
||||
|
||||
import Hsbot.Command
|
||||
import Hsbot.IRCParser
|
||||
import Hsbot.Plugin
|
||||
import Hsbot.Types
|
||||
import Hsbot.Utils
|
||||
|
||||
|
@ -27,17 +25,12 @@ initServer = do
|
|||
runServer :: IrcBot ()
|
||||
runServer = do
|
||||
chan <- gets botChannel
|
||||
plugins <- gets botPlugins
|
||||
let input = readChan chan
|
||||
msg <- liftIO input
|
||||
case msg of
|
||||
InputMsg inputMsg -> do
|
||||
dispatchCommand $ InputMsg inputMsg
|
||||
mapM_ (sendToPlugin (InputMsg inputMsg) . snd) (M.toList plugins)
|
||||
OutputMsg outputMsg ->
|
||||
sendstr (serializeIrcMsg outputMsg)
|
||||
InternalCmd _ ->
|
||||
traceM "TODO internal command"
|
||||
InputMsg inputMsg -> dispatchMessage $ InputMsg inputMsg
|
||||
OutputMsg outputMsg -> sendstr (serializeIrcMsg outputMsg)
|
||||
InternalCmd internalCmd -> processInternalCommand $ InternalCmd internalCmd
|
||||
runServer
|
||||
|
||||
-- | Joins a chan
|
||||
|
|
Reference in a new issue