Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`words`.`protocols`.`irc`.`IRC``

class documentation

`class IRC(protocol.Protocol): (source)`

Known subclasses: `twisted.words.service.IRCUser`

View In Hierarchy

Internet Relay Chat server protocol.

Method | `action` | Send an action to a channel or user.
Method | `channelMode` | Send information about the mode of a channel.
Method | `connectionMade` | Called when a connection is made.
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 | `join` | Send a join message.
Method | `names` | Send the names of a channel's participants to a user.
Method | `notice` | Send a "notice" to a channel or user.
Method | `part` | Send a part message.
Method | `privmsg` | Send a message to a channel or user
Method | `sendCommand` | Send to the remote peer a line formatted as an IRC message.
Method | `sendLine` | Undocumented
Method | `sendMessage` | Send a line formatted as an IRC message.
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 | `who` | Send a list of users participating in a channel.
Method | `whois` | Send information about the state of a particular user.
Class Variable | `encoding` | Undocumented
Instance Variable | `buffer` | Undocumented
Instance Variable | `channels` | Undocumented
Instance Variable | `hostname` | Undocumented
Method | `_escapeTagValue` | Escape the given tag value according to escaping rules in IRCv3.
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.

Inherited from `Protocol`:

Method | `connectionLost` | Called when the connection is shut down.
Method | `logPrefix` | Return a prefix matching the class name, to identify log messages related to this protocol instance.
Class Variable | `factory` | Undocumented

Inherited from `BaseProtocol` (via `Protocol`):

Method | `makeConnection` | Make a connection to a transport and a server.
Instance Variable | `connected` | Undocumented
Instance Variable | `transport` | Undocumented

def action(self, sender, recip, message): (source)

Send an action to a channel or user.

Parameters
sender:`str` or `unicode` | Who is sending this message. Should be of the form username!ident@hostmask (unless you know better!).
recip:`str` or `unicode` | The recipient of this message. If a channel, it must start with a channel prefix.
message:`str` or `unicode` | The action being sent.

def channelMode(self, user, channel, mode, *args): (source)

Send information about the mode of a channel.

Parameters
user:`str` or `unicode` | The user receiving the name list. Only their nickname, not the full hostmask.
channel:`str` or `unicode` | The channel for which this is the namelist.
mode:`str` | A string describing this channel's modes.
*args | Any additional arguments required by the modes.

def connectionMade(self): (source)
from `twisted.internet.interfaces.IProtocol`
overrides `twisted.internet.protocol.BaseProtocol.connectionMade`
overridden in `twisted.words.service.IRCUser`

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.

def dataReceived(self, data): (source)
from `twisted.internet.interfaces.IProtocol`
overrides `twisted.internet.protocol.Protocol.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.)

def handleCommand(self, command, prefix, params): (source)

Determine the function to call for the given command and call it with the given arguments.

Parameters
command:`bytes` | The IRC command to determine the function for.
prefix:`bytes` | The prefix of the IRC message (as returned by `parsemsg`).
params:`list` | A list of parameters to call the function with.

def irc_unknown(self, prefix, command, params): (source)

Called by `handleCommand` on a command that doesn't have a defined handler. Subclasses should override this method.

def join(self, who, where): (source)

Send a join message.

Parameters
who:`str` or `unicode` | The name of the user joining. Should be of the form username!ident@hostmask (unless you know better!).
where:`str` or `unicode` | The channel the user is joining.

def names(self, user, channel, names): (source)

Send the names of a channel's participants to a user.

Parameters
user:`str` or `unicode` | The user receiving the name list. Only their nickname, not the full hostmask.
channel:`str` or `unicode` | The channel for which this is the namelist.
names:`list` of `str` or `unicode` | The names to send.

def notice(self, sender, recip, message): (source)

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:`str` or `unicode` | Who is sending this message. Should be of the form username!ident@hostmask (unless you know better!).
recip:`str` or `unicode` | The recipient of this message. If a channel, it must start with a channel prefix.
message:`str` or `unicode` | The message being sent.

def part(self, who, where, reason=None): (source)

Send a part message.

