Package twisted :: Package protocols :: Module irc

[show private | hide private]
[frames | no frames]

## Module twisted.protocols.irc

Internet Relay Chat Protocol for client and server.

Stability: semi-stable.

# Future Plans

The way the IRCClient class works here encourages people to implement IRC clients by subclassing the ephemeral protocol class, and it tends to end up with way more state than it should for an object which will be destroyed as soon as the TCP transport drops. Someone oughta do something about that, ya know?

The DCC support needs to have more hooks for the client for it to be able to ask the user things like "Do you want to accept this session?" and "Transfer #2 is 67% done." and otherwise manage the DCC sessions.

Test coverage needs to be better.

Author: Kevin Turner<mailto:acapnotic@twistedmatrix.com>

See also:
  RFC 1459: Internet Relay Chat Protocol , RFC 2812: Internet Relay Chat: Client Protocol , The Client-To-Client-Protocol <http://www.irchelp.org/irchelp/rfc/ctcpspec.html>

Classes
`DccChat` | Direct Client Connection protocol type CHAT.
`DccChatFactory` |
`DccFileReceive` | Higher-level coverage for getting a file from DCC SEND.
`DccFileReceiveBasic` | Bare protocol to receive a Direct Client Connection SEND stream.
`DccSendFactory` |
`DccSendProtocol` | Protocol for an outgoing Direct Client Connection SEND.
`IRC` | Internet Relay Chat server protocol.
`IRCClient` | Internet Relay Chat client protocol, with sprinkles.

Exceptions
`IRCBadMessage` |
`IRCPasswordMismatch` |

Function Summary
| `ctcpDequote(s)`
| ``ctcpExtract`(message)` Extract CTCP data from a string.
| `ctcpQuote(s)`
| ``ctcpStringify`(messages)` Return string
| ``dccDescribe`(data)` Given the data chunk from a DCC query, return a descriptive string.
| `dccParseAddress(address)`
| ``fileSize`(file)` I'll try my damndest to determine the size of this file object.
| `lowDequote(s)`
| `lowQuote(s)`
| ``parsemsg`(s)` Breaks a message from an IRC server into its prefix, command, and arguments.
| ``split`(str, length)` I break a message into multiple lines.

