Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides IRC commands the bot can do within a bot session. They conveniently wrap the details of IRC connections and messages.
- disconnect :: Session e s ()
- quit :: Maybe String -> Session e s ()
- run :: Config -> Behavior e s -> e -> s -> Session e s a -> IO a
- login :: Session e s ()
- pong :: String -> Maybe String -> Session e s ()
- joinChannel :: String -> Maybe String -> Session e s ()
- joinMulti :: [(String, Maybe String)] -> Session e s ()
- joinConfig :: Session e s ()
- partChannel :: String -> Maybe String -> Session e s ()
- partMulti :: [String] -> Maybe String -> Session e s ()
- partAll :: Session e s ()
- sendToChannel :: String -> String -> Session e s ()
- sendToUser :: String -> String -> Session e s ()
- sendBack :: Maybe String -> String -> String -> Session e s ()
- failToChannel :: String -> String -> Failure -> Session e s ()
- failToUser :: String -> Failure -> Session e s ()
- failBack :: Maybe String -> String -> Failure -> Session e s ()
- putIrc :: Message -> Session e s ()
Connection Management
disconnect :: Session e s () Source
Disconnect from IRC by closing the bot's side of the connection. This function is mainly provided for completeness and cases of error. You should probably use the QUIT command of IRC to quit the network in a manner coordinated with the server.
After disconnection, make sure not to send more IRC commands.
Finish the IRC session, asking the server to close the connection.
Session Management
:: Config | IRC configuration |
-> Behavior e s | Bot behavior definition |
-> e | Custom bot environment (read-only state) |
-> s | Initial custom bot state |
-> Session e s a | Session definition |
-> IO a |
Connect to an IRC server and run the bot session
login :: Session e s () Source
Log in as an IRC user and identify with the bot's nickname and password.
This is the first thing to do after botConnect
ing to the server.
IRC servers send PING messages at regular intervals to test the presence of an active client, at least if no other activity is detected on the connection. The server closes the connection automatically if a PONG response isn't sent from the client within a certain amount of time.
Therefore, an IRC client (both humans users and bots) usually listens to these PINGs and sends back PONG messages. This function sends a PONG. The parameters should simply be the ones received in the PING message.
Channels
Join an IRC channel.
Join one or more IRC channels.
joinConfig :: Session e s () Source
Join the IRC channels listed in the configuration, without leaving any other channels the bot already joined.
:: String | Channel name |
-> Maybe String | Optional part message, e.g. the reason for leaving |
-> Session e s () |
Leave an IRC channel.
:: [String] | List of channel names |
-> Maybe String | Optional part message, e.g. the reason for leaving |
-> Session e s () |
Leave one or more IRC channels.
Sending Messages
:: String | The channel name |
-> String | The message to send. It may contain newlines, in which case it will be split into multiple messages and sent sequentially. |
-> Session e s () |
Send a message to an IRC channel.
This usually requires that the bot joins the channel first, because many channels have the +n flag set. This flag forbids sending a messages into a channel from outside it.
:: String | The user's nickname |
-> String | The message to send. It may contain newlines, in which case it will be split into multiple messages and sent sequentially. |
-> Session e s () |
Send a private message to an IRC user.
:: Maybe String | Channel name, specify if replying to a message
sent in a channel. Otherwise pass |
-> String | The sender user's nickname |
-> String | The message to send. It may contain newlines, in which case it will be split into multiple messages and sent sequentially. |
-> Session e s () |
Send a message back to the sender. If a channel is specified, send to the channel. If not, send a private message.
Send message explaining a failure to an IRC channel.
Send message explaining a failure to an IRC user.
:: Maybe String | Optional target channel, |
-> String | Target user nickname |
-> Failure | Problem indication |
-> Session e s () |
Send message explaining a failure back to the sender.