Ticket #4929: bug_4929_2.patch

File bug_4929_2.patch, 4.2 KB (added by Upasana, 4 years ago)
  • twisted/words/test/test_irc.py

     
    20012001        return transport.value().split('\r\n')[-2]
    20022002
    20032003
     2004    def test_channelList(self):
     2005        """
     2006        L{IRCClient.channel_list} sends LIST command to the server
     2007        """
     2008        self.protocol.channelList() #for getting list of all the channels from the server
     2009        self.protocol.channelList("#foo") # specifying channel name
     2010        self.protocol.channelList("#foo,#bar", "server") #specifying channel name and target both
     2011
     2012        expected = ["LIST",
     2013                    "LIST #foo",
     2014                    "LIST #foo,#bar server",
     2015                    '']
     2016
     2017        self.assertEqual(self.transport.value().split('\r\n'),
     2018                                                       expected)
     2019
     2020
    20042021    def test_away(self):
    20052022        """
    20062023        L{IRCClient.away} sends an AWAY command with the specified message.
  • twisted/words/protocols/irc.py

     
    13381338        """
    13391339        self.nickname = nick
    13401340
     1341       
     1342    def channelListStart(self, listStart):
     1343        """
     1344        Called when there is a chance of getting channel list from the server in next few lines of response
     1345        @type listStart: C{str}
     1346        """
    13411347
     1348   
     1349    def gotChannelList(self, channel, usersCount, topic):
     1350        """
     1351        Called when we get one channel list from the server
     1352        @type channel: C{str}
     1353        @type usersCount: C{int}
     1354        @type topic: C{str}
     1355        """
     1356
     1357
     1358    def channelListEnd(self, endOfList):
     1359        """
     1360        Called when channel list ends.
     1361        @type endOfList: C[{str}]
     1362        """
     1363
     1364
    13421365    ### Things I observe other people doing in a channel.
    13431366
    13441367    def userJoined(self, user, channel):
     
    17031726        """
    17041727        self.sendLine("QUIT :%s" % message)
    17051728
     1729   
     1730    def channelList(self, channel=None, target=None):
     1731        """
     1732        The list command is used to list channels and their topics. 
     1733        @type channel: C{str}, str is a comma separated list of channels like "#foo,#bar"
     1734        @param channel: If the channel parameter is used, only the status of those channels is displayed.
     1735
     1736        @type target: C{str}
     1737        @param target: If the target parameter is specified, the request is forwarded to that server which will generate the reply.
     1738       
     1739        """
     1740        if channel and target:
     1741            self.sendLine("LIST %s %s" % (channel, target) )
     1742        elif channel:
     1743            channel = channel.replace(' ', '') #replacing any spaces in the channel-names
     1744            self.sendLine("LIST %s" % (channel,))
     1745        else:
     1746            self.sendLine("LIST")
     1747   
     1748
    17061749    ### user input commands, client->client
    17071750
    17081751    def describe(self, channel, action):
     
    20732116    def irc_RPL_LUSERME(self, prefix, params):
    20742117        self.luserMe(params[1])
    20752118
     2119
     2120    def irc_RPL_LISTSTART(self, prefix, params):
     2121        """
     2122        Called when we get an intimation from the server, that it's about to send RPL_LIST
     2123        """
     2124        del params[0]
     2125        firstLine = "\t".join(params)
     2126        self.channelListStart(firstLine)
     2127
     2128
     2129    def irc_RPL_LIST(self, prefix, params):
     2130        """
     2131        Called when we get LIST of channels from the server, output of LIST Command
     2132        """
     2133        self.gotChannelList(params[1], int(params[2]), params[3] )
     2134
     2135
     2136    def irc_RPL_LISTEND(self, prefix, params):
     2137        """
     2138        Called when output of /LIST ends
     2139        """
     2140        del params[0]
     2141        self.channelListEnd(params)
     2142
     2143
    20762144    def irc_unknown(self, prefix, command, params):
    20772145        pass
    20782146
  • twisted/words/topfiles/4929.feature

     
     1twisted.words.protocols.irc.IRCClient provides a function for LIST command
     2 No newline at end of file