From a12e4927728c9907537b221257c5e2914f5f1c48 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Mon, 24 May 2010 22:46:20 +0200 Subject: Implemented ircbot update messages. --- Hsbot/Irc/Command.hs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'Hsbot/Irc/Command.hs') diff --git a/Hsbot/Irc/Command.hs b/Hsbot/Irc/Command.hs index e5c033e..ef1ef27 100644 --- a/Hsbot/Irc/Command.hs +++ b/Hsbot/Irc/Command.hs @@ -36,7 +36,7 @@ unregisterCommand cmd pluginName' = do -- | Processes an internal command processInternalCommand :: IrcBotMsg -> IrcBot () processInternalCommand (IntIrcCmd ircCmd) - | ircCmdTo ircCmd == "CORE" = processCoreCommand ircCmd + | ircCmdTo ircCmd == "CORE" = processCoreCommand ircCmd | otherwise = do plugins <- gets ircBotPlugins case M.lookup (ircCmdTo ircCmd) plugins of @@ -52,8 +52,18 @@ processCoreCommand ircCmd = do case command' of "LIST" -> listPlugins originalRequest (ircCmdFrom ircCmd) "LOAD" -> loadIrcPlugin $ ircCmdMsg ircCmd - "UNLOAD" -> unloadPlugin $ ircCmdMsg ircCmd + "UNLOAD" -> unloadIrcPlugin $ ircCmdMsg ircCmd + "UPDATE" -> processUpdateCommand ircCmd "REGISTER" -> registerCommand (ircCmdMsg ircCmd) (ircCmdFrom ircCmd) "UNREGISTER" -> unregisterCommand (ircCmdMsg ircCmd) (ircCmdFrom ircCmd) _ -> return () +-- | Process an update command +processUpdateCommand :: IrcCmd -> IrcBot () +processUpdateCommand ircCmd = do + ircbot <- get + let oldData = ircBotResumeData ircbot + from = ircCmdFrom ircCmd + stuff = ircCmdMsg ircCmd + put $ ircbot { ircBotResumeData = M.insert from stuff oldData } + -- cgit v1.2.3