<s> """<STR_LIT>""" <EOL> import errno , os , random , re , stat , struct , sys , time , types , traceback <EOL> import string , socket <EOL> import warnings <EOL> import textwrap <EOL> from os import path <EOL> from twisted . internet import reactor , protocol <EOL> from twisted . persisted import styles <EOL> from twisted . protocols import basic <EOL> from twisted . python import log , reflect , text <EOL> NUL = chr ( <NUM_LIT:0> ) <EOL> CR = chr ( <NUM_LIT:0> <NUM_LIT:15> ) <EOL> NL = chr ( <NUM_LIT:0> <NUM_LIT:12> ) <EOL> LF = NL <EOL> SPC = chr ( <NUM_LIT:0> <NUM_LIT> ) <EOL> MAX_COMMAND_LENGTH = <NUM_LIT> <EOL> CHANNEL_PREFIXES = '<STR_LIT>' <EOL> class IRCBadMessage ( Exception ) : <EOL> pass <EOL> class IRCPasswordMismatch ( Exception ) : <EOL> pass <EOL> class IRCBadModes ( ValueError ) : <EOL> """<STR_LIT>""" <EOL> def parsemsg ( s ) : <EOL> """<STR_LIT>""" <EOL> prefix = '<STR_LIT>' <EOL> trailing = [ ] <EOL> if not s : <EOL> raise IRCBadMessage ( "<STR_LIT>" ) <EOL> if s [ <NUM_LIT:0> ] == '<STR_LIT::>' : <EOL> prefix , s = s [ <NUM_LIT:1> : ] . split ( '<STR_LIT:U+0020>' , <NUM_LIT:1> ) <EOL> if s . find ( '<STR_LIT>' ) != - <NUM_LIT:1> : <EOL> s , trailing = s . split ( '<STR_LIT>' , <NUM_LIT:1> ) <EOL> args = s . split ( ) <EOL> args . append ( trailing ) <EOL> else : <EOL> args = s . split ( ) <EOL> command = args . pop ( <NUM_LIT:0> ) <EOL> return prefix , command , args <EOL> def split ( str , length = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> return [ chunk <EOL> for line in str . split ( '<STR_LIT:\n>' ) <EOL> for chunk in textwrap . wrap ( line , length ) ] <EOL> def _intOrDefault ( value , default = None ) : <EOL> """<STR_LIT>""" <EOL> if value : <EOL> try : <EOL> return int ( value ) <EOL> except ( TypeError , ValueError ) : <EOL> pass <EOL> return default <EOL> class UnhandledCommand ( RuntimeError ) : <EOL> """<STR_LIT>""" <EOL> class _CommandDispatcherMixin ( object ) : <EOL> """<STR_LIT>""" <EOL> prefix = None <EOL> def dispatch ( self , commandName , * args ) : <EOL> """<STR_LIT>""" <EOL> def _getMethodName ( command ) : <EOL> return '<STR_LIT>' % ( self . prefix , command ) <EOL> def _getMethod ( name ) : <EOL> return getattr ( self , _getMethodName ( name ) , None ) <EOL> method = _getMethod ( commandName ) <EOL> if method is not None : <EOL> return method ( * args ) <EOL> method = _getMethod ( '<STR_LIT>' ) <EOL> if method is None : <EOL> raise UnhandledCommand ( "<STR_LIT>" % ( _getMethodName ( commandName ) , ) ) <EOL> return method ( commandName , * args ) <EOL> def parseModes ( modes , params , paramModes = ( '<STR_LIT>' , '<STR_LIT>' ) ) : <EOL> """<STR_LIT>""" <EOL> if len ( modes ) == <NUM_LIT:0> : <EOL> raise IRCBadModes ( '<STR_LIT>' ) <EOL> if modes [ <NUM_LIT:0> ] not in '<STR_LIT>' : <EOL> raise IRCBadModes ( '<STR_LIT>' % ( modes , ) ) <EOL> changes = ( [ ] , [ ] ) <EOL> direction = None <EOL> count = - <NUM_LIT:1> <EOL> for ch in modes : <EOL> if ch in '<STR_LIT>' : <EOL> if count == <NUM_LIT:0> : <EOL> raise IRCBadModes ( '<STR_LIT>' % ( modes , ) ) <EOL> direction = '<STR_LIT>' . index ( ch ) <EOL> count = <NUM_LIT:0> <EOL> else : <EOL> param = None <EOL> if ch in paramModes [ direction ] : <EOL> try : <EOL> param = params . pop ( <NUM_LIT:0> ) <EOL> except IndexError : <EOL> raise IRCBadModes ( '<STR_LIT>' % ( ch , ) ) <EOL> changes [ direction ] . append ( ( ch , param ) ) <EOL> count += <NUM_LIT:1> <EOL> if len ( params ) > <NUM_LIT:0> : <EOL> raise IRCBadModes ( '<STR_LIT>' % ( modes , params ) ) <EOL> if count == <NUM_LIT:0> : <EOL> raise IRCBadModes ( '<STR_LIT>' % ( modes , ) ) <EOL> return changes <EOL> class IRC ( protocol . Protocol ) : <EOL> """<STR_LIT>""" <EOL> buffer = "<STR_LIT>" <EOL> hostname = None <EOL> encoding = None <EOL> def connectionMade ( self ) : <EOL> self . channels = [ ] <EOL> if self . hostname is None : <EOL> self . hostname = socket . getfqdn ( ) <EOL> def sendLine ( self , line ) : <EOL> if self . encoding is not None : <EOL> if isinstance ( line , unicode ) : <EOL> line = line . encode ( self . encoding ) <EOL> self . transport . write ( "<STR_LIT>" % ( line , CR , LF ) ) <EOL> def sendMessage ( self , command , * parameter_list , ** prefix ) : <EOL> """<STR_LIT>""" <EOL> if not command : <EOL> raise ValueError , "<STR_LIT>" <EOL> if '<STR_LIT:U+0020>' in command or command [ <NUM_LIT:0> ] == '<STR_LIT::>' : <EOL> raise ValueError , "<STR_LIT>" "<STR_LIT>" % command <EOL> line = string . join ( [ command ] + list ( parameter_list ) ) <EOL> if prefix . has_key ( '<STR_LIT>' ) : <EOL> line = "<STR_LIT>" % ( prefix [ '<STR_LIT>' ] , line ) <EOL> self . sendLine ( line ) <EOL> if len ( parameter_list ) > <NUM_LIT:15> : <EOL> log . msg ( "<STR_LIT>" % <EOL> ( len ( parameter_list ) , line ) ) <EOL> def dataReceived ( self , data ) : <EOL> """<STR_LIT>""" <EOL> lines = ( self . buffer + data ) . split ( LF ) <EOL> self . buffer = lines . pop ( ) <EOL> for line in lines : <EOL> if len ( line ) <= <NUM_LIT:2> : <EOL> continue <EOL> if line [ - <NUM_LIT:1> ] == CR : <EOL> line = line [ : - <NUM_LIT:1> ] <EOL> prefix , command , params = parsemsg ( line ) <EOL> command = command . upper ( ) <EOL> self . handleCommand ( command , prefix , params ) <EOL> def handleCommand ( self , command , prefix , params ) : <EOL> """<STR_LIT>""" <EOL> method = getattr ( self , "<STR_LIT>" % command , None ) <EOL> try : <EOL> if method is not None : <EOL> method ( prefix , params ) <EOL> else : <EOL> self . irc_unknown ( prefix , command , params ) <EOL> except : <EOL> log . deferr ( ) <EOL> def irc_unknown ( self , prefix , command , params ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( command , prefix , params ) <EOL> def privmsg ( self , sender , recip , message ) : <EOL> """<STR_LIT>""" <EOL> self . sendLine ( "<STR_LIT>" % ( sender , recip , lowQuote ( message ) ) ) <EOL> def notice ( self , sender , recip , message ) : <EOL> """<STR_LIT>""" <EOL> self . sendLine ( "<STR_LIT>" % ( sender , recip , message ) ) <EOL> def action ( self , sender , recip , message ) : <EOL> """<STR_LIT>""" <EOL> self . sendLine ( "<STR_LIT>" % ( sender , recip , message ) ) <EOL> def topic ( self , user , channel , topic , author = None ) : <EOL> """<STR_LIT>""" <EOL> if author is None : <EOL> if topic is None : <EOL> self . sendLine ( '<STR_LIT>' % ( <EOL> self . hostname , RPL_NOTOPIC , user , channel , '<STR_LIT>' ) ) <EOL> else : <EOL> self . sendLine ( "<STR_LIT>" % ( <EOL> self . hostname , RPL_TOPIC , user , channel , lowQuote ( topic ) ) ) <EOL> else : <EOL> self . sendLine ( "<STR_LIT>" % ( author , channel , lowQuote ( topic ) ) ) <EOL> def topicAuthor ( self , user , channel , author , date ) : <EOL> """<STR_LIT>""" <EOL> self . sendLine ( '<STR_LIT>' % ( <EOL> self . hostname , <NUM_LIT> , user , channel , author , date ) ) <EOL> def names ( self , user , channel , names ) : <EOL> """<STR_LIT>""" <EOL> prefixLength = len ( channel ) + len ( user ) + <NUM_LIT:10> <EOL> namesLength = <NUM_LIT> - prefixLength <EOL> L = [ ] <EOL> count = <NUM_LIT:0> <EOL> for n in names : <EOL> if count + len ( n ) + <NUM_LIT:1> > namesLength : <EOL> self . sendLine ( "<STR_LIT>" % ( <EOL> self . hostname , RPL_NAMREPLY , user , channel , '<STR_LIT:U+0020>' . join ( L ) ) ) <EOL> L = [ n ] <EOL> count = len ( n ) <EOL> else : <EOL> L . append ( n ) <EOL> count += len ( n ) + <NUM_LIT:1> <EOL> if L : <EOL> self . sendLine ( "<STR_LIT>" % ( <EOL> self . hostname , RPL_NAMREPLY , user , channel , '<STR_LIT:U+0020>' . join ( L ) ) ) <EOL> self . sendLine ( "<STR_LIT>" % ( <EOL> self . hostname , RPL_ENDOFNAMES , user , channel ) ) <EOL> def who ( self , user , channel , memberInfo ) : <EOL> """<STR_LIT>""" <EOL> for info in memberInfo : <EOL> ( username , hostmask , server , nickname , flag , hops , realName ) = info <EOL> assert flag in ( "<STR_LIT:H>" , "<STR_LIT>" ) <EOL> self . sendLine ( "<STR_LIT>" % ( <EOL> self . hostname , RPL_WHOREPLY , user , channel , <EOL> username , hostmask , server , nickname , flag , hops , realName ) ) <EOL> self . sendLine ( "<STR_LIT>" % ( <EOL> self . hostname , RPL_ENDOFWHO , user , channel ) ) <EOL> def whois ( self , user , nick , username , hostname , realName , server , serverInfo , oper , idle , signOn , channels ) : <EOL> """<STR_LIT>""" <EOL> self . sendLine ( "<STR_LIT>" % ( <EOL> self . hostname , RPL_WHOISUSER , user , nick , username , hostname , realName ) ) <EOL> self . sendLine ( "<STR_LIT>" % ( <EOL> self . hostname , RPL_WHOISSERVER , user , nick , server , serverInfo ) ) <EOL> if oper : <EOL> self . sendLine ( "<STR_LIT>" % ( <EOL> self . hostname , RPL_WHOISOPERATOR , user , nick ) ) <EOL> self . sendLine ( "<STR_LIT>" % ( <EOL> self . hostname , RPL_WHOISIDLE , user , nick , idle , signOn ) ) <EOL> self . sendLine ( "<STR_LIT>" % ( <EOL> self . hostname , RPL_WHOISCHANNELS , user , nick , '<STR_LIT:U+0020>' . join ( channels ) ) ) <EOL> self . sendLine ( "<STR_LIT>" % ( <EOL> self . hostname , RPL_ENDOFWHOIS , user , nick ) ) <EOL> def join ( self , who , where ) : <EOL> """<STR_LIT>""" <EOL> self . sendLine ( "<STR_LIT>" % ( who , where ) ) <EOL> def part ( self , who , where , reason = None ) : <EOL> """<STR_LIT>""" <EOL> if reason : <EOL> self . sendLine ( "<STR_LIT>" % ( who , where , reason ) ) <EOL> else : <EOL> self . sendLine ( "<STR_LIT>" % ( who , where ) ) <EOL> def channelMode ( self , user , channel , mode , * args ) : <EOL> """<STR_LIT>""" <EOL> self . sendLine ( "<STR_LIT>" % ( <EOL> self . hostname , RPL_CHANNELMODEIS , user , channel , mode , '<STR_LIT:U+0020>' . join ( args ) ) ) <EOL> class ServerSupportedFeatures ( _CommandDispatcherMixin ) : <EOL> """<STR_LIT>""" <EOL> prefix = '<STR_LIT>' <EOL> def __init__ ( self ) : <EOL> self . _features = { <EOL> '<STR_LIT>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : tuple ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : <NUM_LIT:3> , <EOL> '<STR_LIT>' : <NUM_LIT:9> , <EOL> '<STR_LIT>' : self . _parsePrefixParam ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : self . _parseChanModesParam ( [ '<STR_LIT:b>' , '<STR_LIT>' , '<STR_LIT>' ] ) } <EOL> def _splitParamArgs ( cls , params , valueProcessor = None ) : <EOL> """<STR_LIT>""" <EOL> if valueProcessor is None : <EOL> valueProcessor = lambda x : x <EOL> def _parse ( ) : <EOL> for param in params : <EOL> if '<STR_LIT::>' not in param : <EOL> param += '<STR_LIT::>' <EOL> a , b = param . split ( '<STR_LIT::>' , <NUM_LIT:1> ) <EOL> yield a , valueProcessor ( b ) <EOL> return list ( _parse ( ) ) <EOL> _splitParamArgs = classmethod ( _splitParamArgs ) <EOL> def _unescapeParamValue ( cls , value ) : <EOL> """<STR_LIT>""" <EOL> def _unescape ( ) : <EOL> parts = value . split ( '<STR_LIT>' ) <EOL> yield parts . pop ( <NUM_LIT:0> ) <EOL> for s in parts : <EOL> octet , rest = s [ : <NUM_LIT:2> ] , s [ <NUM_LIT:2> : ] <EOL> try : <EOL> octet = int ( octet , <NUM_LIT:16> ) <EOL> except ValueError : <EOL> raise ValueError ( '<STR_LIT>' % ( octet , ) ) <EOL> yield chr ( octet ) + rest <EOL> if '<STR_LIT>' not in value : <EOL> return value <EOL> return '<STR_LIT>' . join ( _unescape ( ) ) <EOL> _unescapeParamValue = classmethod ( _unescapeParamValue ) <EOL> def _splitParam ( cls , param ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT:=>' not in param : <EOL> param += '<STR_LIT:=>' <EOL> key , value = param . split ( '<STR_LIT:=>' , <NUM_LIT:1> ) <EOL> return key , map ( cls . _unescapeParamValue , value . split ( '<STR_LIT:U+002C>' ) ) <EOL> _splitParam = classmethod ( _splitParam ) <EOL> def _parsePrefixParam ( cls , prefix ) : <EOL> """<STR_LIT>""" <EOL> if not prefix : <EOL> return None <EOL> if prefix [ <NUM_LIT:0> ] != '<STR_LIT:(>' and '<STR_LIT:)>' not in prefix : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> modes , symbols = prefix . split ( '<STR_LIT:)>' , <NUM_LIT:1> ) <EOL> symbols = zip ( symbols , xrange ( len ( symbols ) ) ) <EOL> modes = modes [ <NUM_LIT:1> : ] <EOL> return dict ( zip ( modes , symbols ) ) <EOL> _parsePrefixParam = classmethod ( _parsePrefixParam ) <EOL> def _parseChanModesParam ( self , params ) : <EOL> """<STR_LIT>""" <EOL> names = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> if len ( params ) > len ( names ) : <EOL> raise ValueError ( <EOL> '<STR_LIT>' % ( <EOL> len ( names ) , len ( params ) ) ) <EOL> items = map ( lambda key , value : ( key , value or '<STR_LIT>' ) , names , params ) <EOL> return dict ( items ) <EOL> _parseChanModesParam = classmethod ( _parseChanModesParam ) <EOL> def getFeature ( self , feature , default = None ) : <EOL> """<STR_LIT>""" <EOL> return self . _features . get ( feature , default ) <EOL> def hasFeature ( self , feature ) : <EOL> """<STR_LIT>""" <EOL> return self . getFeature ( feature ) is not None <EOL> def parse ( self , params ) : <EOL> """<STR_LIT>""" <EOL> for param in params : <EOL> key , value = self . _splitParam ( param ) <EOL> if key . startswith ( '<STR_LIT:->' ) : <EOL> self . _features . pop ( key [ <NUM_LIT:1> : ] , None ) <EOL> else : <EOL> self . _features [ key ] = self . dispatch ( key , value ) <EOL> def isupport_unknown ( self , command , params ) : <EOL> """<STR_LIT>""" <EOL> return tuple ( params ) <EOL> def isupport_CHANLIMIT ( self , params ) : <EOL> """<STR_LIT>""" <EOL> return self . _splitParamArgs ( params , _intOrDefault ) <EOL> def isupport_CHANMODES ( self , params ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return self . _parseChanModesParam ( params ) <EOL> except ValueError : <EOL> return self . getFeature ( '<STR_LIT>' ) <EOL> def isupport_CHANNELLEN ( self , params ) : <EOL> """<STR_LIT>""" <EOL> return _intOrDefault ( params [ <NUM_LIT:0> ] , self . getFeature ( '<STR_LIT>' ) ) <EOL> def isupport_CHANTYPES ( self , params ) : <EOL> """<STR_LIT>""" <EOL> return tuple ( params [ <NUM_LIT:0> ] ) <EOL> def isupport_EXCEPTS ( self , params ) : <EOL> """<STR_LIT>""" <EOL> return params [ <NUM_LIT:0> ] or '<STR_LIT:e>' <EOL> def isupport_IDCHAN ( self , params ) : <EOL> """<STR_LIT>""" <EOL> return self . _splitParamArgs ( params ) <EOL> def isupport_INVEX ( self , params ) : <EOL> """<STR_LIT>""" <EOL> return params [ <NUM_LIT:0> ] or '<STR_LIT:I>' <EOL> def isupport_KICKLEN ( self , params ) : <EOL> """<STR_LIT>""" <EOL> return _intOrDefault ( params [ <NUM_LIT:0> ] ) <EOL> def isupport_MAXLIST ( self , params ) : <EOL> """<STR_LIT>""" <EOL> return self . _splitParamArgs ( params , _intOrDefault ) <EOL> def isupport_MODES ( self , params ) : <EOL> """<STR_LIT>""" <EOL> return _intOrDefault ( params [ <NUM_LIT:0> ] ) <EOL> def isupport_NETWORK ( self , params ) : <EOL> """<STR_LIT>""" <EOL> return params [ <NUM_LIT:0> ] <EOL> def isupport_NICKLEN ( self , params ) : <EOL> """<STR_LIT>""" <EOL> return _intOrDefault ( params [ <NUM_LIT:0> ] , self . getFeature ( '<STR_LIT>' ) ) <EOL> def isupport_PREFIX ( self , params ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return self . _parsePrefixParam ( params [ <NUM_LIT:0> ] ) <EOL> except ValueError : <EOL> return self . getFeature ( '<STR_LIT>' ) <EOL> def isupport_SAFELIST ( self , params ) : <EOL> """<STR_LIT>""" <EOL> return True <EOL> def isupport_STATUSMSG ( self , params ) : <EOL> """<STR_LIT>""" <EOL> return params [ <NUM_LIT:0> ] <EOL> def isupport_TARGMAX ( self , params ) : <EOL> """<STR_LIT>""" <EOL> return dict ( self . _splitParamArgs ( params , _intOrDefault ) ) <EOL> def isupport_TOPICLEN ( self , params ) : <EOL> """<STR_LIT>""" <EOL> return _intOrDefault ( params [ <NUM_LIT:0> ] ) <EOL> class IRCClient ( basic . LineReceiver ) : <EOL> """<STR_LIT>""" <EOL> motd = None <EOL> nickname = '<STR_LIT>' <EOL> password = None <EOL> realname = None <EOL> username = None <EOL> userinfo = None <EOL> fingerReply = None <EOL> versionName = None <EOL> versionNum = None <EOL> versionEnv = None <EOL> sourceURL = "<STR_LIT>" <EOL> dcc_destdir = '<STR_LIT:.>' <EOL> dcc_sessions = None <EOL> performLogin = <NUM_LIT:1> <EOL> lineRate = None <EOL> _queue = None <EOL> _queueEmptying = None <EOL> delimiter = '<STR_LIT:\n>' <EOL> __pychecker__ = '<STR_LIT>' <EOL> _registered = False <EOL> _attemptedNick = '<STR_LIT>' <EOL> erroneousNickFallback = '<STR_LIT>' <EOL> def _reallySendLine ( self , line ) : <EOL> return basic . LineReceiver . sendLine ( self , lowQuote ( line ) + '<STR_LIT:\r>' ) <EOL> def sendLine ( self , line ) : <EOL> if self . lineRate is None : <EOL> self . _reallySendLine ( line ) <EOL> else : <EOL> self . _queue . append ( line ) <EOL> if not self . _queueEmptying : <EOL> self . _sendLine ( ) <EOL> def _sendLine ( self ) : <EOL> if self . _queue : <EOL> self . _reallySendLine ( self . _queue . pop ( <NUM_LIT:0> ) ) <EOL> self . _queueEmptying = reactor . callLater ( self . lineRate , <EOL> self . _sendLine ) <EOL> else : <EOL> self . _queueEmptying = None <EOL> def created ( self , when ) : <EOL> """<STR_LIT>""" <EOL> def yourHost ( self , info ) : <EOL> """<STR_LIT>""" <EOL> def myInfo ( self , servername , version , umodes , cmodes ) : <EOL> """<STR_LIT>""" <EOL> def luserClient ( self , info ) : <EOL> """<STR_LIT>""" <EOL> def bounce ( self , info ) : <EOL> """<STR_LIT>""" <EOL> def isupport ( self , options ) : <EOL> """<STR_LIT>""" <EOL> def luserChannels ( self , channels ) : <EOL> """<STR_LIT>""" <EOL> def luserOp ( self , ops ) : <EOL> """<STR_LIT>""" <EOL> def luserMe ( self , info ) : <EOL> """<STR_LIT>""" <EOL> def privmsg ( self , user , channel , message ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def joined ( self , channel ) : <EOL> """<STR_LIT>""" <EOL> def left ( self , channel ) : <EOL> """<STR_LIT>""" <EOL> def noticed ( self , user , channel , message ) : <EOL> """<STR_LIT>""" <EOL> def modeChanged ( self , user , channel , set , modes , args ) : <EOL> """<STR_LIT>""" <EOL> def pong ( self , user , secs ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def signedOn ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def kickedFrom ( self , channel , kicker , message ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def nickChanged ( self , nick ) : <EOL> """<STR_LIT>""" <EOL> self . nickname = nick <EOL> def userJoined ( self , user , channel ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def userLeft ( self , user , channel ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def userQuit ( self , user , quitMessage ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def userKicked ( self , kickee , channel , kicker , message ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def action ( self , user , channel , data ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def topicUpdated ( self , user , channel , newTopic ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def userRenamed ( self , oldname , newname ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def receivedMOTD ( self , motd ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def join ( self , channel , key = None ) : <EOL> """<STR_LIT>""" <EOL> if channel [ <NUM_LIT:0> ] not in CHANNEL_PREFIXES : <EOL> channel = '<STR_LIT:#>' + channel <EOL> if key : <EOL> self . sendLine ( "<STR_LIT>" % ( channel , key ) ) <EOL> else : <EOL> self . sendLine ( "<STR_LIT>" % ( channel , ) ) <EOL> def leave ( self , channel , reason = None ) : <EOL> """<STR_LIT>""" <EOL> if channel [ <NUM_LIT:0> ] not in CHANNEL_PREFIXES : <EOL> channel = '<STR_LIT:#>' + channel <EOL> if reason : <EOL> self . sendLine ( "<STR_LIT>" % ( channel , reason ) ) <EOL> else : <EOL> self . sendLine ( "<STR_LIT>" % ( channel , ) ) <EOL> def kick ( self , channel , user , reason = None ) : <EOL> """<STR_LIT>""" <EOL> if channel [ <NUM_LIT:0> ] not in CHANNEL_PREFIXES : <EOL> channel = '<STR_LIT:#>' + channel <EOL> if reason : <EOL> self . sendLine ( "<STR_LIT>" % ( channel , user , reason ) ) <EOL> else : <EOL> self . sendLine ( "<STR_LIT>" % ( channel , user ) ) <EOL> part = leave <EOL> def topic ( self , channel , topic = None ) : <EOL> """<STR_LIT>""" <EOL> if channel [ <NUM_LIT:0> ] not in CHANNEL_PREFIXES : <EOL> channel = '<STR_LIT:#>' + channel <EOL> if topic != None : <EOL> self . sendLine ( "<STR_LIT>" % ( channel , topic ) ) <EOL> else : <EOL> self . sendLine ( "<STR_LIT>" % ( channel , ) ) <EOL> def mode ( self , chan , set , modes , limit = None , user = None , mask = None ) : <EOL> """<STR_LIT>""" <EOL> if set : <EOL> line = '<STR_LIT>' % ( chan , modes ) <EOL> else : <EOL> line = '<STR_LIT>' % ( chan , modes ) <EOL> if limit is not None : <EOL> line = '<STR_LIT>' % ( line , limit ) <EOL> elif user is not None : <EOL> line = '<STR_LIT>' % ( line , user ) <EOL> elif mask is not None : <EOL> line = '<STR_LIT>' % ( line , mask ) <EOL> self . sendLine ( line ) <EOL> def say ( self , channel , message , length = None ) : <EOL> """<STR_LIT>""" <EOL> if channel [ <NUM_LIT:0> ] not in CHANNEL_PREFIXES : <EOL> channel = '<STR_LIT:#>' + channel <EOL> self . msg ( channel , message , length ) <EOL> def msg ( self , user , message , length = MAX_COMMAND_LENGTH ) : <EOL> """<STR_LIT>""" <EOL> fmt = "<STR_LIT>" % ( user , ) <EOL> minimumLength = len ( fmt ) <EOL> if length <= minimumLength : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" % ( minimumLength , user ) ) <EOL> for line in split ( message , length - minimumLength ) : <EOL> self . sendLine ( fmt % ( line , ) ) <EOL> def notice ( self , user , message ) : <EOL> """<STR_LIT>""" <EOL> self . sendLine ( "<STR_LIT>" % ( user , message ) ) <EOL> def away ( self , message = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> self . sendLine ( "<STR_LIT>" % message ) <EOL> def back ( self ) : <EOL> """<STR_LIT>""" <EOL> self . away ( ) <EOL> def whois ( self , nickname , server = None ) : <EOL> """<STR_LIT>""" <EOL> if server is None : <EOL> self . sendLine ( '<STR_LIT>' + nickname ) <EOL> else : <EOL> self . sendLine ( '<STR_LIT>' % ( server , nickname ) ) <EOL> def register ( self , nickname , hostname = '<STR_LIT:foo>' , servername = '<STR_LIT:bar>' ) : <EOL> """<STR_LIT>""" <EOL> if self . password is not None : <EOL> self . sendLine ( "<STR_LIT>" % self . password ) <EOL> self . setNick ( nickname ) <EOL> if self . username is None : <EOL> self . username = nickname <EOL> self . sendLine ( "<STR_LIT>" % ( self . username , hostname , servername , self . realname ) ) <EOL> def setNick ( self , nickname ) : <EOL> """<STR_LIT>""" <EOL> self . _attemptedNick = nickname <EOL> self . sendLine ( "<STR_LIT>" % nickname ) <EOL> def quit ( self , message = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> self . sendLine ( "<STR_LIT>" % message ) <EOL> def describe ( self , channel , action ) : <EOL> """<STR_LIT>""" <EOL> self . ctcpMakeQuery ( channel , [ ( '<STR_LIT>' , action ) ] ) <EOL> def me ( self , channel , action ) : <EOL> """<STR_LIT>""" <EOL> warnings . warn ( "<STR_LIT>" , <EOL> DeprecationWarning , stacklevel = <NUM_LIT:2> ) <EOL> if channel [ <NUM_LIT:0> ] not in CHANNEL_PREFIXES : <EOL> channel = '<STR_LIT:#>' + channel <EOL> self . describe ( channel , action ) <EOL> _pings = None <EOL> _MAX_PINGRING = <NUM_LIT:12> <EOL> def ping ( self , user , text = None ) : <EOL> """<STR_LIT>""" <EOL> if self . _pings is None : <EOL> self . _pings = { } <EOL> if text is None : <EOL> chars = string . letters + string . digits + string . punctuation <EOL> key = '<STR_LIT>' . join ( [ random . choice ( chars ) for i in range ( <NUM_LIT:12> ) ] ) <EOL> else : <EOL> key = str ( text ) <EOL> self . _pings [ ( user , key ) ] = time . time ( ) <EOL> self . ctcpMakeQuery ( user , [ ( '<STR_LIT>' , key ) ] ) <EOL> if len ( self . _pings ) > self . _MAX_PINGRING : <EOL> byValue = [ ( v , k ) for ( k , v ) in self . _pings . items ( ) ] <EOL> byValue . sort ( ) <EOL> excess = self . _MAX_PINGRING - len ( self . _pings ) <EOL> for i in xrange ( excess ) : <EOL> del self . _pings [ byValue [ i ] [ <NUM_LIT:1> ] ] <EOL> def dccSend ( self , user , file ) : <EOL> if type ( file ) == types . StringType : <EOL> file = open ( file , '<STR_LIT:r>' ) <EOL> size = fileSize ( file ) <EOL> name = getattr ( file , "<STR_LIT:name>" , "<STR_LIT>" % ( id ( file ) , ) ) <EOL> factory = DccSendFactory ( file ) <EOL> port = reactor . listenTCP ( <NUM_LIT:0> , factory , <NUM_LIT:1> ) <EOL> raise NotImplementedError , ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> my_address = struct . pack ( "<STR_LIT>" , my_address ) <EOL> args = [ '<STR_LIT>' , name , my_address , str ( port ) ] <EOL> if not ( size is None ) : <EOL> args . append ( size ) <EOL> args = string . join ( args , '<STR_LIT:U+0020>' ) <EOL> self . ctcpMakeQuery ( user , [ ( '<STR_LIT>' , args ) ] ) <EOL> def dccResume ( self , user , fileName , port , resumePos ) : <EOL> """<STR_LIT>""" <EOL> self . ctcpMakeQuery ( user , [ <EOL> ( '<STR_LIT>' , [ '<STR_LIT>' , fileName , port , resumePos ] ) ] ) <EOL> def dccAcceptResume ( self , user , fileName , port , resumePos ) : <EOL> """<STR_LIT>""" <EOL> self . ctcpMakeQuery ( user , [ <EOL> ( '<STR_LIT>' , [ '<STR_LIT>' , fileName , port , resumePos ] ) ] ) <EOL> def irc_ERR_NICKNAMEINUSE ( self , prefix , params ) : <EOL> """<STR_LIT>""" <EOL> self . _attemptedNick = self . alterCollidedNick ( self . _attemptedNick ) <EOL> self . setNick ( self . _attemptedNick ) <EOL> def alterCollidedNick ( self , nickname ) : <EOL> """<STR_LIT>""" <EOL> return nickname + '<STR_LIT:_>' <EOL> def irc_ERR_ERRONEUSNICKNAME ( self , prefix , params ) : <EOL> """<STR_LIT>""" <EOL> if not self . _registered : <EOL> self . setNick ( self . erroneousNickFallback ) <EOL> def irc_ERR_PASSWDMISMATCH ( self , prefix , params ) : <EOL> """<STR_LIT>""" <EOL> raise IRCPasswordMismatch ( "<STR_LIT>" ) <EOL> def irc_RPL_WELCOME ( self , prefix , params ) : <EOL> """<STR_LIT>""" <EOL> self . _registered = True <EOL> self . nickname = self . _attemptedNick <EOL> self . signedOn ( ) <EOL> def irc_JOIN ( self , prefix , params ) : <EOL> """<STR_LIT>""" <EOL> nick = string . split ( prefix , '<STR_LIT:!>' ) [ <NUM_LIT:0> ] <EOL> channel = params [ - <NUM_LIT:1> ] <EOL> if nick == self . nickname : <EOL> self . joined ( channel ) <EOL> else : <EOL> self . userJoined ( nick , channel ) <EOL> def irc_PART ( self , prefix , params ) : <EOL> """<STR_LIT>""" <EOL> nick = string . split ( prefix , '<STR_LIT:!>' ) [ <NUM_LIT:0> ] <EOL> channel = params [ <NUM_LIT:0> ] <EOL> if nick == self . nickname : <EOL> self . left ( channel ) <EOL> else : <EOL> self . userLeft ( nick , channel ) <EOL> def irc_QUIT ( self , prefix , params ) : <EOL> """<STR_LIT>""" <EOL> nick = string . split ( prefix , '<STR_LIT:!>' ) [ <NUM_LIT:0> ] <EOL> self . userQuit ( nick , params [ <NUM_LIT:0> ] ) <EOL> def irc_MODE ( self , user , params ) : <EOL> """<STR_LIT>""" <EOL> channel , modes , args = params [ <NUM_LIT:0> ] , params [ <NUM_LIT:1> ] , params [ <NUM_LIT:2> : ] <EOL> if modes [ <NUM_LIT:0> ] not in '<STR_LIT>' : <EOL> modes = '<STR_LIT:+>' + modes <EOL> if channel == self . nickname : <EOL> paramModes = self . getUserModeParams ( ) <EOL> else : <EOL> paramModes = self . getChannelModeParams ( ) <EOL> try : <EOL> added , removed = parseModes ( modes , args , paramModes ) <EOL> except IRCBadModes : <EOL> log . err ( None , '<STR_LIT>' <EOL> '<STR_LIT>' % ( '<STR_LIT:U+0020>' . join ( params ) , ) ) <EOL> else : <EOL> if added : <EOL> modes , params = zip ( * added ) <EOL> self . modeChanged ( user , channel , True , '<STR_LIT>' . join ( modes ) , params ) <EOL> if removed : <EOL> modes , params = zip ( * removed ) <EOL> self . modeChanged ( user , channel , False , '<STR_LIT>' . join ( modes ) , params ) <EOL> def irc_PING ( self , prefix , params ) : <EOL> """<STR_LIT>""" <EOL> self . sendLine ( "<STR_LIT>" % params [ - <NUM_LIT:1> ] ) <EOL> def irc_PRIVMSG ( self , prefix , params ) : <EOL> """<STR_LIT>""" <EOL> user = prefix <EOL> channel = params [ <NUM_LIT:0> ] <EOL> message = params [ - <NUM_LIT:1> ] <EOL> if not message : return <EOL> if message [ <NUM_LIT:0> ] == X_DELIM : <EOL> m = ctcpExtract ( message ) <EOL> if m [ '<STR_LIT>' ] : <EOL> self . ctcpQuery ( user , channel , m [ '<STR_LIT>' ] ) <EOL> if not m [ '<STR_LIT>' ] : <EOL> return <EOL> message = string . join ( m [ '<STR_LIT>' ] , '<STR_LIT:U+0020>' ) <EOL> self . privmsg ( user , channel , message ) <EOL> def irc_NOTICE ( self , prefix , params ) : <EOL> """<STR_LIT>""" <EOL> user = prefix <EOL> channel = params [ <NUM_LIT:0> ] <EOL> message = params [ - <NUM_LIT:1> ] <EOL> if message [ <NUM_LIT:0> ] == X_DELIM : <EOL> m = ctcpExtract ( message ) <EOL> if m [ '<STR_LIT>' ] : <EOL> self . ctcpReply ( user , channel , m [ '<STR_LIT>' ] ) <EOL> if not m [ '<STR_LIT>' ] : <EOL> return <EOL> message = string . join ( m [ '<STR_LIT>' ] , '<STR_LIT:U+0020>' ) <EOL> self . noticed ( user , channel , message ) <EOL> def irc_NICK ( self , prefix , params ) : <EOL> """<STR_LIT>""" <EOL> nick = string . split ( prefix , '<STR_LIT:!>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> if nick == self . nickname : <EOL> self . nickChanged ( params [ <NUM_LIT:0> ] ) <EOL> else : <EOL> self . userRenamed ( nick , params [ <NUM_LIT:0> ] ) <EOL> def irc_KICK ( self , prefix , params ) : <EOL> """<STR_LIT>""" <EOL> kicker = string . split ( prefix , '<STR_LIT:!>' ) [ <NUM_LIT:0> ] <EOL> channel = params [ <NUM_LIT:0> ] <EOL> kicked = params [ <NUM_LIT:1> ] <EOL> message = params [ - <NUM_LIT:1> ] <EOL> if string . lower ( kicked ) == string . lower ( self . nickname ) : <EOL> self . kickedFrom ( channel , kicker , message ) <EOL> else : <EOL> self . userKicked ( kicked , channel , kicker , message ) <EOL> def irc_TOPIC ( self , prefix , params ) : <EOL> """<STR_LIT>""" <EOL> user = string . split ( prefix , '<STR_LIT:!>' ) [ <NUM_LIT:0> ] <EOL> channel = params [ <NUM_LIT:0> ] <EOL> newtopic = params [ <NUM_LIT:1> ] <EOL> self . topicUpdated ( user , channel , newtopic ) <EOL> def irc_RPL_TOPIC ( self , prefix , params ) : <EOL> """<STR_LIT>""" <EOL> user = string . split ( prefix , '<STR_LIT:!>' ) [ <NUM_LIT:0> ] <EOL> channel = params [ <NUM_LIT:1> ] <EOL> newtopic = params [ <NUM_LIT:2> ] <EOL> self . topicUpdated ( user , channel , newtopic ) <EOL> def irc_RPL_NOTOPIC ( self , prefix , params ) : <EOL> user = string . split ( prefix , '<STR_LIT:!>' ) [ <NUM_LIT:0> ] <EOL> channel = params [ <NUM_LIT:1> ] <EOL> newtopic = "<STR_LIT>" <EOL> self . topicUpdated ( user , channel , newtopic ) <EOL> def irc_RPL_MOTDSTART ( self , prefix , params ) : <EOL> if params [ - <NUM_LIT:1> ] . startswith ( "<STR_LIT>" ) : <EOL> params [ - <NUM_LIT:1> ] = params [ - <NUM_LIT:1> ] [ <NUM_LIT:2> : ] <EOL> self . motd = [ params [ - <NUM_LIT:1> ] ] <EOL> def irc_RPL_MOTD ( self , prefix , params ) : <EOL> if params [ - <NUM_LIT:1> ] . startswith ( "<STR_LIT>" ) : <EOL> params [ - <NUM_LIT:1> ] = params [ - <NUM_LIT:1> ] [ <NUM_LIT:2> : ] <EOL> if self . motd is None : <EOL> self . motd = [ ] <EOL> self . motd . append ( params [ - <NUM_LIT:1> ] ) <EOL> def irc_RPL_ENDOFMOTD ( self , prefix , params ) : <EOL> """<STR_LIT>""" <EOL> motd = self . motd <EOL> self . motd = None <EOL> self . receivedMOTD ( motd ) <EOL> def irc_RPL_CREATED ( self , prefix , params ) : <EOL> self . created ( params [ <NUM_LIT:1> ] ) <EOL> def irc_RPL_YOURHOST ( self , prefix , params ) : <EOL> self . yourHost ( params [ <NUM_LIT:1> ] ) <EOL> def irc_RPL_MYINFO ( self , prefix , params ) : <EOL> info = params [ <NUM_LIT:1> ] . split ( None , <NUM_LIT:3> ) <EOL> while len ( info ) < <NUM_LIT:4> : <EOL> info . append ( None ) <EOL> self . myInfo ( * info ) <EOL> def irc_RPL_BOUNCE ( self , prefix , params ) : <EOL> self . bounce ( params [ <NUM_LIT:1> ] ) <EOL> def irc_RPL_ISUPPORT ( self , prefix , params ) : <EOL> args = params [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> self . supported . parse ( args ) <EOL> self . isupport ( args ) <EOL> def irc_RPL_LUSERCLIENT ( self , prefix , params ) : <EOL> self . luserClient ( params [ <NUM_LIT:1> ] ) <EOL> def irc_RPL_LUSEROP ( self , prefix , params ) : <EOL> try : <EOL> self . luserOp ( int ( params [ <NUM_LIT:1> ] ) ) <EOL> except ValueError : <EOL> pass <EOL> def irc_RPL_LUSERCHANNELS ( self , prefix , params ) : <EOL> try : <EOL> self . luserChannels ( int ( params [ <NUM_LIT:1> ] ) ) <EOL> except ValueError : <EOL> pass <EOL> def irc_RPL_LUSERME ( self , prefix , params ) : <EOL> self . luserMe ( params [ <NUM_LIT:1> ] ) <EOL> def irc_unknown ( self , prefix , command , params ) : <EOL> pass <EOL> def ctcpQuery ( self , user , channel , messages ) : <EOL> """<STR_LIT>""" <EOL> for m in messages : <EOL> method = getattr ( self , "<STR_LIT>" % m [ <NUM_LIT:0> ] , None ) <EOL> if method : <EOL> method ( user , channel , m [ <NUM_LIT:1> ] ) <EOL> else : <EOL> self . ctcpUnknownQuery ( user , channel , m [ <NUM_LIT:0> ] , m [ <NUM_LIT:1> ] ) <EOL> def ctcpQuery_ACTION ( self , user , channel , data ) : <EOL> self . action ( user , channel , data ) <EOL> def ctcpQuery_PING ( self , user , channel , data ) : <EOL> nick = string . split ( user , "<STR_LIT:!>" ) [ <NUM_LIT:0> ] <EOL> self . ctcpMakeReply ( nick , [ ( "<STR_LIT>" , data ) ] ) <EOL> def ctcpQuery_FINGER ( self , user , channel , data ) : <EOL> if data is not None : <EOL> self . quirkyMessage ( "<STR_LIT>" <EOL> % ( user , data ) ) <EOL> if not self . fingerReply : <EOL> return <EOL> if callable ( self . fingerReply ) : <EOL> reply = self . fingerReply ( ) <EOL> else : <EOL> reply = str ( self . fingerReply ) <EOL> nick = string . split ( user , "<STR_LIT:!>" ) [ <NUM_LIT:0> ] <EOL> self . ctcpMakeReply ( nick , [ ( '<STR_LIT>' , reply ) ] ) <EOL> def ctcpQuery_VERSION ( self , user , channel , data ) : <EOL> if data is not None : <EOL> self . quirkyMessage ( "<STR_LIT>" <EOL> % ( user , data ) ) <EOL> if self . versionName : <EOL> nick = string . split ( user , "<STR_LIT:!>" ) [ <NUM_LIT:0> ] <EOL> self . ctcpMakeReply ( nick , [ ( '<STR_LIT>' , '<STR_LIT>' % <EOL> ( self . versionName , <EOL> self . versionNum or '<STR_LIT>' , <EOL> self . versionEnv or '<STR_LIT>' ) ) ] ) <EOL> def ctcpQuery_SOURCE ( self , user , channel , data ) : <EOL> if data is not None : <EOL> self . quirkyMessage ( "<STR_LIT>" <EOL> % ( user , data ) ) <EOL> if self . sourceURL : <EOL> nick = string . split ( user , "<STR_LIT:!>" ) [ <NUM_LIT:0> ] <EOL> self . ctcpMakeReply ( nick , [ ( '<STR_LIT>' , self . sourceURL ) , <EOL> ( '<STR_LIT>' , None ) ] ) <EOL> def ctcpQuery_USERINFO ( self , user , channel , data ) : <EOL> if data is not None : <EOL> self . quirkyMessage ( "<STR_LIT>" <EOL> % ( user , data ) ) <EOL> if self . userinfo : <EOL> nick = string . split ( user , "<STR_LIT:!>" ) [ <NUM_LIT:0> ] <EOL> self . ctcpMakeReply ( nick , [ ( '<STR_LIT>' , self . userinfo ) ] ) <EOL> def ctcpQuery_CLIENTINFO ( self , user , channel , data ) : <EOL> """<STR_LIT>""" <EOL> nick = string . split ( user , "<STR_LIT:!>" ) [ <NUM_LIT:0> ] <EOL> if not data : <EOL> names = reflect . prefixedMethodNames ( self . __class__ , <EOL> '<STR_LIT>' ) <EOL> self . ctcpMakeReply ( nick , [ ( '<STR_LIT>' , <EOL> string . join ( names , '<STR_LIT:U+0020>' ) ) ] ) <EOL> else : <EOL> args = string . split ( data ) <EOL> method = getattr ( self , '<STR_LIT>' % ( args [ <NUM_LIT:0> ] , ) , None ) <EOL> if not method : <EOL> self . ctcpMakeReply ( nick , [ ( '<STR_LIT>' , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> % ( data , args [ <NUM_LIT:0> ] ) ) ] ) <EOL> return <EOL> doc = getattr ( method , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . ctcpMakeReply ( nick , [ ( '<STR_LIT>' , doc ) ] ) <EOL> def ctcpQuery_ERRMSG ( self , user , channel , data ) : <EOL> nick = string . split ( user , "<STR_LIT:!>" ) [ <NUM_LIT:0> ] <EOL> self . ctcpMakeReply ( nick , [ ( '<STR_LIT>' , <EOL> "<STR_LIT>" % data ) ] ) <EOL> def ctcpQuery_TIME ( self , user , channel , data ) : <EOL> if data is not None : <EOL> self . quirkyMessage ( "<STR_LIT>" <EOL> % ( user , data ) ) <EOL> nick = string . split ( user , "<STR_LIT:!>" ) [ <NUM_LIT:0> ] <EOL> self . ctcpMakeReply ( nick , <EOL> [ ( '<STR_LIT>' , '<STR_LIT>' % <EOL> time . asctime ( time . localtime ( time . time ( ) ) ) ) ] ) <EOL> def ctcpQuery_DCC ( self , user , channel , data ) : <EOL> """<STR_LIT>""" <EOL> if not data : return <EOL> dcctype = data . split ( None , <NUM_LIT:1> ) [ <NUM_LIT:0> ] . upper ( ) <EOL> handler = getattr ( self , "<STR_LIT>" + dcctype , None ) <EOL> if handler : <EOL> if self . dcc_sessions is None : <EOL> self . dcc_sessions = [ ] <EOL> data = data [ len ( dcctype ) + <NUM_LIT:1> : ] <EOL> handler ( user , channel , data ) <EOL> else : <EOL> nick = string . split ( user , "<STR_LIT:!>" ) [ <NUM_LIT:0> ] <EOL> self . ctcpMakeReply ( nick , [ ( '<STR_LIT>' , <EOL> "<STR_LIT>" <EOL> % ( data , dcctype ) ) ] ) <EOL> self . quirkyMessage ( "<STR_LIT>" <EOL> % ( user , dcctype ) ) <EOL> def dcc_SEND ( self , user , channel , data ) : <EOL> data = text . splitQuoted ( data ) <EOL> if len ( data ) < <NUM_LIT:3> : <EOL> raise IRCBadMessage , "<STR_LIT>" % ( data , ) <EOL> ( filename , address , port ) = data [ : <NUM_LIT:3> ] <EOL> address = dccParseAddress ( address ) <EOL> try : <EOL> port = int ( port ) <EOL> except ValueError : <EOL> raise IRCBadMessage , "<STR_LIT>" % ( port , ) <EOL> size = - <NUM_LIT:1> <EOL> if len ( data ) >= <NUM_LIT:4> : <EOL> try : <EOL> size = int ( data [ <NUM_LIT:3> ] ) <EOL> except ValueError : <EOL> pass <EOL> self . dccDoSend ( user , address , port , filename , size , data ) <EOL> def dcc_ACCEPT ( self , user , channel , data ) : <EOL> data = text . splitQuoted ( data ) <EOL> if len ( data ) < <NUM_LIT:3> : <EOL> raise IRCBadMessage , "<STR_LIT>" % ( data , ) <EOL> ( filename , port , resumePos ) = data [ : <NUM_LIT:3> ] <EOL> try : <EOL> port = int ( port ) <EOL> resumePos = int ( resumePos ) <EOL> except ValueError : <EOL> return <EOL> self . dccDoAcceptResume ( user , filename , port , resumePos ) <EOL> def dcc_RESUME ( self , user , channel , data ) : <EOL> data = text . splitQuoted ( data ) <EOL> if len ( data ) < <NUM_LIT:3> : <EOL> raise IRCBadMessage , "<STR_LIT>" % ( data , ) <EOL> ( filename , port , resumePos ) = data [ : <NUM_LIT:3> ] <EOL> try : <EOL> port = int ( port ) <EOL> resumePos = int ( resumePos ) <EOL> except ValueError : <EOL> return <EOL> self . dccDoResume ( user , filename , port , resumePos ) <EOL> def dcc_CHAT ( self , user , channel , data ) : <EOL> data = text . splitQuoted ( data ) <EOL> if len ( data ) < <NUM_LIT:3> : <EOL> raise IRCBadMessage , "<STR_LIT>" % ( data , ) <EOL> ( filename , address , port ) = data [ : <NUM_LIT:3> ] <EOL> address = dccParseAddress ( address ) <EOL> try : <EOL> port = int ( port ) <EOL> except ValueError : <EOL> raise IRCBadMessage , "<STR_LIT>" % ( port , ) <EOL> self . dccDoChat ( user , channel , address , port , data ) <EOL> def dccDoSend ( self , user , address , port , fileName , size , data ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def dccDoResume ( self , user , file , port , resumePos ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def dccDoAcceptResume ( self , user , file , port , resumePos ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def dccDoChat ( self , user , channel , address , port , data ) : <EOL> pass <EOL> def ctcpUnknownQuery ( self , user , channel , tag , data ) : <EOL> nick = string . split ( user , "<STR_LIT:!>" ) [ <NUM_LIT:0> ] <EOL> self . ctcpMakeReply ( nick , [ ( '<STR_LIT>' , <EOL> "<STR_LIT>" <EOL> % ( tag , data , tag ) ) ] ) <EOL> log . msg ( "<STR_LIT>" <EOL> % ( user , tag , data ) ) <EOL> def ctcpMakeReply ( self , user , messages ) : <EOL> """<STR_LIT>""" <EOL> self . notice ( user , ctcpStringify ( messages ) ) <EOL> def ctcpMakeQuery ( self , user , messages ) : <EOL> """<STR_LIT>""" <EOL> self . msg ( user , ctcpStringify ( messages ) ) <EOL> def ctcpReply ( self , user , channel , messages ) : <EOL> """<STR_LIT>""" <EOL> for m in messages : <EOL> method = getattr ( self , "<STR_LIT>" % m [ <NUM_LIT:0> ] , None ) <EOL> if method : <EOL> method ( user , channel , m [ <NUM_LIT:1> ] ) <EOL> else : <EOL> self . ctcpUnknownReply ( user , channel , m [ <NUM_LIT:0> ] , m [ <NUM_LIT:1> ] ) <EOL> def ctcpReply_PING ( self , user , channel , data ) : <EOL> nick = user . split ( '<STR_LIT:!>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> if ( not self . _pings ) or ( not self . _pings . has_key ( ( nick , data ) ) ) : <EOL> raise IRCBadMessage , "<STR_LIT>" % ( user , data ) <EOL> t0 = self . _pings [ ( nick , data ) ] <EOL> self . pong ( user , time . time ( ) - t0 ) <EOL> def ctcpUnknownReply ( self , user , channel , tag , data ) : <EOL> """<STR_LIT>""" <EOL> log . msg ( "<STR_LIT>" <EOL> % ( user , tag , data ) ) <EOL> def badMessage ( self , line , excType , excValue , tb ) : <EOL> """<STR_LIT>""" <EOL> log . msg ( line ) <EOL> log . msg ( string . join ( traceback . format_exception ( excType , <EOL> excValue , <EOL> tb ) , '<STR_LIT>' ) ) <EOL> def quirkyMessage ( self , s ) : <EOL> """<STR_LIT>""" <EOL> log . msg ( s + '<STR_LIT:\n>' ) <EOL> def connectionMade ( self ) : <EOL> self . supported = ServerSupportedFeatures ( ) <EOL> self . _queue = [ ] <EOL> if self . performLogin : <EOL> self . register ( self . nickname ) <EOL> def dataReceived ( self , data ) : <EOL> basic . LineReceiver . dataReceived ( self , data . replace ( '<STR_LIT:\r>' , '<STR_LIT>' ) ) <EOL> def lineReceived ( self , line ) : <EOL> line = lowDequote ( line ) <EOL> try : <EOL> prefix , command , params = parsemsg ( line ) <EOL> if numeric_to_symbolic . has_key ( command ) : <EOL> command = numeric_to_symbolic [ command ] <EOL> self . handleCommand ( command , prefix , params ) <EOL> except IRCBadMessage : <EOL> self . badMessage ( line , * sys . exc_info ( ) ) <EOL> def getUserModeParams ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def getChannelModeParams ( self ) : <EOL> """<STR_LIT>""" <EOL> params = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> prefixes = self . supported . getFeature ( '<STR_LIT>' , { } ) <EOL> params [ <NUM_LIT:0> ] = params [ <NUM_LIT:1> ] = '<STR_LIT>' . join ( prefixes . iterkeys ( ) ) <EOL> chanmodes = self . supported . getFeature ( '<STR_LIT>' ) <EOL> if chanmodes is not None : <EOL> params [ <NUM_LIT:0> ] += chanmodes . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> params [ <NUM_LIT:0> ] += chanmodes . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> params [ <NUM_LIT:1> ] = params [ <NUM_LIT:0> ] <EOL> params [ <NUM_LIT:0> ] += chanmodes . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> return params <EOL> def handleCommand ( self , command , prefix , params ) : <EOL> """<STR_LIT>""" <EOL> method = getattr ( self , "<STR_LIT>" % command , None ) <EOL> try : <EOL> if method is not None : <EOL> method ( prefix , params ) <EOL> else : <EOL> self . irc_unknown ( prefix , command , params ) <EOL> except : <EOL> log . deferr ( ) <EOL> def __getstate__ ( self ) : <EOL> dct = self . __dict__ . copy ( ) <EOL> dct [ '<STR_LIT>' ] = None <EOL> dct [ '<STR_LIT>' ] = None <EOL> return dct <EOL> def dccParseAddress ( address ) : <EOL> if '<STR_LIT:.>' in address : <EOL> pass <EOL> else : <EOL> try : <EOL> address = long ( address ) <EOL> except ValueError : <EOL> raise IRCBadMessage , "<STR_LIT>" % ( address , ) <EOL> else : <EOL> address = ( <EOL> ( address >> <NUM_LIT> ) & <NUM_LIT> , <EOL> ( address >> <NUM_LIT:16> ) & <NUM_LIT> , <EOL> ( address >> <NUM_LIT:8> ) & <NUM_LIT> , <EOL> address & <NUM_LIT> , <EOL> ) <EOL> address = '<STR_LIT:.>' . join ( map ( str , address ) ) <EOL> return address <EOL> class DccFileReceiveBasic ( protocol . Protocol , styles . Ephemeral ) : <EOL> """<STR_LIT>""" <EOL> bytesReceived = <NUM_LIT:0> <EOL> def __init__ ( self , resumeOffset = <NUM_LIT:0> ) : <EOL> self . bytesReceived = resumeOffset <EOL> self . resume = ( resumeOffset != <NUM_LIT:0> ) <EOL> def dataReceived ( self , data ) : <EOL> """<STR_LIT>""" <EOL> self . bytesReceived = self . bytesReceived + len ( data ) <EOL> self . transport . write ( struct . pack ( '<STR_LIT>' , self . bytesReceived ) ) <EOL> class DccSendProtocol ( protocol . Protocol , styles . Ephemeral ) : <EOL> """<STR_LIT>""" <EOL> blocksize = <NUM_LIT> <EOL> file = None <EOL> bytesSent = <NUM_LIT:0> <EOL> completed = <NUM_LIT:0> <EOL> connected = <NUM_LIT:0> <EOL> def __init__ ( self , file ) : <EOL> if type ( file ) is types . StringType : <EOL> self . file = open ( file , '<STR_LIT:r>' ) <EOL> def connectionMade ( self ) : <EOL> self . connected = <NUM_LIT:1> <EOL> self . sendBlock ( ) <EOL> def dataReceived ( self , data ) : <EOL> bytesShesGot = struct . unpack ( "<STR_LIT>" , data ) <EOL> if bytesShesGot < self . bytesSent : <EOL> return <EOL> elif bytesShesGot > self . bytesSent : <EOL> self . transport . loseConnection ( ) <EOL> return <EOL> self . sendBlock ( ) <EOL> def sendBlock ( self ) : <EOL> block = self . file . read ( self . blocksize ) <EOL> if block : <EOL> self . transport . write ( block ) <EOL> self . bytesSent = self . bytesSent + len ( block ) <EOL> else : <EOL> self . transport . loseConnection ( ) <EOL> self . completed = <NUM_LIT:1> <EOL> def connectionLost ( self , reason ) : <EOL> self . connected = <NUM_LIT:0> <EOL> if hasattr ( self . file , "<STR_LIT>" ) : <EOL> self . file . close ( ) <EOL> class DccSendFactory ( protocol . Factory ) : <EOL> protocol = DccSendProtocol <EOL> def __init__ ( self , file ) : <EOL> self . file = file <EOL> def buildProtocol ( self , connection ) : <EOL> p = self . protocol ( self . file ) <EOL> p . factory = self <EOL> return p <EOL> def fileSize ( file ) : <EOL> """<STR_LIT>""" <EOL> size = None <EOL> if hasattr ( file , "<STR_LIT>" ) : <EOL> fileno = file . fileno ( ) <EOL> try : <EOL> stat_ = os . fstat ( fileno ) <EOL> size = stat_ [ stat . ST_SIZE ] <EOL> except : <EOL> pass <EOL> else : <EOL> return size <EOL> if hasattr ( file , "<STR_LIT:name>" ) and path . exists ( file . name ) : <EOL> try : <EOL> size = path . getsize ( file . name ) <EOL> except : <EOL> pass <EOL> else : <EOL> return size <EOL> if hasattr ( file , "<STR_LIT>" ) and hasattr ( file , "<STR_LIT>" ) : <EOL> try : <EOL> try : <EOL> file . seek ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> size = file . tell ( ) <EOL> finally : <EOL> file . seek ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> except : <EOL> pass <EOL> else : <EOL> return size <EOL> return size <EOL> class DccChat ( basic . LineReceiver , styles . Ephemeral ) : <EOL> """<STR_LIT>""" <EOL> queryData = None <EOL> delimiter = CR + NL <EOL> client = None <EOL> remoteParty = None <EOL> buffer = "<STR_LIT>" <EOL> def __init__ ( self , client , queryData = None ) : <EOL> """<STR_LIT>""" <EOL> self . client = client <EOL> if queryData : <EOL> self . queryData = queryData <EOL> self . remoteParty = self . queryData [ <NUM_LIT:0> ] <EOL> def dataReceived ( self , data ) : <EOL> self . buffer = self . buffer + data <EOL> lines = string . split ( self . buffer , LF ) <EOL> self . buffer = lines . pop ( ) <EOL> for line in lines : <EOL> if line [ - <NUM_LIT:1> ] == CR : <EOL> line = line [ : - <NUM_LIT:1> ] <EOL> self . lineReceived ( line ) <EOL> def lineReceived ( self , line ) : <EOL> log . msg ( "<STR_LIT>" % ( self . remoteParty , line ) ) <EOL> self . client . privmsg ( self . remoteParty , <EOL> self . client . nickname , line ) <EOL> class DccChatFactory ( protocol . ClientFactory ) : <EOL> protocol = DccChat <EOL> noisy = <NUM_LIT:0> <EOL> def __init__ ( self , client , queryData ) : <EOL> self . client = client <EOL> self . queryData = queryData <EOL> def buildProtocol ( self , addr ) : <EOL> p = self . protocol ( client = self . client , queryData = self . queryData ) <EOL> p . factory = self <EOL> def clientConnectionFailed ( self , unused_connector , unused_reason ) : <EOL> self . client . dcc_sessions . remove ( self ) <EOL> def clientConnectionLost ( self , unused_connector , unused_reason ) : <EOL> self . client . dcc_sessions . remove ( self ) <EOL> def dccDescribe ( data ) : <EOL> """<STR_LIT>""" <EOL> orig_data = data <EOL> data = string . split ( data ) <EOL> if len ( data ) < <NUM_LIT:4> : <EOL> return orig_data <EOL> ( dcctype , arg , address , port ) = data [ : <NUM_LIT:4> ] <EOL> if '<STR_LIT:.>' in address : <EOL> pass <EOL> else : <EOL> try : <EOL> address = long ( address ) <EOL> except ValueError : <EOL> pass <EOL> else : <EOL> address = ( <EOL> ( address >> <NUM_LIT> ) & <NUM_LIT> , <EOL> ( address >> <NUM_LIT:16> ) & <NUM_LIT> , <EOL> ( address >> <NUM_LIT:8> ) & <NUM_LIT> , <EOL> address & <NUM_LIT> , <EOL> ) <EOL> address = string . join ( map ( str , map ( int , address ) ) , "<STR_LIT:.>" ) <EOL> if dcctype == '<STR_LIT>' : <EOL> filename = arg <EOL> size_txt = '<STR_LIT>' <EOL> if len ( data ) >= <NUM_LIT:5> : <EOL> try : <EOL> size = int ( data [ <NUM_LIT:4> ] ) <EOL> size_txt = '<STR_LIT>' % ( size , ) <EOL> except ValueError : <EOL> pass <EOL> dcc_text = ( "<STR_LIT>" <EOL> % ( filename , size_txt , address , port ) ) <EOL> elif dcctype == '<STR_LIT>' : <EOL> dcc_text = ( "<STR_LIT>" <EOL> % ( address , port ) ) <EOL> else : <EOL> dcc_text = orig_data <EOL> return dcc_text <EOL> class DccFileReceive ( DccFileReceiveBasic ) : <EOL> """<STR_LIT>""" <EOL> filename = '<STR_LIT>' <EOL> fileSize = - <NUM_LIT:1> <EOL> destDir = '<STR_LIT:.>' <EOL> overwrite = <NUM_LIT:0> <EOL> fromUser = None <EOL> queryData = None <EOL> def __init__ ( self , filename , fileSize = - <NUM_LIT:1> , queryData = None , <EOL> destDir = '<STR_LIT:.>' , resumeOffset = <NUM_LIT:0> ) : <EOL> DccFileReceiveBasic . __init__ ( self , resumeOffset = resumeOffset ) <EOL> self . filename = filename <EOL> self . destDir = destDir <EOL> self . fileSize = fileSize <EOL> if queryData : <EOL> self . queryData = queryData <EOL> self . fromUser = self . queryData [ <NUM_LIT:0> ] <EOL> def set_directory ( self , directory ) : <EOL> """<STR_LIT>""" <EOL> if not path . exists ( directory ) : <EOL> raise OSError ( errno . ENOENT , "<STR_LIT>" , <EOL> directory ) <EOL> if not path . isdir ( directory ) : <EOL> raise OSError ( errno . ENOTDIR , "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> directory ) <EOL> if not os . access ( directory , os . X_OK | os . W_OK ) : <EOL> raise OSError ( errno . EACCES , <EOL> "<STR_LIT>" , <EOL> directory ) <EOL> self . destDir = directory <EOL> def set_filename ( self , filename ) : <EOL> """<STR_LIT>""" <EOL> self . filename = filename <EOL> def set_overwrite ( self , boolean ) : <EOL> """<STR_LIT>""" <EOL> self . overwrite = boolean <EOL> def connectionMade ( self ) : <EOL> dst = path . abspath ( path . join ( self . destDir , self . filename ) ) <EOL> exists = path . exists ( dst ) <EOL> if self . resume and exists : <EOL> self . file = open ( dst , '<STR_LIT>' ) <EOL> log . msg ( "<STR_LIT>" % <EOL> ( self . file , self . file . tell ( ) ) ) <EOL> elif self . overwrite or not exists : <EOL> self . file = open ( dst , '<STR_LIT:wb>' ) <EOL> else : <EOL> raise OSError ( errno . EEXIST , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> dst ) <EOL> def dataReceived ( self , data ) : <EOL> self . file . write ( data ) <EOL> DccFileReceiveBasic . dataReceived ( self , data ) <EOL> def connectionLost ( self , reason ) : <EOL> """<STR_LIT>""" <EOL> self . connected = <NUM_LIT:0> <EOL> logmsg = ( "<STR_LIT>" % ( self , ) ) <EOL> if self . fileSize > <NUM_LIT:0> : <EOL> logmsg = ( "<STR_LIT>" <EOL> % ( logmsg , self . bytesReceived , self . fileSize ) ) <EOL> if self . bytesReceived == self . fileSize : <EOL> pass <EOL> elif self . bytesReceived < self . fileSize : <EOL> logmsg = ( "<STR_LIT>" <EOL> % ( logmsg , self . fileSize - self . bytesReceived ) ) <EOL> else : <EOL> logmsg = ( "<STR_LIT>" <EOL> % ( logmsg , ) ) <EOL> else : <EOL> logmsg = ( "<STR_LIT>" <EOL> % ( logmsg , self . bytesReceived ) ) <EOL> if hasattr ( self , '<STR_LIT:file>' ) : <EOL> logmsg = "<STR_LIT>" % ( logmsg , self . file . name ) <EOL> if hasattr ( self . file , '<STR_LIT>' ) : self . file . close ( ) <EOL> def __str__ ( self ) : <EOL> if not self . connected : <EOL> return "<STR_LIT>" % ( id ( self ) , ) <EOL> from_ = self . transport . getPeer ( ) <EOL> if self . fromUser : <EOL> from_ = "<STR_LIT>" % ( self . fromUser , from_ ) <EOL> s = ( "<STR_LIT>" % ( self . filename , from_ ) ) <EOL> return s <EOL> def __repr__ ( self ) : <EOL> s = ( "<STR_LIT>" <EOL> % ( self . __class__ , id ( self ) , self . filename ) ) <EOL> return s <EOL> X_DELIM = chr ( <NUM_LIT> <NUM_LIT:1> ) <EOL> def ctcpExtract ( message ) : <EOL> """<STR_LIT>""" <EOL> extended_messages = [ ] <EOL> normal_messages = [ ] <EOL> retval = { '<STR_LIT>' : extended_messages , <EOL> '<STR_LIT>' : normal_messages } <EOL> messages = string . split ( message , X_DELIM ) <EOL> odd = <NUM_LIT:0> <EOL> while messages : <EOL> if odd : <EOL> extended_messages . append ( messages . pop ( <NUM_LIT:0> ) ) <EOL> else : <EOL> normal_messages . append ( messages . pop ( <NUM_LIT:0> ) ) <EOL> odd = not odd <EOL> extended_messages [ : ] = filter ( None , extended_messages ) <EOL> normal_messages [ : ] = filter ( None , normal_messages ) <EOL> extended_messages [ : ] = map ( ctcpDequote , extended_messages ) <EOL> for i in xrange ( len ( extended_messages ) ) : <EOL> m = string . split ( extended_messages [ i ] , SPC , <NUM_LIT:1> ) <EOL> tag = m [ <NUM_LIT:0> ] <EOL> if len ( m ) > <NUM_LIT:1> : <EOL> data = m [ <NUM_LIT:1> ] <EOL> else : <EOL> data = None <EOL> extended_messages [ i ] = ( tag , data ) <EOL> return retval <EOL> M_QUOTE = chr ( <NUM_LIT:0> <NUM_LIT:20> ) <EOL> mQuoteTable = { <EOL> NUL : M_QUOTE + '<STR_LIT:0>' , <EOL> NL : M_QUOTE + '<STR_LIT:n>' , <EOL> CR : M_QUOTE + '<STR_LIT:r>' , <EOL> M_QUOTE : M_QUOTE + M_QUOTE <EOL> } <EOL> mDequoteTable = { } <EOL> for k , v in mQuoteTable . items ( ) : <EOL> mDequoteTable [ v [ - <NUM_LIT:1> ] ] = k <EOL> del k , v <EOL> mEscape_re = re . compile ( '<STR_LIT>' % ( re . escape ( M_QUOTE ) , ) , re . DOTALL ) <EOL> def lowQuote ( s ) : <EOL> for c in ( M_QUOTE , NUL , NL , CR ) : <EOL> s = string . replace ( s , c , mQuoteTable [ c ] ) <EOL> return s <EOL> def lowDequote ( s ) : <EOL> def sub ( matchobj , mDequoteTable = mDequoteTable ) : <EOL> s = matchobj . group ( ) [ <NUM_LIT:1> ] <EOL> try : <EOL> s = mDequoteTable [ s ] <EOL> except KeyError : <EOL> s = s <EOL> return s <EOL> return mEscape_re . sub ( sub , s ) <EOL> X_QUOTE = '<STR_LIT:\\>' <EOL> xQuoteTable = { <EOL> X_DELIM : X_QUOTE + '<STR_LIT:a>' , <EOL> X_QUOTE : X_QUOTE + X_QUOTE <EOL> } <EOL> xDequoteTable = { } <EOL> for k , v in xQuoteTable . items ( ) : <EOL> xDequoteTable [ v [ - <NUM_LIT:1> ] ] = k <EOL> xEscape_re = re . compile ( '<STR_LIT>' % ( re . escape ( X_QUOTE ) , ) , re . DOTALL ) <EOL> def ctcpQuote ( s ) : <EOL> for c in ( X_QUOTE , X_DELIM ) : <EOL> s = string . replace ( s , c , xQuoteTable [ c ] ) <EOL> return s <EOL> def ctcpDequote ( s ) : <EOL> def sub ( matchobj , xDequoteTable = xDequoteTable ) : <EOL> s = matchobj . group ( ) [ <NUM_LIT:1> ] <EOL> try : <EOL> s = xDequoteTable [ s ] <EOL> except KeyError : <EOL> s = s <EOL> return s <EOL> return xEscape_re . sub ( sub , s ) <EOL> def ctcpStringify ( messages ) : <EOL> """<STR_LIT>""" <EOL> coded_messages = [ ] <EOL> for ( tag , data ) in messages : <EOL> if data : <EOL> if not isinstance ( data , types . StringType ) : <EOL> try : <EOL> data = "<STR_LIT:U+0020>" . join ( map ( str , data ) ) <EOL> except TypeError : <EOL> pass <EOL> m = "<STR_LIT>" % ( tag , data ) <EOL> else : <EOL> m = str ( tag ) <EOL> m = ctcpQuote ( m ) <EOL> m = "<STR_LIT>" % ( X_DELIM , m , X_DELIM ) <EOL> coded_messages . append ( m ) <EOL> line = string . join ( coded_messages , '<STR_LIT>' ) <EOL> return line <EOL> RPL_WELCOME = '<STR_LIT>' <EOL> RPL_YOURHOST = '<STR_LIT>' <EOL> RPL_CREATED = '<STR_LIT>' <EOL> RPL_MYINFO = '<STR_LIT>' <EOL> RPL_ISUPPORT = '<STR_LIT>' <EOL> RPL_BOUNCE = '<STR_LIT>' <EOL> RPL_USERHOST = '<STR_LIT>' <EOL> RPL_ISON = '<STR_LIT>' <EOL> RPL_AWAY = '<STR_LIT>' <EOL> RPL_UNAWAY = '<STR_LIT>' <EOL> RPL_NOWAWAY = '<STR_LIT>' <EOL> RPL_WHOISUSER = '<STR_LIT>' <EOL> RPL_WHOISSERVER = '<STR_LIT>' <EOL> RPL_WHOISOPERATOR = '<STR_LIT>' <EOL> RPL_WHOISIDLE = '<STR_LIT>' <EOL> RPL_ENDOFWHOIS = '<STR_LIT>' <EOL> RPL_WHOISCHANNELS = '<STR_LIT>' <EOL> RPL_WHOWASUSER = '<STR_LIT>' <EOL> RPL_ENDOFWHOWAS = '<STR_LIT>' <EOL> RPL_LISTSTART = '<STR_LIT>' <EOL> RPL_LIST = '<STR_LIT>' <EOL> RPL_LISTEND = '<STR_LIT>' <EOL> RPL_UNIQOPIS = '<STR_LIT>' <EOL> RPL_CHANNELMODEIS = '<STR_LIT>' <EOL> RPL_NOTOPIC = '<STR_LIT>' <EOL> RPL_TOPIC = '<STR_LIT>' <EOL> RPL_INVITING = '<STR_LIT>' <EOL> RPL_SUMMONING = '<STR_LIT>' <EOL> RPL_INVITELIST = '<STR_LIT>' <EOL> RPL_ENDOFINVITELIST = '<STR_LIT>' <EOL> RPL_EXCEPTLIST = '<STR_LIT>' <EOL> RPL_ENDOFEXCEPTLIST = '<STR_LIT>' <EOL> RPL_VERSION = '<STR_LIT>' <EOL> RPL_WHOREPLY = '<STR_LIT>' <EOL> RPL_ENDOFWHO = '<STR_LIT>' <EOL> RPL_NAMREPLY = '<STR_LIT>' <EOL> RPL_ENDOFNAMES = '<STR_LIT>' <EOL> RPL_LINKS = '<STR_LIT>' <EOL> RPL_ENDOFLINKS = '<STR_LIT>' <EOL> RPL_BANLIST = '<STR_LIT>' <EOL> RPL_ENDOFBANLIST = '<STR_LIT>' <EOL> RPL_INFO = '<STR_LIT>' <EOL> RPL_ENDOFINFO = '<STR_LIT>' <EOL> RPL_MOTDSTART = '<STR_LIT>' <EOL> RPL_MOTD = '<STR_LIT>' <EOL> RPL_ENDOFMOTD = '<STR_LIT>' <EOL> RPL_YOUREOPER = '<STR_LIT>' <EOL> RPL_REHASHING = '<STR_LIT>' <EOL> RPL_YOURESERVICE = '<STR_LIT>' <EOL> RPL_TIME = '<STR_LIT>' <EOL> RPL_USERSSTART = '<STR_LIT>' <EOL> RPL_USERS = '<STR_LIT>' <EOL> RPL_ENDOFUSERS = '<STR_LIT>' <EOL> RPL_NOUSERS = '<STR_LIT>' <EOL> RPL_TRACELINK = '<STR_LIT>' <EOL> RPL_TRACECONNECTING = '<STR_LIT>' <EOL> RPL_TRACEHANDSHAKE = '<STR_LIT>' <EOL> RPL_TRACEUNKNOWN = '<STR_LIT>' <EOL> RPL_TRACEOPERATOR = '<STR_LIT>' <EOL> RPL_TRACEUSER = '<STR_LIT>' <EOL> RPL_TRACESERVER = '<STR_LIT>' <EOL> RPL_TRACESERVICE = '<STR_LIT>' <EOL> RPL_TRACENEWTYPE = '<STR_LIT>' <EOL> RPL_TRACECLASS = '<STR_LIT>' <EOL> RPL_TRACERECONNECT = '<STR_LIT>' <EOL> RPL_TRACELOG = '<STR_LIT>' <EOL> RPL_TRACEEND = '<STR_LIT>' <EOL> RPL_STATSLINKINFO = '<STR_LIT>' <EOL> RPL_STATSCOMMANDS = '<STR_LIT>' <EOL> RPL_ENDOFSTATS = '<STR_LIT>' <EOL> RPL_STATSUPTIME = '<STR_LIT>' <EOL> RPL_STATSOLINE = '<STR_LIT>' <EOL> RPL_UMODEIS = '<STR_LIT>' <EOL> RPL_SERVLIST = '<STR_LIT>' <EOL> RPL_SERVLISTEND = '<STR_LIT>' <EOL> RPL_LUSERCLIENT = '<STR_LIT>' <EOL> RPL_LUSEROP = '<STR_LIT>' <EOL> RPL_LUSERUNKNOWN = '<STR_LIT>' <EOL> RPL_LUSERCHANNELS = '<STR_LIT>' <EOL> RPL_LUSERME = '<STR_LIT>' <EOL> RPL_ADMINME = '<STR_LIT>' <EOL> RPL_ADMINLOC = '<STR_LIT>' <EOL> RPL_ADMINLOC = '<STR_LIT>' <EOL> RPL_ADMINEMAIL = '<STR_LIT>' <EOL> RPL_TRYAGAIN = '<STR_LIT>' <EOL> ERR_NOSUCHNICK = '<STR_LIT>' <EOL> ERR_NOSUCHSERVER = '<STR_LIT>' <EOL> ERR_NOSUCHCHANNEL = '<STR_LIT>' <EOL> ERR_CANNOTSENDTOCHAN = '<STR_LIT>' <EOL> ERR_TOOMANYCHANNELS = '<STR_LIT>' <EOL> ERR_WASNOSUCHNICK = '<STR_LIT>' <EOL> ERR_TOOMANYTARGETS = '<STR_LIT>' <EOL> ERR_NOSUCHSERVICE = '<STR_LIT>' <EOL> ERR_NOORIGIN = '<STR_LIT>' <EOL> ERR_NORECIPIENT = '<STR_LIT>' <EOL> ERR_NOTEXTTOSEND = '<STR_LIT>' <EOL> ERR_NOTOPLEVEL = '<STR_LIT>' <EOL> ERR_WILDTOPLEVEL = '<STR_LIT>' <EOL> ERR_BADMASK = '<STR_LIT>' <EOL> ERR_UNKNOWNCOMMAND = '<STR_LIT>' <EOL> ERR_NOMOTD = '<STR_LIT>' <EOL> ERR_NOADMININFO = '<STR_LIT>' <EOL> ERR_FILEERROR = '<STR_LIT>' <EOL> ERR_NONICKNAMEGIVEN = '<STR_LIT>' <EOL> ERR_ERRONEUSNICKNAME = '<STR_LIT>' <EOL> ERR_NICKNAMEINUSE = '<STR_LIT>' <EOL> ERR_NICKCOLLISION = '<STR_LIT>' <EOL> ERR_UNAVAILRESOURCE = '<STR_LIT>' <EOL> ERR_USERNOTINCHANNEL = '<STR_LIT>' <EOL> ERR_NOTONCHANNEL = '<STR_LIT>' <EOL> ERR_USERONCHANNEL = '<STR_LIT>' <EOL> ERR_NOLOGIN = '<STR_LIT>' <EOL> ERR_SUMMONDISABLED = '<STR_LIT>' <EOL> ERR_USERSDISABLED = '<STR_LIT>' <EOL> ERR_NOTREGISTERED = '<STR_LIT>' <EOL> ERR_NEEDMOREPARAMS = '<STR_LIT>' <EOL> ERR_ALREADYREGISTRED = '<STR_LIT>' <EOL> ERR_NOPERMFORHOST = '<STR_LIT>' <EOL> ERR_PASSWDMISMATCH = '<STR_LIT>' <EOL> ERR_YOUREBANNEDCREEP = '<STR_LIT>' <EOL> ERR_YOUWILLBEBANNED = '<STR_LIT>' <EOL> ERR_KEYSET = '<STR_LIT>' <EOL> ERR_CHANNELISFULL = '<STR_LIT>' <EOL> ERR_UNKNOWNMODE = '<STR_LIT>' <EOL> ERR_INVITEONLYCHAN = '<STR_LIT>' <EOL> ERR_BANNEDFROMCHAN = '<STR_LIT>' <EOL> ERR_BADCHANNELKEY = '<STR_LIT>' <EOL> ERR_BADCHANMASK = '<STR_LIT>' <EOL> ERR_NOCHANMODES = '<STR_LIT>' <EOL> ERR_BANLISTFULL = '<STR_LIT>' <EOL> ERR_NOPRIVILEGES = '<STR_LIT>' <EOL> ERR_CHANOPRIVSNEEDED = '<STR_LIT>' <EOL> ERR_CANTKILLSERVER = '<STR_LIT>' <EOL> ERR_RESTRICTED = '<STR_LIT>' <EOL> ERR_UNIQOPPRIVSNEEDED = '<STR_LIT>' <EOL> ERR_NOOPERHOST = '<STR_LIT>' <EOL> ERR_NOSERVICEHOST = '<STR_LIT>' <EOL> ERR_UMODEUNKNOWNFLAG = '<STR_LIT>' <EOL> ERR_USERSDONTMATCH = '<STR_LIT>' <EOL> symbolic_to_numeric = { <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> } <EOL> numeric_to_symbolic = { } <EOL> for k , v in symbolic_to_numeric . items ( ) : <EOL> numeric_to_symbolic [ v ] = k </s>
