Archived
1
0
Fork 0
This repository has been archived on 2025-03-10. You can view files and clone it, but cannot push or open issues or pull requests.
hsbot/Hsbot/Types.hs
2011-04-13 20:15:55 +02:00

54 lines
1.2 KiB
Haskell

module Hsbot.Types
( Bot
, BotState (..)
, BotStatus (..)
, BotEnv (..)
, Env
, Message (..)
, PluginState (..)
) where
import Control.Concurrent
import qualified Data.Map as M
import Control.Monad.Reader
import Control.Monad.State
import qualified Network.IRC as IRC
import Network.TLS
import System.IO
import Hsbot.Config
-- The bot environment
type Env = ReaderT BotEnv
data BotEnv = BotEnv
{ envHandle :: Handle
, envChan :: Chan Message
, envQuitMv :: MVar (BotStatus)
, envThreadIdsMv :: MVar [ThreadId]
, envConfig :: Config
, envTLS :: Maybe TLSParams
, envTLSCtx :: Maybe TLSCtx
}
-- The bot monad
type Bot = StateT BotState
data BotState = BotState
{ botPlugins :: M.Map String (PluginState, MVar (), ThreadId)
, botCommands :: M.Map String [String]
, botChannels :: [String]
, botNickname :: String
}
-- The Plugin monad
data PluginState = PluginState
{ pluginName :: String
, pluginChan :: Chan Message
}
data BotStatus = BotContinue | BotExit | BotReload | BotRestart deriving (Show)
data Message = IncomingMsg IRC.Message
| OutgoingMsg IRC.Message