Stability | alpha |
---|---|
Maintainer | Ertugrul Soeylemez <es@ertes.de> |
This module implements a framework for IRC client software. Essentially it consists of a dumb bot, which connects to and stays on an IRC server waiting for commands.
Using the onEvent
function (or the convenience functions
onConnect
, onDisconnect
, etc.) you can attach event handlers to
certain events. These event handlers are run in the Bot
monad,
which encapsulates the current state of the bot.
Please note that even though unlikely you should expect that parts of this interface will be changed in future revisions.
- type Bot = ContT () (StateT Config (ReaderT Params IO))
- data BotCommand
- = BotAddHandler (EventHandler -> IO ()) (Event -> Bot ())
- | BotDispatch Event
- | BotError String
- | BotQuit (Maybe CommandArg)
- | BotRecv Message
- | BotSendCmd Command
- | BotSendMsg Message
- | BotSendString MsgString
- | BotTerminate
- data BotInfo = BotInfo {}
- data BotSession
- data Event
- type EventHandler = Unique
- data Params = Params {}
- ircSendCmd :: BotSession -> Command -> IO ()
- ircSendMsg :: BotSession -> Message -> IO ()
- ircSendString :: BotSession -> MsgString -> IO ()
- onEvent :: BotSession -> (Event -> Bot ()) -> IO EventHandler
- sendBotCmd :: BotSession -> BotCommand -> IO ()
- startBot :: Params -> IO (Either IOError BotSession)
- onConnect :: BotSession -> Bot () -> IO EventHandler
- onDisconnect :: BotSession -> Bot () -> IO EventHandler
- onError :: BotSession -> (String -> Bot ()) -> IO EventHandler
- onLoggedIn :: BotSession -> Bot () -> IO EventHandler
- onMessage :: BotSession -> (Message -> Bot ()) -> IO EventHandler
- onQuit :: BotSession -> Bot () -> IO EventHandler
- getBotInfo :: Bot BotInfo
Types
data BotCommand Source
Commands to be sent to the bot.
BotAddHandler (EventHandler -> IO ()) (Event -> Bot ()) | Add an event handler. |
BotDispatch Event | Dispatch simulated event. |
BotError String | Simulate an error. |
BotQuit (Maybe CommandArg) | Send a quit message. |
BotRecv Message | Simulate receiving of a message. |
BotSendCmd Command | Send a command to the IRC server. |
BotSendMsg Message | Send a message to the IRC server. |
BotSendString MsgString | Send a raw string to the IRC server. |
BotTerminate | Immediately kill the bot. |
data BotSession Source
Bot session descriptor.
A bot event.
ConnectedEvent | Bot connected. |
DisconnectedEvent | Bot disconnected (either error or on demand). |
ErrorEvent String | Connection failed or disconnected on error. |
LoggedInEvent | Bot logged in (received numeric 001). |
MessageEvent Message | Received message from server. |
QuitEvent | Bot disconnected on demand. |
type EventHandler = UniqueSource
Event handler identifier.
Parameters for an IRC client connection.
Params | |
|
Functions
ircSendCmd :: BotSession -> Command -> IO ()Source
Send a command to the IRC server.
ircSendMsg :: BotSession -> Message -> IO ()Source
Send a message (with origin) to the IRC server. Note that IRC
servers ignore the origin prefix, so in general you would want to use
ircSendCmd
instead.
ircSendString :: BotSession -> MsgString -> IO ()Source
Send a raw message string to the IRC server. This is what most IRC clients call /quote.
onEvent :: BotSession -> (Event -> Bot ()) -> IO EventHandlerSource
Add an event handler.
sendBotCmd :: BotSession -> BotCommand -> IO ()Source
Send bot command to a bot.
Event utility functions
onConnect :: BotSession -> Bot () -> IO EventHandlerSource
Action to run on connect.
onDisconnect :: BotSession -> Bot () -> IO EventHandlerSource
Action to run on disconnect.
onError :: BotSession -> (String -> Bot ()) -> IO EventHandlerSource
Action to run on error (connection failed/aborted).
onLoggedIn :: BotSession -> Bot () -> IO EventHandlerSource
Action to run after login (numeric 001 received).
onMessage :: BotSession -> (Message -> Bot ()) -> IO EventHandlerSource
Action to run when a message arrives.
onQuit :: BotSession -> Bot () -> IO EventHandlerSource
Action to run on quit.
Bot monad
getBotInfo :: Bot BotInfoSource
Get current bot information.