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

CHANNEL_PREFIXES

Type:
string
Value:
'&#!+'                                                                 

CR

Type:
string
Value:
'\r'                                                                   

ERR_ALREADYREGISTRED

Type:
string
Value:
'462'                                                                  

ERR_BADCHANMASK

Type:
string
Value:
'476'                                                                  

ERR_BADCHANNELKEY

Type:
string
Value:
'475'                                                                  

ERR_BADMASK

Type:
string
Value:
'415'                                                                  

ERR_BANLISTFULL

Type:
string
Value:
'478'                                                                  

ERR_BANNEDFROMCHAN

Type:
string
Value:
'474'                                                                  

ERR_CANNOTSENDTOCHAN

Type:
string
Value:
'404'                                                                  

ERR_CANTKILLSERVER

Type:
string
Value:
'483'                                                                  

ERR_CHANNELISFULL

Type:
string
Value:
'471'                                                                  

ERR_CHANOPRIVSNEEDED

Type:
string
Value:
'482'                                                                  

ERR_ERRONEUSNICKNAME

Type:
string
Value:
'432'                                                                  

ERR_FILEERROR

Type:
string
Value:
'424'                                                                  

ERR_INVITEONLYCHAN

Type:
string
Value:
'473'                                                                  

ERR_KEYSET

Type:
string
Value:
'467'                                                                  

ERR_NEEDMOREPARAMS

Type:
string
Value:
'461'                                                                  

ERR_NICKCOLLISION

Type:
string
Value:
'436'                                                                  

ERR_NICKNAMEINUSE

Type:
string
Value:
'433'                                                                  

ERR_NOADMININFO

Type:
string
Value:
'423'                                                                  

ERR_NOCHANMODES

Type:
string
Value:
'477'                                                                  

ERR_NOLOGIN

Type:
string
Value:
'444'                                                                  

ERR_NOMOTD

Type:
string
Value:
'422'                                                                  

ERR_NONICKNAMEGIVEN

Type:
string
Value:
'431'                                                                  

ERR_NOOPERHOST

Type:
string
Value:
'491'                                                                  

ERR_NOORIGIN

Type:
string
Value:
'409'                                                                  

ERR_NOPERMFORHOST

Type:
string
Value:
'463'                                                                  

ERR_NOPRIVILEGES

Type:
string
Value:
'481'                                                                  

ERR_NORECIPIENT

Type:
string
Value:
'411'                                                                  

ERR_NOSERVICEHOST

Type:
string
Value:
'492'                                                                  

ERR_NOSUCHCHANNEL

Type:
string
Value:
'403'                                                                  

ERR_NOSUCHNICK

Type:
string
Value:
'401'                                                                  

ERR_NOSUCHSERVER

Type:
string
Value:
'402'                                                                  

ERR_NOSUCHSERVICE

Type:
string
Value:
'408'                                                                  

ERR_NOTEXTTOSEND

Type:
string
Value:
'412'                                                                  

ERR_NOTONCHANNEL

Type:
string
Value:
'442'                                                                  

ERR_NOTOPLEVEL

Type:
string
Value:
'413'                                                                  

ERR_NOTREGISTERED

Type:
string
Value:
'451'                                                                  

ERR_PASSWDMISMATCH

Type:
string
Value:
'464'                                                                  

ERR_RESTRICTED

Type:
string
Value:
'484'                                                                  

ERR_SUMMONDISABLED

Type:
string
Value:
'445'                                                                  

ERR_TOOMANYCHANNELS

Type:
string
Value:
'405'                                                                  

ERR_TOOMANYTARGETS

Type:
string
Value:
'407'                                                                  

ERR_UMODEUNKNOWNFLAG

Type:
string
Value:
'501'                                                                  

ERR_UNAVAILRESOURCE

Type:
string
Value:
'437'                                                                  

ERR_UNIQOPPRIVSNEEDED

Type:
string
Value:
'485'                                                                  

ERR_UNKNOWNCOMMAND

Type:
string
Value:
'421'                                                                  

ERR_UNKNOWNMODE

Type:
string
Value:
'472'                                                                  

ERR_USERNOTINCHANNEL

Type:
string
Value:
'441'                                                                  

ERR_USERONCHANNEL

