o b@sdZddlmZmZddlmZddlmZddlmZm Z m Z ddl m Z mZddlmZmZmZddlmZdd lmZdd lmZmZdd lmZeejGd d d ZeejGdddZdZ eej!Gdddej"Z#Gdddej$Z%Gdddej&Z'eej!Gdddej(Z)e*e'e)Gdddej&Z+eejGdddej(Z,e*e+e,Gdddej&Z-eej!Gdd d ej&Z.ee.ejej/Gd!d"d"ej(Z0e*e.e0ee j1ej2Gd#d$d$Z3Gd%d&d&e3Z4gd'Z5d(S))a A module that needs a better name. Implements new cred things for words. How does this thing work? - Network connection on some port expecting to speak some protocol - Protocol-specific authentication, resulting in some kind of credentials object - twisted.cred.portal login using those credentials for the interface IUser and with something implementing IChatClient as the mind - successful login results in an IUser avatar the protocol can call methods on, and state added to the realm such that the mind will have methods called on it as is necessary - protocol specific actions lead to calls onto the avatar; remote events lead to calls onto the mind - protocol specific hangup, realm is notified, user is removed from active play, the end. )ctimetime) implementer) copyright) credentialserrorportal)deferprotocol)failurelogreflect)registerAdapter)pb)ewordsiwords)ircc@sVeZdZddZddZddZddZdd d Zd d ZddZ ddZ ddZ d S)GroupcCs||_i|_ddd|_dS)N)topic topic_author)nameusersmetaselfrr7/usr/lib/python3/dist-packages/twisted/words/service.py__init__.s  zGroup.__init__cCstt||SN)r Failure Exception)rerrprrr _ebUserCall6zGroup._ebUserCallcCs0|D]\}}|s|j\}}|||qdSr)valueremovegetErrorMessage)rresultssuccessresultuserr"rrr _cbUserCall9s  zGroup._cbUserCallcCstj|s Jd||j|jvrEg}||j|j<|jD]}||ur;t|j ||}|j |j |d| |q t ||jtdS)Nz{!r} is not a chat clientr#)r IChatClient providedByformatrrvaluesr maybeDeferred userJoined addErrbackr$append DeferredList addCallbackr-succeed)rr, additionsr#drrradd?s    z Group.addNcCsz|j|j=Wn tyYn.wg}|jD]}||ur4t|j|||}|j|j|d| |qt | |j t dSNr.)rrKeyErrorr2r r3userLeftr5r$r6r7r8r-r9)rr,reasonremovalsr#r;rrrr'Ns   z Group.removecCstt|jSr)r r9lenrrrrrsize]r%z Group.sizecCsp||usJg}|jD]}||ur)t|j|||}|j|j|d||q t| |j t dSr=) rr2r r3receiver5r$r6r7r8r-r9)rsender recipientmessagereceivesr#r;rrrrE`s   z Group.receivecCs`||_g}|jD]}t|j||}|j|j|d||q t | |j t dSr=) rrr2r r3groupMetaUpdater5r$r6r7r8r-r9)rrsetsr#r;rrr setMetadataks  zGroup.setMetadatacCst|jSr)iterrr2rCrrr iterusersuszGroup.iterusersr) __name__ __module__ __qualname__rr$r-r<r'rDrErLrNrrrrr,s  rc@sNeZdZdZdZddZddZddZddd Zd d Z d d Z ddZ dS)UserNcCs||_g|_t|_dSr)rgroupsr lastMessagerrrrr z User.__init__cCs||_||_t|_dSr)realmmindrsignOn)rrVrWrrrloggedInrUz User.loggedIncs fdd}j|S)Ncj|Sr)rSr6r+grouprrrcbJoin zUser.join..cbJoin)r<rWr8)rr]r^rr\rjoinsz User.joincs"fdd}j||S)NcrZr)rSr'r[r\rrcbLeaver_zUser.leave..cbLeave)r'rWr8)rr]r@rarr\rleavesz User.leavecCst|_||j||Sr)rrTrErW)rrGrHrrrsendsz User.sendcCs t|jSr)rMrSrCrrr itergroups zUser.itergroupscCs"|jddD]}||qdSr)rSrb)rgrrrlogouts z User.logoutr) rOrPrQrVrWrrYr`rbrcrdrgrrrrrRzs  rRzNickServ!NickServ@servicesc@seZdZdZdZdZdZdZdZddZ ddZ dd Z d d Z dPd d Z ddZddZdZdZddZddZddZddZddZejdfejdfejdfejdfgZejd fejd!fgZd"d#Z d$d%Z!d&d'Z"d(d)Z#dPd*d+Z$dPd,d-Z%d.d/Z&d0d1Z'd2d3Z(d4d5Z)d6d7Z*d8d9Z+d:d;Z,dd?Z.d@dAZ/dBdCZ0dDdEZ1dFdGZ2dHdIZ3dJdKZ4dLdMZ5dNdOZ6dS)QIRCUserzM Protocol instance representing an IRC user connected to the server. Nutf-8cCs |j|_|jj|_|jj|_dSr)irc_NICKSERV_PRIVMSG irc_PRIVMSGfactoryrVrhostnamerCrrrconnectionMades zIRCUser.connectionMadecCs |jdur|d|_dSdSr)rgavatarrr@rrrconnectionLosts  zIRCUser.connectionLostcOsd|vr |j|d<d|vr|j|j|d<|||dgt|}g}|D]}t|tr1|d}||q%t j j |i|dS)Nprefixtori) rmrencodeencodinglist isinstancebytesdecoder6rIRC sendMessage)rcommandparameter_listkwarglistarglistUnicodeargrrrr{s    zIRCUser.sendMessagecCs,||jd|jd|jd|jdS)N!@#)r`rrmrr]r,rrrr4s,zIRCUser.userJoinedcCs2||jd|jd|jd|j|pddS)Nrrrleaving)partrrmrr]r,r@rrrr?s zIRCUser.userLeftcCs`tj|r d|j}n|j}|dd}|D]}||jd|jd|j||qdS)Nrtextzrr)rIGroupr0rget splitlinesprivmsgrm)rrFrGrH recipientNamerLrrrrEs    zIRCUser.receivec CsNd|vr%|d}|dd}||jd|j||d|d|jdSdS)Nrrrrrr)rrrrm)rr]rrauthorrrrrJs zIRCUser.groupMetaUpdatecC|d|_dS)z Password message -- Register a password. Parameters: [REQUIRED] Note that IRC requires the client send this *before* NICK and USER. N)passwordrrrparamsrrrirc_PASSs zIRCUser.irc_PASScCs|d}z t|tr||j}Wnty)|tt|d|j YdSw||_ ||_ |j D]\}}| |||jjq3|jdurP|t|ddS|j}d|_|||dS)zh Nick message -- Set your nickname. Parameters: [REQUIRED] rz;Your nickname cannot be decoded. Please use ASCII or UTF-8.Nz Password?)rwrxryruUnicodeDecodeErrorrNICKSERVrepr transportloseConnectionnicknamer _motdMessagesr{rl _serverInforlogInAs)rrrrrcoderrrrrirc_NICK s.      zIRCUser.irc_NICKcCr)zk User message -- Set your realname. Parameters: rN)realnamerrrrirc_USER/s zIRCUser.irc_USERcCsd|d}|d}|jdur|jdS|dkr$|t|jddS|j}d|_|||dS)^ Send a (private) message. Parameters: rrNnickservz1Denied. Please send me (NickServ) your password.)rrrlowerrrr)rrrrtargetrrrrrrj:s  zIRCUser.irc_NICKSERV_PRIVMSGcCs6|jjt|||tj}|j|j|j |fddS)N) errbackArgs) rlrloginrUsernamePasswordrIUser addCallbacks_cbLogin_ebLogin)rrrr;rrrrQszIRCUser.logInAsz:connected to Twisted IRCzA:Your host is %(serviceName)s, running version %(serviceVersion)sz,:This server was created on %(creationDate)sz&%(serviceName)s %(serviceVersion)s w nz(:- %(serviceName)s Message of the Day - z:End of /MOTD command.cCsZ|\}}}|tjusJd||`||_||_|jD]\}}||||jjqdS)NzRealm is buggy, got ) rrrkrorg_welcomeMessagesr{rlr)rr+ifacerorgrrrrrrns zIRCUser._cbLogincCsh|tjr|t|dn|tjr|t|dntdt ||t|d|j dS)Nz*Already logged in. No pod people allowed!zLogin failed. Goodbye.zUnhandled error during login:z"Server error during login. Sorry.) checkrAlreadyLoggedInrrecredUnauthorizedLoginr msgr"rr)rr"rrrrrzs    zIRCUser._ebLogincCs |jdur|d|jdSdS)zK Ping message Parameters: [ ] NPONG)rVr{rmrrrrirc_PINGs zIRCUser.irc_PINGcCs|jdS)z> Quit Parameters: [ ] N)rrrrrrirc_QUITszIRCUser.irc_QUITcGs0|r |tjddS||jd|jddS)N:Unknown MODE flag.r+)r{rERR_UNKNOWNMODE channelModer)rr]modesargsrrr _channelModeszIRCUser._channelModecCsD|r |tjddS||jur|tjddS|tjddS)Nrrz(:You can't look at someone else's modes.)r{rrro RPL_UMODEISERR_USERSDONTMATCH)rr,rrrr _userModes zIRCUser._userModecszd}t|tr|j}Wnty%tjddYdSw|drMfdd}j |dd}|j j |t ddddSfd d }j |}|j j|t ddddS) z User mode message Parameters: *( ( "+" / "-" ) *( "i" / "w" / "o" / "O" / "r" ) ) rz2:No such nickname (could not decode your unicode!)Nrc$|tjtjdddS)Nr:That channel doesn't exist.trapr NoSuchGroupr{rERR_NOSUCHCHANNELr"rrrrebGroups  z!IRCUser.irc_MODE..ebGroup) callbackArgscstjddS)Nz:No such nickname.r{rERR_NOSUCHNICKrrCrrebUserz IRCUser.irc_MODE..ebUser)rwrxryrurr{rr startswithrV lookupGrouprrtuple lookupUserr)rrrr channelOrUserrr;rrrrirc_MODEs(    "  "zIRCUser.irc_MODEcCsdS)zl Userhost message Parameters: *( SPACE ) [Optional] Nrrrrr irc_USERHOSTszIRCUser.irc_USERHOSTcsz|dttrjWnty%tj|ddYdSw|ddr:j dd}n j  dd}fd d }fd d }| ||dS) rrz6:No such nick/channel (could not decode your unicode!)NrrrcSs|jSr)rWr,rrrsz%IRCUser.irc_PRIVMSG..cs|dur j|diSdS)Nr)rorc)targ) messageTextrrrcbTargetsz%IRCUser.irc_PRIVMSG..cbTargetcstjddS)Nz:No such nick/channel.rr)r targetNamerrebTargetz%IRCUser.irc_PRIVMSG..ebTarget)rwrxryrurr{rrrrVrrr8r)rrrrrrrr)rrrrrks,     zIRCUser.irc_PRIVMSGcz|dttrjWnty%tj|ddYdSwdr1ddfdd}fdd }j  ||dS) zm Join message Parameters: ( *( "," ) [ *( "," ) ] ) r1:No such channel (could not decode your unicode!)Nrrcs fdd}j|S)Ncs>jdjddDdS)NrcSg|]}|jqSrr.0r,rrr zEIRCUser.irc_JOIN..cbGroup..cbJoin..)r4namesrrN _sendTopic)ignr\rrr^s z1IRCUser.irc_JOIN..cbGroup..cbJoinror`r8)r]r^rCr]rcbGroups z!IRCUser.irc_JOIN..cbGroupcstjdddS)Nrz:No such channel.)r{rrr groupNamerrrrs z!IRCUser.irc_JOIN..ebGroup) rwrxryrurr{rrrrVgetGrouprrrrrrrrrrirc_JOINs$       zIRCUser.irc_JOINcsz|dt|dtr|djWnty)tj|ddYdSwdr5ddt |dkrJ|dttrIdndfdd}fd d }j  ||dS) zc Part message Parameters: *( "," ) [ ] rz:Could not decode your unicode!Nrrrics$fdd}j|S)NcsdSr)r?r[)r]r@rrrra@rz2IRCUser.irc_PART..cbGroup..cbLeave)rorbr8)r]ra)r@rrrr?sz!IRCUser.irc_PART..cbGroupcs,|tjtjdd|dS)Nr:)rrrr{rERR_NOTONCHANNELr(rrrrrEs z!IRCUser.irc_PART..ebGroup) rwrxryrurr{rrrrBrVrrrr)rr@rrirc_PART%s,       zIRCUser.irc_PARTcr) zb Names message Parameters: [ *( "," ) [ ] ] rrNrrcs(jd|jdd|DdS)NrcSrrrrrrrrgrz6IRCUser.irc_NAMES..cbGroup..)rrrNrrCrrresz"IRCUser.irc_NAMES..cbGroupcs$|tjjdgdS)Nr)rrrrrrchannelrrrrjs z"IRCUser.irc_NAMES..ebGroup) rwrxryrurr{rrrrVrrrrrr irc_NAMESMs$       zIRCUser.irc_NAMEScCsz|d}t|dtr||j}Wnty$|tjdYdSw|dr0|dd}t |dkr@| ||ddS| |dS)zJ Topic message Parameters: [ ] rz<:That channel doesn't exist (could not decode your unicode!)Nrr) rwrxryrurr{rrrrB _setTopic _getTopic)rrrrrrrr irc_TOPICqs"     zIRCUser.irc_TOPICcCsd|jd}|r0|jdpd}|jdd}||jd|j|||jd|j||dSdS)zP Send the topic of the given group to this user, if it has one. rrz topic_daterrN)rrrr topicAuthor)rr]rrdaterrrrs zIRCUser._sendTopiccs(fdd}jj|dS)Nc"|tjtjdddSN=rrrrrrr  z"IRCUser._getTopic..ebGroup)rVrrr)rrrrrrrszIRCUser._getTopiccs4fdd}fdd}j||dS)NcsHj}|d<j|d<tt|d<fdd}||S)NrrrcstjdjddS)Nrz.:You need to be a channel operator to do that.)r{rERR_CHANOPRIVSNEEDEDrrr\rrebSets z1IRCUser._setTopic..cbGroup..ebSet)rcopyrintrrLr5)r]newMetar)rrrrrs  z"IRCUser._setTopic..cbGroupcrrrrrrrrrz"IRCUser._setTopic..ebGroup)rVrr)rrrrrr)rrrrrszIRCUser._setTopiccCs<|D]\}}}|tj|t|d|q|tjddS)z Send a group of LIST response lines @type channels: C{list} of C{(str, int, str)} @param channels: Information about the channels being sent: their name, the number of participants, and their topic. rz :End of /LISTN)r{rRPL_LISTstr RPL_LISTEND)rchannelsrrDrrrrrvsz IRCUser.listcs|rWz|d}t|tr|j}|d}Wnty,tj|ddYdSwg}|D]}| dr>|dd}| j |q1t j|dd}|d d nj }fd d }||dS) z List query Return information about the indicated channels, or about all channels if none are specified. Parameters: [ *( "," ) [ ] ] r,rNrrT) consumeErrorscSsdd|DS)NcSg|]\}}|r|qSrrrsrrrrrz6IRCUser.irc_LIST....r)gsrrrrsz"IRCUser.irc_LIST..cs6ddtfdd|D}|fdd|S)NcSs|j||jdfS)Nr)rrr)rDr]rrrgotSizerz3IRCUser.irc_LIST..cbGroups..gotSizecsg|] }||qSr)rDr8rr]rrrrsz6IRCUser.irc_LIST..cbGroups..csdd|DS)NcSrrrrrrrrrzHIRCUser.irc_LIST..cbGroups....)rv)r)rCrrrsz4IRCUser.irc_LIST..cbGroups..)r r7r8)rSr;rCrrcbGroupss z"IRCUser.irc_LIST..cbGroups)rwrxryrusplitrr{rrrr6rVrr r7r8rd)rrrr allChannelsr rSchrrrCrirc_LISTs0         zIRCUser.irc_LISTcs,jd|jfdd|DdS)Nrc s*g|]}|jjjj|jdd|jfqS)Hr)rrmrV)rmrCrrrsz'IRCUser._channelWho..)whorrNrr]rrCr _channelWhos zIRCUser._channelWhocCs|tjddS)Nz:User /WHO not implemented)r{r RPL_ENDOFWHOrr,rrr_userWhorzIRCUser._userWhocs|s tjddSz|dttrjWnty0tj|ddYdSwdrPfdd}j dd}| j |dSfd d }j }| j|dS) zC Who query Parameters: [ [ "o" ] ] z:/WHO not supported.Nrz2:End of /WHO list (could not decode your unicode!)rc |tjtjddSNz:End of /WHO list.)rrrr{rr"rrrrrr* z IRCUser.irc_WHO..ebGrouprcr%r&)rr NoSuchUserr{rr"rr'rrr2r(zIRCUser.irc_WHO..ebUser)r{rr"rwrxryrurrrVrrr!rr$)rrrrrr;rrr'rirc_WHO s.     zIRCUser.irc_WHOcs~fdd}fdd}zd}t|tr|j}Wnty2tjddYdSwj | ||dS)zV Whois query Parameters: [ ] *( "," ) csNj|j|jjj|jjjddtt|j|jdd|D dS)NzHi mom!FcSsg|]}d|jqS)rrrrrrrLsz5IRCUser.irc_WHOIS..cbUser..)whoisrrVrrrTrXrdrrCrrcbUser@sz!IRCUser.irc_WHOIS..cbUsercr)Nr:No such nick/channel)rrr)r{rrrrrrrOs z!IRCUser.irc_WHOIS..ebUserrr-N) rwrxryrurr{rrrVrr)rrrrr,rr,rrr irc_WHOIS9s    zIRCUser.irc_WHOIScCs|tjddS)zE Oper message Parameters: z:O-lines not applicableN)r{rERR_NOOPERHOSTrrrrirc_OPER^szIRCUser.irc_OPERr)7rOrPrQ__doc__rSrgrorVrurnrqr{r4r?rErJrrrrrrjrr RPL_WELCOME RPL_YOURHOST RPL_CREATED RPL_MYINFOr RPL_MOTDSTART RPL_ENDOFMOTDrrrrrrrrrrkrrrrrrrrvrr!r$r*r.r0rrrrrhsp   "     & #(($   4 0 %rhc@seZdZdZeZddZdS) IRCFactorya IRC server that creates instances of the L{IRCUser} protocol. @ivar _serverInfo: A dictionary mapping: "serviceName" to the name of the server, "serviceVersion" to the copyright version, "creationDate" to the time that the server was started. cCs&||_||_|jjtjtd|_dS)N) serviceNameserviceVersion creationDate)rVrrrversionrr)rrVrrrrrss  zIRCFactory.__init__N)rOrPrQr1rhr rrrrrr8gs r8c@s<eZdZddZddZddZddZd d Zd d Zd S)PBMindcCdSrrrCrrrr~zPBMind.__init__cCs.tt}t|tr|d}||j|fSNri)r qualr=rwr rtinvokerregisterReferencerjellierrArrrjellyFors   zPBMind.jellyForcCr>rr)rr,r]rrrremote_userJoinedr?zPBMind.remote_userJoinedcCr>rr)rr,r]r@rrrremote_userLeftr?zPBMind.remote_userLeftcCr>rrrrFrGrHrrrremote_receiver?zPBMind.remote_receivecCr>rrrr]rrrrremote_groupMetaUpdater?zPBMind.remote_groupMetaUpdateN) rOrPrQrrFrGrHrJrLrrrrr=}s r=c@s2eZdZdZddZddZddZd d d ZdS) PBMindReferencercCsJtj|rt|j|j|}nt|j|j|}|dt|j|j|||S)NrE)rrr0PBGrouprVroPBUser callRemote)rrFrGrHrecrrrrEs zPBMindReference.receivecCs|dt|j|j||S)NrJ)rPrNrVrorKrrrrJszPBMindReference.groupMetaUpdatecCs&|dt|j|j|t|j|j|S)Nr4rPrNrVrorOrrrrr4s zPBMindReference.userJoinedNcCs(|dt|j|j|t|j|j||S)Nr?rRrrrrr?s zPBMindReference.userLeftr)rOrPrQrrErJr4r?rrrrrMs  rMc@s6eZdZddZddZddZd dd Zd d ZdS) rNcC||_||_||_dSr)rVror])rrVror]rrrr zPBGroup.__init__cCt|jj|jj|jjfSr)hashrVrror]rCrrrprocessUniqueIDzPBGroup.processUniqueIDcCsNt|j}t|tr|d}|jj}t|tr|d}|||j |fSr@) r rA __class__rwr rtr]rrBrC)rrErAr]rrrrFs     zPBGroup.jellyForNcC|j|j|Sr)rorbr]rprrr remote_leaver%zPBGroup.remote_leavecCrZr)rorcr]rrHrrr remote_sendr%zPBGroup.remote_sendr)rOrPrQrrWrFr[r]rrrrrNs  rNc@sXeZdZddZdddZddZdd Zd d Zd d ZdddZ ddZ ddZ dS)PBGroupReferencecCsF|\}}}||_ttkrt|jtr|jd|_tj||||gSr@)rrxr rwryrRemoteReference unjellyFor)r unjellier unjellyListclsNamerrefrrrr`s zPBGroupReference.unjellyForNcC |d|S)NrbrPrprrrrb zPBGroupReference.leavecCre)Nrcrfr\rrrrcrgzPBGroupReference.sendcCr>rrr#rrrr<zPBGroupReference.addcCr>rrrCrrrrNrhzPBGroupReference.iteruserscCr>rrrIrrrrErhzPBGroupReference.receivecCr>rr)rr,r@rrrr'rhzPBGroupReference.removecCr>rr)rrrrrrLrhzPBGroupReference.setMetadatacCr>rrrCrrrrDrhzPBGroupReference.sizer) rOrPrQr`rbrcr<rNrEr'rLrDrrrrr^s   r^c@eZdZddZddZdS)rOcCrSr)rVror,)rrVror,rrrrrTzPBUser.__init__cCrUr)rVrVrror,rCrrrrWrXzPBUser.processUniqueIDN)rOrPrQrrWrrrrrOs rOc@s`eZdZddZddZddZeddZejd dZd d Z d d Z ddZ dddZ dS) ChatAvatarcC ||_dSr)ro)rrorrrr rezChatAvatar.__init__cCs0t|j}t|tr|d}||j|fSr@)r rArYrwr rtrBrCrDrrrrF s   zChatAvatar.jellyForcs(fdd}jj|}|||S)Ncs(fdd}j}|||S)NcstjjjSr)rNrorV)ignoredr\rrr^rz7ChatAvatar.remote_join..cbGroup..cbJoinr)r]r^r;rCrrrs  z'ChatAvatar.remote_join..cbGroup)rorVrr8)rrrr;rrCr remote_joins  zChatAvatar.remote_joincCr>rrrCrrrr zChatAvatar.namecCr>rr)rr&rrrr%rncCr>rrrKrrrrJ*rhzChatAvatar.groupMetaUpdatecCr>rrrIrrrrE.rhzChatAvatar.receivecCr>rrrrrrr42rhzChatAvatar.userJoinedNcCr>rrrrrrr?6rhzChatAvatar.userLeftr) rOrPrQrrFrmpropertyrsetterrJrEr4r?rrrrrjs  rjc@ri)AvatarReferencecCre)Nr`rf)rrrrrr`?rgzAvatarReference.joincs,t|jfdd|jjS)Ncs dSr)callbackrr;rrrDs z&AvatarReference.quit..)r DeferredbrokernotifyOnDisconnectrrrCrrsrquitBs zAvatarReference.quitN)rOrPrQr`rwrrrrrq>s rqc@seZdZdZddZddZddZdd Zd d Zd d Z dZ dZ ddZ ddZ ddZddZddZddZddZddZd S)! WordsRealmricCrkrrrrrrrPrezWordsRealm.__init__cCt|Sr)rRrrrr userFactorySzWordsRealm.userFactorycCryr)rrrrr groupFactoryVr{zWordsRealm.groupFactorycsfdd}|S)Ncs"tdddd__dS)NrgcSr>rrrrrrr\sz:WordsRealm.logoutFactory..logout..)getattrrVrWrrofacetrrrgZsz(WordsRealm.logoutFactory..logoutr)rrorrgrr~r logoutFactoryYszWordsRealm.logoutFactorycs8ttr jfdd}|S)Ncsl|jdur tD]%}||d}|dur0|__|_||||fSq tr)rVrrrYrrorNotImplementedError)rorravatarId interfacesrWrrr gotAvatares    z+WordsRealm.requestAvatar..gotAvatar)rwrxry _encodinggetUserr8)rrrWrrrrr requestAvataras   zWordsRealm.requestAvatarcCr>rrrCrrrrdtrhzWordsRealm.itergroupsFTcCtrrrrrrr|r?zWordsRealm.lookupUsercCrrrr rrrrr?zWordsRealm.lookupGroupcCr)a Add the given user to this service. This is an internal method intended to be overridden by L{WordsRealm} subclasses, not called by external code. @type user: L{IUser} @rtype: L{twisted.internet.defer.Deferred} @return: A Deferred which fires with L{None} when the user is added, or which fails with L{twisted.words.ewords.DuplicateUser} if a user with the same name exists already. rr#rrraddUserszWordsRealm.addUsercCr)aY Add the given group to this service. @type group: L{IGroup} @rtype: L{twisted.internet.defer.Deferred} @return: A Deferred which fires with L{None} when the group is added, or which fails with L{twisted.words.ewords.DuplicateGroup} if a group with the same name exists already. rr rrraddGroups zWordsRealm.addGroupc.jrfdd}|SS)Nc|tjSr)rrDuplicateGrouprrrrrrr  z$WordsRealm.getGroup..ebGroup)createGroupOnRequest createGroupr5r)rrrrrrr zWordsRealm.getGroupcr)Ncrr)rr DuplicateUserrrrrrrrz"WordsRealm.getUser..ebUser)createUserOnRequest createUserr5r)rrrrrrrrzWordsRealm.getUsercHfdd}fdd}}||||j|S)NcttSr)r r rrrrrrcbLookupr%z'WordsRealm.createUser..cbLookupcrr)rrr)rzrrrrebLookuprz'WordsRealm.createUser..ebLookup)rrrr8rrrrrr;rrrr    zWordsRealm.createUsercr)Ncrr)r r rrrrrrrr%z(WordsRealm.createGroup..cbLookupcrr)rrrr|rrrrrrz(WordsRealm.createGroup..ebLookup)rrrr8rrrrrrrzWordsRealm.createGroupN)rOrPrQrrrzr|rrrdrrrrrrrrrrrrrrrxLs$  rxcsDeZdZfddZddZddZddZd d Zd d ZZ S) InMemoryWordsRealmcs"tj|i|i|_i|_dSr)superrrrS)rar~rYrrrs zInMemoryWordsRealm.__init__cCst|jSr)r r9rSr2rCrrrrdr%zInMemoryWordsRealm.itergroupscC6|j|jvrtttS||j|j<t|Sr) rrr failr r rrr9r#rrrr   zInMemoryWordsRealm.addUsercCrr) rrSr rr r rrr9r rrrrrzInMemoryWordsRealm.addGroupc CJ|}z|j|}Wntyttt|YSwt |Sr) rrr>r rr r rr)r9)rrr,rrrr  zInMemoryWordsRealm.lookupUserc Crr) rrSr>r rr r rrr9)rrr]rrrrrzInMemoryWordsRealm.lookupGroup) rOrPrQrrdrrrr __classcell__rrrrrs  r)rrRrxrN)6r1rrzope.interfacertwistedr twisted.credrrrrtwisted.internetr r twisted.pythonr r r twisted.python.componentsrtwisted.spreadr twisted.wordsrrtwisted.words.protocolsrrrrrRrr/rzrh ServerFactoryr8 Referenceabler=r_rMsetUnjellyableForClassrNr^rOrj IPerspectiverqIRealm IChatServicerxr__all__rrrrsV     M(E " ' 2  (