fastirc-0.2.0: Fast Internet Relay Chat (IRC) library

MaintainerErtugrul Soeylemez <>




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))Source

Bot monad.

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.


Immediately kill the bot.

data BotInfo Source

Runtime bot information.



data BotSession Source

Bot session descriptor.

data Event Source

A bot event.



Bot connected.


Bot disconnected (either error or on demand).

ErrorEvent String

Connection failed or disconnected on error.


Bot logged in (received numeric 001).

MessageEvent Message

Received message from server.


Bot disconnected on demand.


type EventHandler = UniqueSource

Event handler identifier.

data Params Source

Parameters for an IRC client connection.




botGetNick :: IO NickName

IRC nick name generator.

botGetUser :: IO UserName

IRC user name generator.

botGetRealName :: IO RealName

IRC real name generator.

botPassword :: Maybe CommandArg

IRC server password.

botServerAddr :: Address

IRC server address.


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.

startBot :: Params -> IO (Either IOError BotSession)Source

Launch an IRC 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.