Variable Summary
`str` | `__version__`
`str` | `CHANNEL_PREFIXES`
`str` | `CR`
`str` | `ERR_ALREADYREGISTRED`
`str` | `ERR_BADCHANMASK`
`str` | `ERR_BADCHANNELKEY`
`str` | `ERR_BADMASK`
`str` | `ERR_BANLISTFULL`
`str` | `ERR_BANNEDFROMCHAN`
`str` | `ERR_CANNOTSENDTOCHAN`
`str` | `ERR_CANTKILLSERVER`
`str` | `ERR_CHANNELISFULL`
`str` | `ERR_CHANOPRIVSNEEDED`
`str` | `ERR_ERRONEUSNICKNAME`
`str` | `ERR_FILEERROR`
`str` | `ERR_INVITEONLYCHAN`
`str` | `ERR_KEYSET`
`str` | `ERR_NEEDMOREPARAMS`
`str` | `ERR_NICKCOLLISION`
`str` | `ERR_NICKNAMEINUSE`
`str` | `ERR_NOADMININFO`
`str` | `ERR_NOCHANMODES`
`str` | `ERR_NOLOGIN`
`str` | `ERR_NOMOTD`
`str` | `ERR_NONICKNAMEGIVEN`
`str` | `ERR_NOOPERHOST`
`str` | `ERR_NOORIGIN`
`str` | `ERR_NOPERMFORHOST`
`str` | `ERR_NOPRIVILEGES`
`str` | `ERR_NORECIPIENT`
`str` | `ERR_NOSERVICEHOST`
`str` | `ERR_NOSUCHCHANNEL`
`str` | `ERR_NOSUCHNICK`
`str` | `ERR_NOSUCHSERVER`
`str` | `ERR_NOSUCHSERVICE`
`str` | `ERR_NOTEXTTOSEND`
`str` | `ERR_NOTONCHANNEL`
`str` | `ERR_NOTOPLEVEL`
`str` | `ERR_NOTREGISTERED`
`str` | `ERR_PASSWDMISMATCH`
`str` | `ERR_RESTRICTED`
`str` | `ERR_SUMMONDISABLED`
`str` | `ERR_TOOMANYCHANNELS`
`str` | `ERR_TOOMANYTARGETS`
`str` | `ERR_UMODEUNKNOWNFLAG`
`str` | `ERR_UNAVAILRESOURCE`
`str` | `ERR_UNIQOPPRIVSNEEDED`
`str` | `ERR_UNKNOWNCOMMAND`
`str` | `ERR_UNKNOWNMODE`
`str` | `ERR_USERNOTINCHANNEL`
`str` | `ERR_USERONCHANNEL`
`str` | `ERR_USERSDISABLED`
`str` | `ERR_USERSDONTMATCH`
`str` | `ERR_WASNOSUCHNICK`
`str` | `ERR_WILDTOPLEVEL`
`str` | `ERR_YOUREBANNEDCREEP`
`str` | `ERR_YOUWILLBEBANNED`
`str` | `k`
`str` | `LF`
`str` | `M_QUOTE`
`dict` | `mDequoteTable`
`SRE_Pattern` | `mEscape_re`
`dict` | `mQuoteTable`
`str` | `NL`
`str` | `NUL`
`dict` | `numeric_to_symbolic`
`SelectReactor` | `reactor`
`str` | `RPL_ADMINEMAIL`
`str` | `RPL_ADMINLOC`
`str` | `RPL_ADMINME`
`str` | `RPL_AWAY`
`str` | `RPL_BANLIST`
`str` | `RPL_BOUNCE`
`str` | `RPL_CHANNELMODEIS`
`str` | `RPL_CREATED`
`str` | `RPL_ENDOFBANLIST`
`str` | `RPL_ENDOFEXCEPTLIST`
`str` | `RPL_ENDOFINFO`
`str` | `RPL_ENDOFINVITELIST`
`str` | `RPL_ENDOFLINKS`
`str` | `RPL_ENDOFMOTD`
`str` | `RPL_ENDOFNAMES`
`str` | `RPL_ENDOFSTATS`
`str` | `RPL_ENDOFUSERS`
`str` | `RPL_ENDOFWHO`
`str` | `RPL_ENDOFWHOIS`
`str` | `RPL_ENDOFWHOWAS`
`str` | `RPL_EXCEPTLIST`
`str` | `RPL_INFO`
`str` | `RPL_INVITELIST`
`str` | `RPL_INVITING`
`str` | `RPL_ISON`
`str` | `RPL_LINKS`
`str` | `RPL_LIST`
`str` | `RPL_LISTEND`
`str` | `RPL_LISTSTART`
`str` | `RPL_LUSERCHANNELS`
`str` | `RPL_LUSERCLIENT`
`str` | `RPL_LUSERME`
`str` | `RPL_LUSEROP`
`str` | `RPL_LUSERUNKNOWN`
`str` | `RPL_MOTD`
`str` | `RPL_MOTDSTART`
`str` | `RPL_MYINFO`
`str` | `RPL_NAMREPLY`
`str` | `RPL_NOTOPIC`
`str` | `RPL_NOUSERS`
`str` | `RPL_NOWAWAY`
`str` | `RPL_REHASHING`
`str` | `RPL_SERVLIST`
`str` | `RPL_SERVLISTEND`
`str` | `RPL_STATSCOMMANDS`
`str` | `RPL_STATSLINKINFO`
`str` | `RPL_STATSOLINE`
`str` | `RPL_STATSUPTIME`
`str` | `RPL_SUMMONING`
`str` | `RPL_TIME`
`str` | `RPL_TOPIC`
`str` | `RPL_TRACECLASS`
`str` | `RPL_TRACECONNECTING`
`str` | `RPL_TRACEEND`
`str` | `RPL_TRACEHANDSHAKE`
`str` | `RPL_TRACELINK`
`str` | `RPL_TRACELOG`
`str` | `RPL_TRACENEWTYPE`
`str` | `RPL_TRACEOPERATOR`
`str` | `RPL_TRACERECONNECT`
`str` | `RPL_TRACESERVER`
`str` | `RPL_TRACESERVICE`
`str` | `RPL_TRACEUNKNOWN`
`str` | `RPL_TRACEUSER`
`str` | `RPL_TRYAGAIN`
`str` | `RPL_UMODEIS`
`str` | `RPL_UNAWAY`
`str` | `RPL_UNIQOPIS`
`str` | `RPL_USERHOST`
`str` | `RPL_USERS`
`str` | `RPL_USERSSTART`
`str` | `RPL_VERSION`
`str` | `RPL_WELCOME`
`str` | `RPL_WHOISCHANNELS`
`str` | `RPL_WHOISIDLE`
`str` | `RPL_WHOISOPERATOR`
`str` | `RPL_WHOISSERVER`
`str` | `RPL_WHOISUSER`
`str` | `RPL_WHOREPLY`
`str` | `RPL_WHOWASUSER`
`str` | `RPL_YOUREOPER`
`str` | `RPL_YOURESERVICE`
`str` | `RPL_YOURHOST`
`str` | `SPC`
`dict` | `symbolic_to_numeric`
`str` | `v`
`str` | `X_DELIM`
`str` | `X_QUOTE`
`dict` | `xDequoteTable`
`SRE_Pattern` | `xEscape_re`
`dict` | `xQuoteTable`