Type:
string
Value:
'443'                                                                  

ERR_USERSDISABLED

Type:
string
Value:
'446'                                                                  

ERR_USERSDONTMATCH

Type:
string
Value:
'502'                                                                  

ERR_WASNOSUCHNICK

Type:
string
Value:
'406'                                                                  

ERR_WILDTOPLEVEL

Type:
string
Value:
'414'                                                                  

ERR_YOUREBANNEDCREEP

Type:
string
Value:
'465'                                                                  

ERR_YOUWILLBEBANNED

Type:
string
Value:
'466'                                                                  

k

Type:
string
Value:
'RPL_SERVLISTEND'                                                      

LF

Type:
string
Value:
'''
'''                                                                    

M_QUOTE

Type:
string
Value:
'\x10'                                                                 

mDequoteTable

Type:
dictionary
Value:
{'n': '\n', 'r': '\r', '0': '\x00', '\x10': '\x10'}                    

mEscape_re

Type:
SRE_Pattern
Value:
.                                                                     

mQuoteTable

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

NL

Type:
string
Value:
'''
'''                                                                    

NUL

Type:
string
Value:
'\x00'                                                                 

numeric_to_symbolic

Type:
dictionary
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 0x834759c>         

RPL_ADMINEMAIL

Type:
string
Value:
'259'                                                                  

RPL_ADMINLOC

Type:
string
Value:
'258'                                                                  

RPL_ADMINME

Type:
string
Value:
'256'                                                                  

RPL_AWAY

Type:
string
Value:
'301'                                                                  

RPL_BANLIST

Type:
string
Value:
'367'                                                                  

RPL_BOUNCE

Type:
string
Value:
'005'                                                                  

RPL_CHANNELMODEIS

Type:
string
Value:
'324'                                                                  

RPL_CREATED

Type:
string
Value:
'003'                                                                  

RPL_ENDOFBANLIST

Type:
string
Value:
'368'                                                                  

RPL_ENDOFEXCEPTLIST

Type:
string
Value:
'349'                                                                  

RPL_ENDOFINFO

Type:
string
Value:
'374'                                                                  

RPL_ENDOFINVITELIST

Type:
string
Value:
'347'                                                                  

RPL_ENDOFLINKS

Type:
string
Value:
'365'                                                                  

RPL_ENDOFMOTD

Type:
string
Value:
'376'                                                                  

RPL_ENDOFNAMES

Type:
string
Value:
'366'                                                                  

RPL_ENDOFSTATS

Type:
string
Value:
'219'                                                                  

RPL_ENDOFUSERS

Type:
string
Value:
'394'                                                                  

RPL_ENDOFWHO

Type:
string
Value:
'315'                                                                  

RPL_ENDOFWHOIS

Type:
string
Value:
'318'                                                                  

RPL_ENDOFWHOWAS

Type:
string
Value:
'369'                                                                  

RPL_EXCEPTLIST

Type:
string
Value:
'348'                                                                  

RPL_INFO

Type:
string
Value:
'371'                                                                  

RPL_INVITELIST

Type:
string
Value:
'346'                                                                  

RPL_INVITING

Type:
string
Value:
'341'                                                                  

RPL_ISON

Type:
string
Value:
'303'                                                                  

RPL_LINKS

Type:
string
Value:
'364'                                                                  

RPL_LIST

Type:
string
Value:
'322'                                                                  

RPL_LISTEND

Type:
string
Value:
'323'                                                                  

RPL_LISTSTART

Type:
string
Value:
'321'                                                                  

RPL_LUSERCHANNELS

Type:
string
Value:
'254'                                                                  

RPL_LUSERCLIENT

Type:
string
Value:
'251'                                                                  

RPL_LUSERME

Type:
string
Value:
'255'                                                                  

RPL_LUSEROP

Type:
string
Value:
'252'                                                                  

RPL_LUSERUNKNOWN

Type:
string
Value:
'253'                                                                  

RPL_MOTD

Type:
string
Value:
'372'                                                                  

RPL_MOTDSTART

Type:
string
Value:
'375'                                                                  

RPL_MYINFO

Type:
string
Value:
'004'                                                                  

RPL_NAMREPLY

Type:
string
Value:
'353'                                                                  

RPL_NOTOPIC

