The IRC protocol, implemented over a Pants Stream.
The goal with this is to create a lightweight IRC class that can serve as either a server or a client. As such, it doesn’t implement a lot of logic in favor of providing a robust base.
The BaseIRC class can receive and send IRC commands, and automatically respond to certain commands such as PING.
This class extends Stream, and as such has the same connect() and listen() functions.
Send a message to the given nick or channel.
| Argument | Default | Description |
|---|---|---|
| destination | The nick or channel to send the message to. | |
| message | The text of the message to be sent. | |
| _ctcpQuote | True | Optional. If True, the message text will be quoted for CTCP before being sent. |
| _prefix | None | Optional. A string that, if provided, will be prepended to the command string before it’s sent to the server. |
Send a NOTICE to the specified destination.
| Argument | Default | Description |
|---|---|---|
| destination | The nick or channel to send the NOTICE to. | |
| message | The text of the NOTICE to be sent. | |
| _ctcpQuote | True | Optional. If True, the message text will be quoted for CTCP before being sent. |
| _prefix | None | Optional. A string that, if provided, will be prepended to the command string before it’s sent to the server. |
Send a QUIT message, with an optional reason.
| Argument | Default | Description |
|---|---|---|
| reason | None | Optional. The reason for quitting that will be displayed to other users. |
| _prefix | None | Optional. A string that, if provided, will be prepended to the command string before it’s sent to the server. |
Send a command to the remote endpoint.
| Argument | Default | Description |
|---|---|---|
| command | The command to send. | |
| *args | Optional. A list of arguments to send with the command. | |
| _prefix | None | Optional. A string that, if provided, will be prepended to the command string before it’s sent to the server. |
Placeholder.
This method is called whenever the IRC instance becomes disconnected from the remote client or server.
Placeholder.
This method is called whenever a command is received from the other side and successfully parsed as an IRC command.
| Argument | Description |
|---|---|
| command | The received command. |
| args | A list of the arguments following the command. |
| nick | The nick of the user that sent the command, if applicable, or an empty string. |
| user | The username of the user that sent the command, if applicable, or an empty string. |
| host | The host of the user that sent the command, the host of the server that sent the command, or an empty string if no host was supplied. |
An IRC client, written in Pants, based on BaseIRC.
This implements rather more logic, and keeps track of what server it’s connected to, its nick, and what channels it’s in.
This instance’s current nickname on the server it’s connected to, or the nickname it will attempt to acquire when connecting.
The port this instance is connected to on the remote server, or the port it will attempt to connect to.
Retrieve a Channel object for the channel name, or None if we’re not in that channel.
Connect to the server.
| Argument | Description |
|---|---|
| server | The host to connect to. |
| port | The port to connect to on the remote server. |
Join the specified channel.
| Argument | Description |
|---|---|
| channel | The name of the channel to join. |
Leave the specified channel.
| Argument | Default | Description |
|---|---|---|
| channel | The channel to leave. | |
| reason | None | Optional. The reason why. |
| force | False | Optional. Don’t ensure the client is actually in the named channel before sending PART. |
Placeholder.
This method is called when the bot receives a CTCP message, which could, in theory, be anywhere in a PRIVMSG... annoyingly enough.
| Argument | Description |
|---|---|
| nick | The nick of the user that sent the CTCP message, or an empty string if no nick is available. |
| message | The full CTCP message. |
| user | The username of the user that sent the CTCP message, or an empty string if no username is available. |
| host | The host of the user that sent the CTCP message, or an empty string if no host is available. |
Placeholder.
This method is called when a user enters a channel. That also means that this function is called whenever this IRC client successfully joins a channel.
| Argument | Description |
|---|---|
| channel | The channel a user has joined. |
| nick | The nick of the user that joined the channel. |
| user | The username of the user that joined the channel. |
| host | The host of the user that joined the channel. |
Placeholder.
This method is called when the client receives a message from a channel.
| Argument | Description |
|---|---|
| channel | The channel the message was received in. |
| message | The text of the message. |
| nick | The nick of the user that sent the message. |
| user | The username of the user that sent the message. |
| host | The host of the user that sent the message. |
Placeholder.
This method is called when the client receives a message from a user.
| Argument | Description |
|---|---|
| nick | The nick of the user that sent the message. |
| message | The text of the message. |
| user | The username of the user that sent the message. |
| host | The host of the user that sent the message. |
Placeholder.
This method is called when the client’s nick on the network is changed for any reason.
| Argument | Description |
|---|---|
| nick | The client’s new nick. |
Placeholder.
This method is called when a leaves enters a channel. That also means that this function is called whenever this IRC client leaves a channel.
| Argument | Description |
|---|---|
| channel | The channel that the user has left. |
| reason | The provided reason message, or an empty string if there is no message. |
| nick | The nick of the user that left the channel. |
| user | The username of the user that left the channel. |
| host | The host of the user that left the channel. |