Function Details

### ctcpExtract(message)

Extract CTCP data from a string.

Returns a dictionary with two items:

- `'extended'`: a list of CTCP (tag, data) tuples
- `'normal'`: a list of strings which were not inside a CTCP delimeter

### ctcpStringify(messages)

  Parameters:
    `messages`
    (type=a list of extended messages. An extended message is a (tag, data) tuple, where 'data' may be `None`, a string, or a list of strings to be joined with whitespace.)
  Returns:
    String

### dccDescribe(data)

Given the data chunk from a DCC query, return a descriptive string.

### fileSize(file)

I'll try my damndest to determine the size of this file object.

### parsemsg(s)

Breaks a message from an IRC server into its prefix, command, and arguments.

### split(str, length=80)

I break a message into multiple lines.

I prefer to break at whitespace near str[length]. I also break at \n.

  Returns:
    list of strings

Variable Details

### __version__

  Type:
    `str`
  Value:

        '1.82'

### CHANNEL_PREFIXES

  Type:
    `str`
  Value:

        '&#!+'

### CR

  Type:
    `str`
  Value:

        '\r'

### ERR_ALREADYREGISTRED

  Type:
    `str`
  Value:

        '462'

### ERR_BADCHANMASK

  Type:
    `str`
  Value:

        '476'

### ERR_BADCHANNELKEY

  Type:
    `str`
  Value:

        '475'

### ERR_BADMASK

  Type:
    `str`
  Value:

        '415'

### ERR_BANLISTFULL

  Type:
    `str`
  Value:

        '478'

### ERR_BANNEDFROMCHAN

  Type:
    `str`
  Value:

        '474'

### ERR_CANNOTSENDTOCHAN

  Type:
    `str`
  Value:

        '404'

### ERR_CANTKILLSERVER

  Type:
    `str`
  Value:

        '483'

### ERR_CHANNELISFULL

  Type:
    `str`
  Value:

        '471'

### ERR_CHANOPRIVSNEEDED

  Type:
    `str`
  Value:

        '482'

### ERR_ERRONEUSNICKNAME

  Type:
    `str`
  Value:

        '432'

### ERR_FILEERROR

  Type:
    `str`
  Value:

        '424'

### ERR_INVITEONLYCHAN

  Type:
    `str`
  Value:

        '473'

### ERR_KEYSET

  Type:
    `str`
  Value:

        '467'

### ERR_NEEDMOREPARAMS

  Type:
    `str`
  Value:

        '461'

### ERR_NICKCOLLISION

  Type:
    `str`
  Value:

        '436'

### ERR_NICKNAMEINUSE

  Type:
    `str`
  Value:

        '433'

### ERR_NOADMININFO

  Type:
    `str`
  Value:

        '423'

### ERR_NOCHANMODES

  Type:
    `str`
  Value:

        '477'

### ERR_NOLOGIN

  Type:
    `str`
  Value:

        '444'

### ERR_NOMOTD

  Type:
    `str`
  Value:

        '422'

