summaryrefslogtreecommitdiff
path: root/Hsbot/Types.hs
diff options
context:
space:
mode:
authorJulien Dessaux2010-05-24 23:50:59 +0200
committerJulien Dessaux2010-05-24 23:52:47 +0200
commit8b33600f3818edd9aa9dedfa7a9a03d6e2af3276 (patch)
tree50a8ae73d0c67df2f9349d96fd47b65a10244185 /Hsbot/Types.hs
parentImplemented ircbot update messages. (diff)
downloadhsbot-8b33600f3818edd9aa9dedfa7a9a03d6e2af3276.tar.gz
hsbot-8b33600f3818edd9aa9dedfa7a9a03d6e2af3276.tar.bz2
hsbot-8b33600f3818edd9aa9dedfa7a9a03d6e2af3276.zip
Implemented update message handling in the bot's core.
Diffstat (limited to '')
-rw-r--r--Hsbot/Types.hs50
1 files changed, 50 insertions, 0 deletions
diff --git a/Hsbot/Types.hs b/Hsbot/Types.hs
new file mode 100644
index 0000000..3afbff5
--- /dev/null
+++ b/Hsbot/Types.hs
@@ -0,0 +1,50 @@
+module Hsbot.Types
+ ( Bot
+ , BotMsg (..)
+ , BotState (..)
+ , Msg (..)
+ , Plugin
+ , PluginState (..)
+ ) where
+
+import Control.Concurrent
+import Control.Monad.State
+import qualified Data.Map as M
+import Data.Time
+import System.IO
+
+import Hsbot.Config
+
+-- | The Bot monad
+type Bot = StateT BotState IO
+
+-- | An Hsbot state
+data BotState = BotState
+ { 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
+ , botUpdateChan :: Chan String -- the bot's chan to report updates on
+ , botResumeData :: M.Map String String -- the necessary data to resume the bot's operations on reboot
+ }
+
+-- | The Plugin monad
+type Plugin = StateT PluginState IO
+
+-- | A plugin state
+data PluginState = PluginState
+ { pluginName :: String -- The plugin's name
+ , pluginChan :: Chan BotMsg -- The plugin chan
+ , pluginHandles :: M.Map String Handle -- the plugins's handles
+ }
+
+-- | A hsbot message
+data Msg = Msg
+ { msgType :: String -- the message type
+ , msgFrom :: String -- who issues it
+ , msgTo :: String -- who it is destinated to
+ , msgCmd :: String -- the message to be transfered
+ } deriving (Show)
+
+data BotMsg = InMsg Msg | OutMsg Msg | IntMsg Msg deriving (Show)
+