Index: twisted/words/test/test_irc.py =================================================================== --- twisted/words/test/test_irc.py (revision 38290) +++ twisted/words/test/test_irc.py (working copy) @@ -2001,6 +2001,23 @@ return transport.value().split('\r\n')[-2] + def test_channel_list(self): + """ + L{IRCClient.channel_list} sends LIST command to the server + """ + self.protocol.channel_list() #for getting list of all the channels from the server + self.protocol.channel_list("#foo") # specifying channel name + self.protocol.channel_list("#foo", "server") #specifying channel name and target both + + expected = ["LIST", + "LIST #foo", + "LIST #foo server", + ''] + + self.assertEqual(self.transport.value().split('\r\n'), + expected) + + def test_away(self): """ L{IRCClient.away} sends an AWAY command with the specified message. Index: twisted/words/protocols/irc.py =================================================================== --- twisted/words/protocols/irc.py (revision 38290) +++ twisted/words/protocols/irc.py (working copy) @@ -1815,6 +1815,64 @@ return nickname + '_' + def channel_list(self, channel=None, target=None): + """ + The list command is used to list channels and their topics. + @type channel: C{str} + @param channel: If the channel parameter is used, only the status of that channel is displayed. + + @type target: C{str} + @param target: If the target parameter is specified, the request is forwarded to that server which will generate the reply. + + """ + if channel and target: + self.sendLine("LIST %s %s" % (channel, target) ) + elif channel: + self.sendLine("LIST %s" % (channel)) + else: + # print "Sending list" + self.sendLine("LIST") + + + def irc_RPL_LIST(self, prefix, params): + """ + Called when we get LIST of channels from the server, output of LIST Command + """ + # print "In irc_RPL_LIST" + # print "prefix : %s" % (prefix) + # print "params : %s" % (params) + #deleting nick from params,so that params will contain channel name,number of users on the channel and topic of the channel + del params[0] + self.gotChannelList(params ) + + + def irc_RPL_LISTEND(self, prefix, params): + """ + Called when output of /LIST ends + """ + # print "prefix : %s" % ( prefix ) + # print "params : %s" % ( params ) + del params[0] + self.channelListEnd(params) + + + def gotChannelList(self, params): + """ + @type params: C{[str, str, str]} + @return a list like this: [channel, number of users, topic of the channel] + """ + return params + + + def channelListEnd(self, param): + """ + Returns End of /LIST + @type param: C[{str}] + @return : C{str} + """ + return params[0] + + def irc_ERR_ERRONEUSNICKNAME(self, prefix, params): """ Called when we try to register or change to an illegal nickname.