### ERR_NONICKNAMEGIVEN

  Type:
    `str`
  Value:

        '431'

### ERR_NOOPERHOST

  Type:
    `str`
  Value:

        '491'

### ERR_NOORIGIN

  Type:
    `str`
  Value:

        '409'

### ERR_NOPERMFORHOST

  Type:
    `str`
  Value:

        '463'

### ERR_NOPRIVILEGES

  Type:
    `str`
  Value:

        '481'

### ERR_NORECIPIENT

  Type:
    `str`
  Value:

        '411'

### ERR_NOSERVICEHOST

  Type:
    `str`
  Value:

        '492'

### ERR_NOSUCHCHANNEL

  Type:
    `str`
  Value:

        '403'

### ERR_NOSUCHNICK

  Type:
    `str`
  Value:

        '401'

### ERR_NOSUCHSERVER

  Type:
    `str`
  Value:

        '402'

### ERR_NOSUCHSERVICE

  Type:
    `str`
  Value:

        '408'

### ERR_NOTEXTTOSEND

  Type:
    `str`
  Value:

        '412'

### ERR_NOTONCHANNEL

  Type:
    `str`
  Value:

        '442'

### ERR_NOTOPLEVEL

  Type:
    `str`
  Value:

        '413'

### ERR_NOTREGISTERED

  Type:
    `str`
  Value:

        '451'

### ERR_PASSWDMISMATCH

  Type:
    `str`
  Value:

        '464'

### ERR_RESTRICTED

  Type:
    `str`
  Value:

        '484'

### ERR_SUMMONDISABLED

  Type:
    `str`
  Value:

        '445'

### ERR_TOOMANYCHANNELS

  Type:
    `str`
  Value:

        '405'

### ERR_TOOMANYTARGETS

  Type:
    `str`
  Value:

        '407'

### ERR_UMODEUNKNOWNFLAG

  Type:
    `str`
  Value:

        '501'

### ERR_UNAVAILRESOURCE

  Type:
    `str`
  Value:

        '437'

### ERR_UNIQOPPRIVSNEEDED

  Type:
    `str`
  Value:

        '485'

### ERR_UNKNOWNCOMMAND

  Type:
    `str`
  Value:

        '421'

### ERR_UNKNOWNMODE

  Type:
    `str`
  Value:

        '472'

### ERR_USERNOTINCHANNEL

  Type:
    `str`
  Value:

        '441'

### ERR_USERONCHANNEL

  Type:
    `str`
  Value:

        '443'

### ERR_USERSDISABLED

  Type:
    `str`
  Value:

        '446'

### ERR_USERSDONTMATCH

  Type:
    `str`
  Value:

        '502'

### ERR_WASNOSUCHNICK

  Type:
    `str`
  Value:

        '406'

### ERR_WILDTOPLEVEL

  Type:
    `str`
  Value:

        '414'

### ERR_YOUREBANNEDCREEP

  Type:
    `str`
  Value:

        '465'

### ERR_YOUWILLBEBANNED

  Type:
    `str`
  Value:

        '466'

### k

  Type:
    `str`
  Value:

        'RPL_TRACEOPERATOR'

### LF

  Type:
    `str`
  Value:

        '''
        '''

### M_QUOTE

  Type:
    `str`
  Value:

        '\x10'

### mDequoteTable

  Type:
    `dict`
  Value:

        {'0': '\x00', 'r': '\r', '\x10': '\x10', 'n': '\n'}

### mEscape_re

  Type:
    `SRE_Pattern`
  Value:

        .

### mQuoteTable

  Type:
    `dict`
  Value:

        {'\x00': '\x100', '\n': '\x10n', '\r': '\x10r', '\x10': '\x10\x10'}

### NL

  Type:
    `str`
  Value:

        '''
        '''

### NUL

  Type:
    `str`
  Value:

        '\x00'

