Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides the datatypes.
- data Connection :: * = Connection {}
- data Config = Config {
- cfgConnection :: Connection
- cfgChannels :: [String]
- cfgLogDir :: FilePath
- cfgStateRepo :: Maybe FilePath
- cfgStateFile :: FilePath
- cfgSaveInterval :: TimeInterval
- cfgBotEventLogFile :: FilePath
- cfgIrcErrorLogFile :: Maybe FilePath
- cfgMaxMsgChars :: Maybe Int
- cfgLagCheck :: Maybe TimeInterval
- cfgLagMax :: TimeInterval
- cfgMaxMsgCount :: Int
- cfgMsgDelay :: TimeInterval
- data Failure
- = WrongNumArgs
- | WrongNumArgsN (Maybe Int) (Maybe Int)
- | InvalidArgs
- | InvalidArg (Maybe Int) (Maybe String)
- | OtherFail String
- data Command e s = Command {}
- data CommandSet e s = CommandSet {
- csetPrefix :: Char
- csetCommands :: [Command e s]
- data HistoryLine = HistoryLine {}
- data ChanInfo = ChanInfo {}
- data MsgCountEntry
- type Session e s = RWST (BotEnv e s) () (BotState s) IO
- data EventMatchSpace
- data Behavior e s = Behavior {
- handleJoin :: String -> String -> Session e s ()
- handlePart :: String -> String -> Maybe String -> Session e s ()
- handleQuit :: String -> Maybe String -> Session e s ()
- handleMsg :: String -> String -> String -> Bool -> Session e s ()
- handleAction :: String -> String -> String -> Bool -> Session e s ()
- handleBotMsg :: String -> String -> String -> String -> Session e s ()
- commandSets :: [CommandSet e s]
- handlePersonalMsg :: String -> String -> Session e s ()
- handlePersonalAction :: String -> String -> Session e s ()
- handleNickChange :: String -> String -> Session e s ()
- handleTopicChange :: String -> String -> String -> Session e s ()
- handleNames :: String -> ChannelPrivacy -> [(Privilege, String)] -> Session e s ()
- type EventSource e s a = Config -> e -> (a -> IO ()) -> ([a] -> IO ()) -> (FilePath -> IO Logger) -> IO ()
- type EventHandler e s a = a -> Session e s ()
- data Quotes
Documentation
data Connection :: *
Details of the connection to IRC.
Connection | |
|
Configuration for the bot connection to IRC.
Config | |
|
Describes wrong usage of a bot command.
WrongNumArgs | The number of arguments given is wrong |
WrongNumArgsN (Maybe Int) (Maybe Int) | <first-param> arguments were given, instead of <second-param> |
InvalidArgs | At least one of the arguments is invalid |
InvalidArg (Maybe Int) (Maybe String) | Argument in position <first-param> and value <second-param> invalid |
OtherFail String | Some other error, with a given description |
A bot command, triggered by a message sent to an IRC channel the bot has joined.
The type parameter e
is the type of environment, i.e. real-only state. The
type parameter s
is the type of the writable state the bot holds. For
example, maybe you want your bot to keep a list of to-do items and manage it
using bot commands. The bot state is where you store the to-do list.
Command | |
|
data CommandSet e s Source
The bot recognizes commands by picking IRC channel messages which begin with a special character, the command prefix. It's possible to have several prefixes, maybe give each its own role or meaning. A command set is a set of commands which share a prefix.
A command can be in more than one set.
Common prefixes are
.!
, \@
, >
, :
CommandSet | |
|
data HistoryLine Source
A message sent previously by an IRC user into a channel.
Per-channel information to return to the API user
data MsgCountEntry Source
Message counter log entry.
MsgCountMsgs Int | Number of messages sent in a channel |
MsgCountJoin String | User joined the channel |
MsgCountPart String | User left the channel |
type Session e s = RWST (BotEnv e s) () (BotState s) IO Source
Bot monad. It provides read-only bot environment (e.g. the configuration), read-writable bot state (for use by bot commands) and IO.
Bot behavior definition.
Behavior | |
|
type EventSource e s a Source
= Config | The bot configuration. The event source may find this useful. |
-> e | The bot's custom environment. The event source may find this useful. |
-> (a -> IO ()) | A non-blocking |
-> ([a] -> IO ()) | A non-blocking |
-> (FilePath -> IO Logger) | An |
-> IO () |
An IO
action, possibly running forever, which produces events for the
bot to process. These event sources are run by the bot in dedicated threads.
Type parameters:
e
- custom bot environment types
- custom bot state typea
- event type
type EventHandler e s a = a -> Session e s () Source
A bot session action which reacts to a single event which came from an
EventSource
.
Type parameters:
e
- custom bot environment types
- custom bot state typea
- event type
Quote types for string formatting.
SingleQuotes Bool | Single quote on each side of the formatted string. The parameter sets whether to use Unicode (otherwise use ASCII fallback). |
DoubleQuotes Bool | Double quote on each side of the formatted string. The parameter sets whether to use Unicode (otherwise use ASCII fallback). |
BackTicks | Backtick on each side of the formatted string. |