Archived
1
0
Fork 0

Removed thread ids from plugins data structure.

This commit is contained in:
Julien Dessaux 2010-05-16 17:58:38 +02:00
parent c1662ba7b9
commit 738ad9e9bb
11 changed files with 37 additions and 46 deletions

View file

@ -2,7 +2,7 @@ module Hsbot.Irc.Plugin.Core
( ircBotPluginCore
) where
import Control.Concurrent (Chan, myThreadId)
import Control.Concurrent (Chan)
import Control.Exception
import Control.Monad.State
import Prelude hiding (catch)
@ -13,9 +13,7 @@ import Hsbot.Irc.PluginCommons
-- | The plugin's main entry point
ircBotPluginCore :: Chan IrcBotMsg -> Chan IrcBotMsg -> IO ()
ircBotPluginCore myChan masterChan = do
threadId <- myThreadId
let plugin = IrcPluginState { ircPluginName = "Core"
, ircPluginThreadId = threadId
, ircPluginChan = myChan
, ircPluginMasterChan = masterChan }
evalStateT (mapM_ sendRegisterCommand ["list", "load", "reload", "unload"]) plugin

View file

@ -2,7 +2,6 @@ module Hsbot.Irc.Plugin.Dummy
( ircBotPluginDummy
) where
import Control.Concurrent (myThreadId)
import Control.Concurrent.Chan
import Control.Exception
import Control.Monad.State
@ -14,9 +13,7 @@ import Hsbot.Irc.PluginCommons
-- | The plugin's main entry point
ircBotPluginDummy :: Chan IrcBotMsg -> Chan IrcBotMsg -> IO ()
ircBotPluginDummy myChan masterChan = do
threadId <- myThreadId
let plugin = IrcPluginState { ircPluginName = "Dummy"
, ircPluginThreadId = threadId
, ircPluginChan = myChan
, ircPluginMasterChan = masterChan }
_ <- (execStateT run plugin) `catch` (\(_ :: AsyncException) -> return plugin)

View file

@ -2,7 +2,6 @@ module Hsbot.Irc.Plugin.Ping
( ircBotPluginPing
) where
import Control.Concurrent (myThreadId)
import Control.Concurrent.Chan
import Control.Exception
import Control.Monad.State
@ -14,9 +13,7 @@ import Hsbot.Irc.PluginCommons
-- | The plugin's main entry point
ircBotPluginPing :: Chan IrcBotMsg -> Chan IrcBotMsg -> IO ()
ircBotPluginPing myChan masterChan = do
threadId <- myThreadId
let plugin = IrcPluginState { ircPluginName = "Ping"
, ircPluginThreadId = threadId
, ircPluginChan = myChan
, ircPluginMasterChan = masterChan }
_ <- (execStateT run plugin) `catch` (\(_ :: AsyncException) -> return plugin)

View file

@ -2,7 +2,6 @@ module Hsbot.Irc.Plugin.Quote
( ircBotPluginQuote
) where
import Control.Concurrent (myThreadId)
import Control.Concurrent.Chan
import Control.Exception
import Control.Monad.State
@ -61,9 +60,7 @@ ircBotPluginQuote myChan masterChan = do
txtQuoteBot <- TIO.readFile $ dbfile
let quoteBot = read (T.unpack txtQuoteBot) :: QuoteBotState
-- The plugin main loop
threadId <- myThreadId
let plugin = IrcPluginState { ircPluginName = "Quote"
, ircPluginThreadId = threadId
, ircPluginChan = myChan
, ircPluginMasterChan = masterChan }
evalStateT (mapM_ sendRegisterCommand ["quote"]) plugin