From 738ad9e9bbbefb43a7889a458ff1c326a324eb9a Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sun, 16 May 2010 17:58:38 +0200 Subject: Removed thread ids from plugins data structure. --- Hsbot/Core.hs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'Hsbot/Core.hs') diff --git a/Hsbot/Core.hs b/Hsbot/Core.hs index cae873b..772a31a 100644 --- a/Hsbot/Core.hs +++ b/Hsbot/Core.hs @@ -13,7 +13,7 @@ import System.IO() import Hsbot.Config import Hsbot.Irc.Config -import Hsbot.Irc.Core (ircbot) +import Hsbot.Irc.Core import Hsbot.Message import Hsbot.Plugin @@ -22,10 +22,10 @@ type Bot = StateT BotState IO -- | An Hsbot state data BotState = BotState - { botStartTime :: UTCTime -- the bot's uptime - , botPlugins :: M.Map String PluginState -- Loaded plugins - , botChan :: Chan BotMsg -- The bot's communication channel - , botConfig :: Config -- the bot's starting config + { botStartTime :: UTCTime -- the bot's uptime + , botPlugins :: M.Map String (PluginState, ThreadId) -- Loaded plugins + , botChan :: Chan BotMsg -- The bot's communication channel + , botConfig :: Config -- the bot's starting config } -- | Bot's main entry point @@ -62,8 +62,10 @@ spawnIrcPlugins = do bot <- get let chan = botChan bot pchan <- liftIO (newChan :: IO (Chan BotMsg)) - threadId <- liftIO $ forkIO (ircbot config chan pchan) - let plugin = PluginState (ircConfigName config) threadId pchan M.empty + threadId <- liftIO $ forkIO (startIrcbot config chan pchan) + let plugin = PluginState { pluginName = ircConfigName config + , pluginChan = pchan + , pluginHandles = M.empty } plugins = botPlugins bot - put $ bot { botPlugins = M.insert (pluginName plugin) plugin plugins } + put $ bot { botPlugins = M.insert (pluginName plugin) (plugin, threadId) plugins } -- cgit v1.2.3