twisted.words.protocols.irc.IRC(protocol.Protocol)
class documentationtwisted.words.protocols.irc
View Source
(View In Hierarchy)
Known subclasses: twisted.words.service.IRCUser
Internet Relay Chat server protocol.
Method | connectionMade | Called when a connection is made. |
Method | sendLine | Undocumented |
Method | sendMessage | Send a line formatted as an IRC message. |
Method | sendCommand | Send to the remote peer a line formatted as an IRC message. |
Method | dataReceived | This hack is to support mIRC, which sends LF only, even though the RFC says CRLF. (Also, the flexibility of LineReceiver to turn "line mode" on and off was not required.) |
Method | handleCommand | Determine the function to call for the given command and call it with the given arguments. |
Method | irc_unknown | Called by handleCommand
on a command that doesn't have a defined handler. Subclasses should
override this method. |
Method | privmsg | Send a message to a channel or user |
Method | notice | Send a "notice" to a channel or user. |
Method | action | Send an action to a channel or user. |
Method | topic | Send the topic to a user. |
Method | topicAuthor | Send the author of and time at which a topic was set for the given channel. |
Method | names | Send the names of a channel's participants to a user. |
Method | who | Send a list of users participating in a channel. |
Method | whois | Send information about the state of a particular user. |
Method | join | Send a join message. |
Method | part | Send a part message. |
Method | channelMode | Send information about the mode of a channel. |
Method | _stringTags | Converts a tag dictionary to a string. |
Method | _validateTags | Checks the tag dict for errors and raises ValueError
if an error is found. |
Method | _escapeTagValue | Escape the given tag value according to escaping rules in IRCv3. |
Inherited from Protocol:
Method | logPrefix | Return a prefix matching the class name, to identify log messages related to this protocol instance. |
Method | connectionLost | Called when the connection is shut down. |
Inherited from BaseProtocol (via Protocol):
Method | makeConnection | Make a connection to a transport and a server. |
Called when a connection is made.
This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.
Send a line formatted as an IRC message.
First argument is the command, all subsequent arguments are parameters to that command. If a prefix is desired, it may be specified with the keyword argument 'prefix'.
The sendCommand
method is generally preferred over this one. Notably, this method does not
support sending message tags, while the sendCommand
method does.
Send to the remote peer a line formatted as an IRC message.
Parameters | command | The command or numeric to send. (type: unicode ) |
parameters | The parameters to send with the command. (type: A tuple
or list
of unicode
parameters) | |
prefix | The prefix to send with the command. If not given, no prefix is sent. (type: unicode ) | |
tags | A dict of message tags. If not given, no message tags are sent. The dict
key should be the name of the tag to send as a string; the value should be
the unescaped value to send with the tag, or either None or "" if
no value is to be sent with the tag. (type: dict
of tags (unicode ) =>
values (unicode )) | |
See Also | https://ircv3.net/specs/core/message-tags-3.2.html |
Converts a tag dictionary to a string.
Parameters | tags | The tag dict passed to sendMsg. |
Returns | IRCv3-format tag string (type: unicode ) |
Checks the tag dict for errors and raises ValueError
if an error is found.
Parameters | tags | The tag dict passed to sendMsg. |
Escape the given tag value according to escaping rules in IRCv3.
Parameters | value | The string value to escape. (type: str ) |
Returns | The escaped string for sending as a message value (type: str ) |
This hack is to support mIRC, which sends LF only, even though the RFC says CRLF. (Also, the flexibility of LineReceiver to turn "line mode" on and off was not required.)
Determine the function to call for the given command and call it with the given arguments.
Parameters | command | The IRC command to determine the function for. (type: bytes ) |
prefix | The prefix of the IRC message (as returned by parsemsg ). (type: bytes ) | |
params | A list of parameters to call the function with. (type: list ) |
Called by handleCommand
on a command that doesn't have a defined handler. Subclasses should
override this method.
Send a message to a channel or user
Parameters | sender | Who is sending this message. Should be of the form username!ident@hostmask
(unless you know better!). (type: str or unicode ) |
recip | The recipient of this message. If a channel, it must start with a channel
prefix. (type: str or unicode ) | |
message | The message being sent. (type: str or unicode ) |
Send a "notice" to a channel or user.
Notices differ from privmsgs in that the RFC claims they are different. Robots are supposed to send notices and not respond to them. Clients typically display notices differently from privmsgs.
Parameters | sender | Who is sending this message. Should be of the form username!ident@hostmask
(unless you know better!). (type: str or unicode ) |
recip | The recipient of this message. If a channel, it must start with a channel
prefix. (type: str or unicode ) | |
message | The message being sent. (type: str or unicode ) |
Send an action to a channel or user.
Parameters | sender | Who is sending this message. Should be of the form username!ident@hostmask
(unless you know better!). (type: str or unicode ) |
recip | The recipient of this message. If a channel, it must start with a channel
prefix. (type: str or unicode ) | |
message | The action being sent. (type: str or unicode ) |
Send the topic to a user.
Parameters | user | The user receiving the topic. Only their nickname, not the full hostmask. (type: str or unicode ) |
channel | The channel for which this is the topic. (type: str or unicode ) | |
topic | The topic string, unquoted, or None if there is no topic. (type: str or unicode or None ) | |
author | If the topic is being changed, the full username and hostmask of the person
changing it. (type: str or unicode ) |
Send the author of and time at which a topic was set for the given channel.
This sends a 333 reply message, which is not part of the IRC RFC.
Parameters | user | The user receiving the topic. Only their nickname, not the full hostmask. (type: str or unicode ) |
channel | The channel for which this information is relevant. (type: str or unicode ) | |
author | The nickname (without hostmask) of the user who last set the topic. (type: str or unicode ) | |
date | A POSIX timestamp (number of seconds since the epoch) at which the topic
was last set. (type: int ) |
Send the names of a channel's participants to a user.
Parameters | user | The user receiving the name list. Only their nickname, not the full
hostmask. (type: str or unicode ) |
channel | The channel for which this is the namelist. (type: str or unicode ) | |
names | The names to send. (type: list of str or unicode ) |
Send a list of users participating in a channel.
Parameters | user | The user receiving this member information. Only their nickname, not the
full hostmask. (type: str or unicode ) |
channel | The channel for which this is the member information. (type: str or unicode ) | |
memberInfo | For each member of the given channel, a 7-tuple containing their username,
their hostmask, the server to which they are connected, their nickname, the
letter "H" or "G" (standing for "Here" or
"Gone"), the hopcount from user to this member, and
this member's real name. (type: list of tuples ) |
Send information about the state of a particular user.
Parameters | user | The user receiving this information. Only their nickname, not the full
hostmask. (type: str or unicode ) |
nick | The nickname of the user this information describes. (type: str or unicode ) | |
username | The user's username (eg, ident response) (type: str or unicode ) | |
hostname | The user's hostmask (type: str ) | |
realName | The user's real name (type: str or unicode ) | |
server | The name of the server to which the user is connected (type: str or unicode ) | |
serverInfo | A descriptive string about that server (type: str or unicode ) | |
oper | Indicates whether the user is an IRC operator (type: bool ) | |
idle | The number of seconds since the user last sent a message (type: int ) | |
signOn | A POSIX timestamp (number of seconds since the epoch) indicating the time
the user signed on (type: int ) | |
channels | A list of the channels which the user is participating in (type: list of str or unicode ) |
Send a join message.
Parameters | who | The name of the user joining. Should be of the form
username!ident@hostmask (unless you know better!). (type: str or unicode ) |
where | The channel the user is joining. (type: str or unicode ) |
Send a part message.
Parameters | who | The name of the user joining. Should be of the form
username!ident@hostmask (unless you know better!). (type: str or unicode ) |
where | The channel the user is joining. (type: str or unicode ) | |
reason | A string describing the misery which caused this poor soul to depart. (type: str or unicode ) |
Send information about the mode of a channel.
Parameters | user | The user receiving the name list. Only their nickname, not the full
hostmask. (type: str or unicode ) |
channel | The channel for which this is the namelist. (type: str or unicode ) | |
mode | A string describing this channel's modes. (type: str ) | |
args | Any additional arguments required by the modes. |