### numeric_to_symbolic

  Type:
    `dict`
  Value:

        {'001': 'RPL_WELCOME',
         '002': 'RPL_YOURHOST',
         '003': 'RPL_CREATED',
         '004': 'RPL_MYINFO',
         '005': 'RPL_BOUNCE',
         '200': 'RPL_TRACELINK',
         '201': 'RPL_TRACECONNECTING',
         '202': 'RPL_TRACEHANDSHAKE',
        ...

### reactor

  Type:
    `SelectReactor`
  Value:

        <twisted.internet.default.SelectReactor instance at 0x82e8c8c>

### RPL_ADMINEMAIL

  Type:
    `str`
  Value:

        '259'

### RPL_ADMINLOC

  Type:
    `str`
  Value:

        '258'

### RPL_ADMINME

  Type:
    `str`
  Value:

        '256'

### RPL_AWAY

  Type:
    `str`
  Value:

        '301'

### RPL_BANLIST

  Type:
    `str`
  Value:

        '367'

### RPL_BOUNCE

  Type:
    `str`
  Value:

        '005'

### RPL_CHANNELMODEIS

  Type:
    `str`
  Value:

        '324'

### RPL_CREATED

  Type:
    `str`
  Value:

        '003'

### RPL_ENDOFBANLIST

  Type:
    `str`
  Value:

        '368'

### RPL_ENDOFEXCEPTLIST

  Type:
    `str`
  Value:

        '349'

### RPL_ENDOFINFO

  Type:
    `str`
  Value:

        '374'

### RPL_ENDOFINVITELIST

  Type:
    `str`
  Value:

        '347'

### RPL_ENDOFLINKS

  Type:
    `str`
  Value:

        '365'

### RPL_ENDOFMOTD

  Type:
    `str`
  Value:

        '376'

### RPL_ENDOFNAMES

  Type:
    `str`
  Value:

        '366'

### RPL_ENDOFSTATS

  Type:
    `str`
  Value:

        '219'

### RPL_ENDOFUSERS

  Type:
    `str`
  Value:

        '394'

### RPL_ENDOFWHO

  Type:
    `str`
  Value:

        '315'

### RPL_ENDOFWHOIS

  Type:
    `str`
  Value:

        '318'

### RPL_ENDOFWHOWAS

  Type:
    `str`
  Value:

        '369'

### RPL_EXCEPTLIST

  Type:
    `str`
  Value:

        '348'

### RPL_INFO

  Type:
    `str`
  Value:

        '371'

### RPL_INVITELIST

  Type:
    `str`
  Value:

        '346'

### RPL_INVITING

  Type:
    `str`
  Value:

        '341'

### RPL_ISON

  Type:
    `str`
  Value:

        '303'

### RPL_LINKS

  Type:
    `str`
  Value:

        '364'

### RPL_LIST

  Type:
    `str`
  Value:

        '322'

### RPL_LISTEND

  Type:
    `str`
  Value:

        '323'

### RPL_LISTSTART

  Type:
    `str`
  Value:

        '321'

### RPL_LUSERCHANNELS

  Type:
    `str`
  Value:

        '254'

### RPL_LUSERCLIENT

  Type:
    `str`
  Value:

        '251'

### RPL_LUSERME

  Type:
    `str`
  Value:

        '255'

### RPL_LUSEROP

  Type:
    `str`
  Value:

        '252'

### RPL_LUSERUNKNOWN

  Type:
    `str`
  Value:

        '253'

### RPL_MOTD

  Type:
    `str`
  Value:

        '372'

### RPL_MOTDSTART

  Type:
    `str`
  Value:

        '375'

### RPL_MYINFO

  Type:
    `str`
  Value:

        '004'

### RPL_NAMREPLY

  Type:
    `str`
  Value:

        '353'

### RPL_NOTOPIC

  Type:
    `str`
  Value:

        '331'

### RPL_NOUSERS

  Type:
    `str`
  Value:

        '395'

### RPL_NOWAWAY

  Type:
    `str`
  Value:

        '306'

### RPL_REHASHING

  Type:
    `str`
  Value:

        '382'

### RPL_SERVLIST

  Type:
    `str`
  Value:

        '234'

### RPL_SERVLISTEND

  Type:
    `str`
  Value:

        '235'

### RPL_STATSCOMMANDS

  Type:
    `str`
  Value:

        '212'

### RPL_STATSLINKINFO

  Type:
    `str`
  Value:

        '211'

### RPL_STATSOLINE

  Type:
    `str`
  Value:

        '243'

### RPL_STATSUPTIME

  Type:
    `str`
  Value:

        '242'

### RPL_SUMMONING

  Type:
    `str`
  Value:

        '342'

### RPL_TIME

  Type:
    `str`
  Value:

        '391'

### RPL_TOPIC

  Type:
    `str`
  Value:

        '332'

### RPL_TRACECLASS

  Type:
    `str`
  Value:

        '209'

### RPL_TRACECONNECTING

  Type:
    `str`
  Value:

        '201'

### RPL_TRACEEND

  Type:
    `str`
  Value:

        '262'

### RPL_TRACEHANDSHAKE

  Type:
    `str`
  Value:

        '202'

### RPL_TRACELINK

  Type:
    `str`
  Value:

        '200'

### RPL_TRACELOG

  Type:
    `str`
  Value:

        '261'

### RPL_TRACENEWTYPE

  Type:
    `str`
  Value:

        '208'

### RPL_TRACEOPERATOR

  Type:
    `str`
  Value:

        '204'

### RPL_TRACERECONNECT

  Type:
    `str`
  Value:

        '210'

### RPL_TRACESERVER

  Type:
    `str`
  Value:

        '206'

### RPL_TRACESERVICE

  Type:
    `str`
  Value:

        '207'

### RPL_TRACEUNKNOWN

  Type:
    `str`
  Value:

        '203'

### RPL_TRACEUSER

  Type:
    `str`
  Value:

        '205'

### RPL_TRYAGAIN

  Type:
    `str`
  Value:

        '263'

### RPL_UMODEIS

  Type:
    `str`
  Value:

        '221'

### RPL_UNAWAY

  Type:
    `str`
  Value:

        '305'

### RPL_UNIQOPIS

  Type:
    `str`
  Value:

        '325'

### RPL_USERHOST

  Type:
    `str`
  Value:

        '302'

### RPL_USERS

  Type:
    `str`
  Value:

        '393'

### RPL_USERSSTART

  Type:
    `str`
  Value:

        '392'

### RPL_VERSION

  Type:
    `str`
  Value:

        '351'

### RPL_WELCOME

  Type:
    `str`
  Value:

        '001'

### RPL_WHOISCHANNELS

  Type:
    `str`
  Value:

        '319'

### RPL_WHOISIDLE

  Type:
    `str`
  Value:

        '317'

### RPL_WHOISOPERATOR

  Type:
    `str`
  Value:

        '313'

### RPL_WHOISSERVER

  Type:
    `str`
  Value:

        '312'

### RPL_WHOISUSER

  Type:
    `str`
  Value:

        '311'

### RPL_WHOREPLY

  Type:
    `str`
  Value:

        '352'

### RPL_WHOWASUSER

  Type:
    `str`
  Value:

        '314'

### RPL_YOUREOPER

  Type:
    `str`
  Value:

        '381'

### RPL_YOURESERVICE

  Type:
    `str`
  Value:

        '383'

### RPL_YOURHOST

  Type:
    `str`
  Value:

        '002'

### SPC

  Type:
    `str`
  Value:

        ' '

### symbolic_to_numeric

  Type:
    `dict`
  Value:

        {'ERR_ALREADYREGISTRED': '462',
         'ERR_BADCHANMASK': '476',
         'ERR_BADCHANNELKEY': '475',
         'ERR_BADMASK': '415',
         'ERR_BANLISTFULL': '478',
         'ERR_BANNEDFROMCHAN': '474',
         'ERR_CANNOTSENDTOCHAN': '404',
         'ERR_CANTKILLSERVER': '483',
        ...

### v

  Type:
    `str`
  Value:

        '204'

### X_DELIM

  Type:
    `str`
  Value:

        '\x01'

### X_QUOTE

  Type:
    `str`
  Value:

        '\\'

### xDequoteTable

  Type:
    `dict`
  Value:

        {'a': '\x01', '\\': '\\'}

### xEscape_re

  Type:
    `SRE_Pattern`
  Value:

        \\.

### xQuoteTable

  Type:
    `dict`
  Value:

        {'\x01': '\\a', '\\': '\\\\'}

Generated by Epydoc 1.1 on Thu May 8 13:16:39 2003 | http://epydoc.sf.net