Safe Haskell | None |
---|---|
Language | Haskell2010 |
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.
- connect :: MonadIO m => ByteString -> Int -> NominalDiffTime -> m ConnectionConfig
- connectWithTLS :: MonadIO m => ByteString -> Int -> NominalDiffTime -> m ConnectionConfig
- start :: MonadIO m => ConnectionConfig -> InstanceConfig -> m ()
- start' :: MonadIO m => IRCState -> m ()
- send :: UnicodeMessage -> IRC ()
- sendBS :: IrcMessage -> IRC ()
- disconnect :: IRC ()
- defaultIRCConf :: Text -> InstanceConfig
- defaultDisconnectHandler :: IRC ()
- defaultEventHandlers :: [EventHandler]
- module Network.IRC.Client.Types
- module Network.IRC.Client.Utils
- rawMessage :: ByteString -> [ByteString] -> IrcMessage
- toByteString :: IrcMessage -> ByteString
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.
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 aPONG
; - respond to CTCP
PING
requests with a CTCPPONG
; - 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
andKICK
.
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
module Network.IRC.Client.Types
Utilities
module Network.IRC.Client.Utils
rawMessage :: ByteString -> [ByteString] -> IrcMessage
toByteString :: IrcMessage -> ByteString