summaryrefslogtreecommitdiff
path: root/Hsbot/Core.hs
diff options
context:
space:
mode:
authorJulien Dessaux2010-05-16 17:58:38 +0200
committerJulien Dessaux2010-05-16 17:58:38 +0200
commit738ad9e9bbbefb43a7889a458ff1c326a324eb9a (patch)
treef8337cc73ffdfa6956dc9425a8338fe496eafec7 /Hsbot/Core.hs
parentRewrote nearly everything! (diff)
downloadhsbot-738ad9e9bbbefb43a7889a458ff1c326a324eb9a.tar.gz
hsbot-738ad9e9bbbefb43a7889a458ff1c326a324eb9a.tar.bz2
hsbot-738ad9e9bbbefb43a7889a458ff1c326a324eb9a.zip
Removed thread ids from plugins data structure.
Diffstat (limited to '')
-rw-r--r--Hsbot/Core.hs18
1 files changed, 10 insertions, 8 deletions
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 }