Parameters
who:`str` or `unicode` | The name of the user joining. Should be of the form username!ident@hostmask (unless you know better!).
where:`str` or `unicode` | The channel the user is joining.
reason:`str` or `unicode` | A string describing the misery which caused this poor soul to depart.

def privmsg(self, sender, recip, message): (source)

Send a message to a channel or user

Parameters
sender:`str` or `unicode` | Who is sending this message. Should be of the form username!ident@hostmask (unless you know better!).
recip:`str` or `unicode` | The recipient of this message. If a channel, it must start with a channel prefix.
message:`str` or `unicode` | The message being sent.

def sendCommand(self, command, parameters, prefix=None, tags=None): (source)

Send to the remote peer a line formatted as an IRC message.

Parameters
command:`unicode` | The command or numeric to send.
parameters:A `tuple` or `list` of `unicode` parameters | The parameters to send with the command.
prefix:`unicode` | The prefix to send with the command. If not given, no prefix is sent.
tags:`dict` of tags (`unicode`) => values (`unicode`) | 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.
See Also
https://ircv3.net/specs/core/message-tags-3.2.html

def sendLine(self, line): (source)

Undocumented

def sendMessage(self, command, *parameter_list, **prefix): (source)
overridden in `twisted.words.service.IRCUser`

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.

def topic(self, user, channel, topic, author=None): (source)

Send the topic to a user.

Parameters
user:`str` or `unicode` | The user receiving the topic. Only their nickname, not the full hostmask.
channel:`str` or `unicode` | The channel for which this is the topic.
topic:`str` or `unicode` or `None` | The topic string, unquoted, or None if there is no topic.
author:`str` or `unicode` | If the topic is being changed, the full username and hostmask of the person changing it.

def topicAuthor(self, user, channel, author, date): (source)

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:`str` or `unicode` | The user receiving the topic. Only their nickname, not the full hostmask.
channel:`str` or `unicode` | The channel for which this information is relevant.
author:`str` or `unicode` | The nickname (without hostmask) of the user who last set the topic.
date:`int` | A POSIX timestamp (number of seconds since the epoch) at which the topic was last set.

def who(self, user, channel, memberInfo): (source)

Send a list of users participating in a channel.

Parameters
user:`str` or `unicode` | The user receiving this member information. Only their nickname, not the full hostmask.
channel:`str` or `unicode` | The channel for which this is the member information.
memberInfo:`list` of `tuples` | 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.

def whois(self, user, nick, username, hostname, realName, server, serverInfo, oper, idle, signOn, channels): (source)

Send information about the state of a particular user.

Parameters
user:`str` or `unicode` | The user receiving this information. Only their nickname, not the full hostmask.
nick:`str` or `unicode` | The nickname of the user this information describes.
username:`str` or `unicode` | The user's username (eg, ident response)
hostname:`str` | The user's hostmask
realName:`str` or `unicode` | The user's real name
server:`str` or `unicode` | The name of the server to which the user is connected
serverInfo:`str` or `unicode` | A descriptive string about that server
oper:`bool` | Indicates whether the user is an IRC operator
idle:`int` | The number of seconds since the user last sent a message
signOn:`int` | A POSIX timestamp (number of seconds since the epoch) indicating the time the user signed on
channels:`list` of `str` or `unicode` | A list of the channels which the user is participating in

encoding: `Optional[str]` = (source)
overridden in `twisted.words.service.IRCUser`

Undocumented

buffer = (source)

Undocumented

channels: `list` = (source)

Undocumented

hostname = (source)
overridden in `twisted.words.service.IRCUser`

Undocumented

def _escapeTagValue(self, value): (source)

Escape the given tag value according to escaping rules in IRCv3.

Parameters
value:`str` | The string value to escape.
Returns
`str` | The escaped string for sending as a message value

def _stringTags(self, tags): (source)

Converts a tag dictionary to a string.

Parameters
tags | The tag dict passed to sendMsg.
Returns
`unicode` | IRCv3-format tag string

def _validateTags(self, tags): (source)

Checks the tag dict for errors and raises `ValueError` if an error is found.

Parameters
tags | The tag dict passed to sendMsg.