Type:
string
Value:
'331'                                                                  

RPL_NOUSERS

Type:
string
Value:
'395'                                                                  

RPL_NOWAWAY

Type:
string
Value:
'306'                                                                  

RPL_REHASHING

Type:
string
Value:
'382'                                                                  

RPL_SERVLIST

Type:
string
Value:
'234'                                                                  

RPL_SERVLISTEND

Type:
string
Value:
'235'                                                                  

RPL_STATSCOMMANDS

Type:
string
Value:
'212'                                                                  

RPL_STATSLINKINFO

Type:
string
Value:
'211'                                                                  

RPL_STATSOLINE

Type:
string
Value:
'243'                                                                  

RPL_STATSUPTIME

Type:
string
Value:
'242'                                                                  

RPL_SUMMONING

Type:
string
Value:
'342'                                                                  

RPL_TIME

Type:
string
Value:
'391'                                                                  

RPL_TOPIC

Type:
string
Value:
'332'                                                                  

RPL_TRACECLASS

Type:
string
Value:
'209'                                                                  

RPL_TRACECONNECTING

Type:
string
Value:
'201'                                                                  

RPL_TRACEEND

Type:
string
Value:
'262'                                                                  

RPL_TRACEHANDSHAKE

Type:
string
Value:
'202'                                                                  

RPL_TRACELINK

Type:
string
Value:
'200'                                                                  

RPL_TRACELOG

Type:
string
Value:
'261'                                                                  

RPL_TRACENEWTYPE

Type:
string
Value:
'208'                                                                  

RPL_TRACEOPERATOR

Type:
string
Value:
'204'                                                                  

RPL_TRACERECONNECT

Type:
string
Value:
'210'                                                                  

RPL_TRACESERVER

Type:
string
Value:
'206'                                                                  

RPL_TRACESERVICE

Type:
string
Value:
'207'                                                                  

RPL_TRACEUNKNOWN

Type:
string
Value:
'203'                                                                  

RPL_TRACEUSER

Type:
string
Value:
'205'                                                                  

RPL_TRYAGAIN

Type:
string
Value:
'263'                                                                  

RPL_UMODEIS

Type:
string
Value:
'221'                                                                  

RPL_UNAWAY

Type:
string
Value:
'305'                                                                  

RPL_UNIQOPIS

Type:
string
Value:
'325'                                                                  

RPL_USERHOST

Type:
string
Value:
'302'                                                                  

RPL_USERS

Type:
string
Value:
'393'                                                                  

RPL_USERSSTART

Type:
string
Value:
'392'                                                                  

RPL_VERSION

Type:
string
Value:
'351'                                                                  

RPL_WELCOME

Type:
string
Value:
'001'                                                                  

RPL_WHOISCHANNELS

Type:
string
Value:
'319'                                                                  

RPL_WHOISIDLE

Type:
string
Value:
'317'                                                                  

RPL_WHOISOPERATOR

Type:
string
Value:
'313'                                                                  

RPL_WHOISSERVER

Type:
string
Value:
'312'                                                                  

RPL_WHOISUSER

Type:
string
Value:
'311'                                                                  

RPL_WHOREPLY

Type:
string
Value:
'352'                                                                  

RPL_WHOWASUSER

Type:
string
Value:
'314'                                                                  

RPL_YOUREOPER

Type:
string
Value:
'381'                                                                  

RPL_YOURESERVICE

Type:
string
Value:
'383'                                                                  

RPL_YOURHOST

Type:
string
Value:
'002'                                                                  

SPC

Type:
string
Value:
' '                                                                    

symbolic_to_numeric

Type:
dictionary
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:
string
Value:
'235'                                                                  

X_DELIM

Type:
string
Value:
'\x01'                                                                 

X_QUOTE

Type:
string
Value:
'\\'                                                                   

xDequoteTable

Type:
dictionary
Value:
{'\\': '\\', 'a': '\x01'}                                              

xEscape_re

Type:
SRE_Pattern
Value:
\\.                                                                    

xQuoteTable

Type:
dictionary
Value:
{'\\': '\\\\', '\x01': '\\a'}                                          

Generated by Epydoc 1.1 on Sat Feb 15 21:19:13 2003 http://epydoc.sf.net