irc-client-0.2.3.0: An IRC client library.

Safe HaskellNone
LanguageHaskell2010

Network.IRC.Client

Contents

Description

A simple IRC client library. Typical usage will be of this form:

run :: ByteString -> Int -> Text -> IO ()
run host port nick = do
  conn <- connect host port 1
  let cfg = defaultIRCConf nick
  let cfg' = cfg { _handlers = yourCustomEventHandlers : _handlers cfg }
  start conn cfg'

You shouldn't really need to tweak anything other than the event handlers, as everything has been designed to be as simple as possible.

Synopsis

Initialisation

connect :: MonadIO m => ByteString -> Int -> NominalDiffTime -> m ConnectionConfig Source

Connect to a server without TLS.

connectWithTLS :: MonadIO m => ByteString -> Int -> NominalDiffTime -> m ConnectionConfig Source

Connect to a server with TLS.

start :: MonadIO m => ConnectionConfig -> InstanceConfig -> m () Source

Run the event loop for a server, receiving messages and handing them off to handlers as appropriate. Messages will be logged to stdout.

start' :: MonadIO m => IRCState -> m () Source

Like start, but use the provided initial state.

Interaction

send :: UnicodeMessage -> IRC () Source

Send a message as UTF-8, using TLS if enabled. This blocks if messages are sent too rapidly.

sendBS :: IrcMessage -> IRC () Source

Send a message, using TLS if enabled. This blocks if messages are sent too rapidly.

disconnect :: IRC () Source

Disconnect from the server, properly tearing down the TLS session (if there is one).

Defaults

defaultIRCConf :: Text -> InstanceConfig Source

Construct a default IRC configuration from a nick

defaultDisconnectHandler :: IRC () Source

The default disconnect handler: do nothing. You might want to override this with one which reconnects.

defaultEventHandlers :: [EventHandler] Source

The default event handlers, the following are included:

  • respond to server PING messages with a PONG;
  • respond to CTCP PING requests with a CTCP PONG;
  • respond to CTCP VERSION requests with the version string;
  • respond to CTCP TIME requests with the system time;
  • update the nick upon receiving the welcome message, in case the server modifies it;
  • mangle the nick if the server reports a collision;
  • update the channel list on JOIN and KICK.

These event handlers are all exposed through the Network.IRC.Client.Handlers module, so you can use them directly if you are building up your InstanceConfig from scratch.

If you are building a bot, you may want to write an event handler to process messages representing commands.

Types

Utilities

rawMessage :: ByteString -> [ByteString] -> IrcMessage

toByteString :: IrcMessage -> ByteString