pants.contrib.irc
¶
BaseIRC¶
-
class
pants.contrib.irc.
BaseIRC
(encoding='utf-8', **kwargs)[source]¶ 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 sameconnect()
andlisten()
functions.-
irc_close
()[source]¶ Placeholder.
This method is called whenever the IRC instance becomes disconnected from the remote client or server.
-
irc_command
(command, args, nick, user, host)[source]¶ 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.
-
irc_connect
()[source]¶ Placeholder.
This method is called when the IRC instance has successfully connected to the remote client or server.
-
message
(destination, message, _ctcpQuote=True, _prefix=None)[source]¶ 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.
-
notice
(destination, message, _ctcpQuote=True, _prefix=None)[source]¶ 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.
-
quit
(reason=None, _prefix=None)[source]¶ 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_command
(command, *args, **kwargs)[source]¶ 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.
-
Channel¶
IRCClient¶
-
class
pants.contrib.irc.
IRCClient
(encoding='utf-8', **kwargs)[source]¶ 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.
-
channel
(name)[source]¶ Retrieve a Channel object for the channel
name
, or None if we’re not in that channel.
-
connect
(server=None, port=None)[source]¶ Connect to the server.
Argument Description server The host to connect to. port The port to connect to on the remote server.
-
irc_ctcp
(nick, message, user, host)[source]¶ 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.
-
irc_join
(channel, nick, user, host)[source]¶ 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.
-
irc_message_channel
(channel, message, nick, user, host)[source]¶ 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.
-
irc_message_private
(nick, message, user, host)[source]¶ 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.
-
irc_nick_changed
(nick)[source]¶ 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.
-
irc_part
(channel, reason, nick, user, host)[source]¶ 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.
-
irc_topic_changed
(channel, topic)[source]¶ Placeholder.
This method is called when the topic of a channel changes.
Argument Description channel The channel which had its topic changed. topic The channel’s new topic.
-
join
(channel)[source]¶ Join the specified channel.
Argument Description channel The name of the channel to join.
-
nick
¶ This instance’s current nickname on the server it’s connected to, or the nickname it will attempt to acquire when connecting.
-
part
(channel, reason=None, force=False)[source]¶ 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
.
-
port
¶ The port this instance is connected to on the remote server, or the port it will attempt to connect to.
-
realname
¶ The real name this instance will report to the server when connecting.
-
server
¶ The server this instance is connected to, or will attempt to connect to.
-
user
¶ The user name this instance will report to the server when connecting.
-