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_channelList(self): + """ + L{IRCClient.channel_list} sends LIST command to the server + """ + self.protocol.channelList() #for getting list of all the channels from the server + self.protocol.channelList("#foo") # specifying channel name + self.protocol.channelList("#foo,#bar", "server") #specifying channel name and target both + + expected = ["LIST", + "LIST #foo", + "LIST #foo,#bar 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) @@ -1338,7 +1338,30 @@ """ self.nickname = nick + + def channelListStart(self, listStart): + """ + Called when there is a chance of getting channel list from the server in next few lines of response + @type listStart: C{str} + """ + + def gotChannelList(self, channel, usersCount, topic): + """ + Called when we get one channel list from the server + @type channel: C{str} + @type usersCount: C{int} + @type topic: C{str} + """ + + + def channelListEnd(self, endOfList): + """ + Called when channel list ends. + @type endOfList: C[{str}] + """ + + ### Things I observe other people doing in a channel. def userJoined(self, user, channel): @@ -1703,6 +1726,26 @@ """ self.sendLine("QUIT :%s" % message) + + def channelList(self, channel=None, target=None): + """ + The list command is used to list channels and their topics. + @type channel: C{str}, str is a comma separated list of channels like "#foo,#bar" + @param channel: If the channel parameter is used, only the status of those channels 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: + channel = channel.replace(' ', '') #replacing any spaces in the channel-names + self.sendLine("LIST %s" % (channel,)) + else: + self.sendLine("LIST") + + ### user input commands, client->client def describe(self, channel, action): @@ -2073,6 +2116,31 @@ def irc_RPL_LUSERME(self, prefix, params): self.luserMe(params[1]) + + def irc_RPL_LISTSTART(self, prefix, params): + """ + Called when we get an intimation from the server, that it's about to send RPL_LIST + """ + del params[0] + firstLine = "\t".join(params) + self.channelListStart(firstLine) + + + def irc_RPL_LIST(self, prefix, params): + """ + Called when we get LIST of channels from the server, output of LIST Command + """ + self.gotChannelList(params[1], int(params[2]), params[3] ) + + + def irc_RPL_LISTEND(self, prefix, params): + """ + Called when output of /LIST ends + """ + del params[0] + self.channelListEnd(params) + + def irc_unknown(self, prefix, command, params): pass Index: twisted/words/topfiles/4929.feature =================================================================== --- twisted/words/topfiles/4929.feature (revision 0) +++ twisted/words/topfiles/4929.feature (working copy) @@ -0,0 +1 @@ +twisted.words.protocols.irc.IRCClient provides a function for LIST command \ No newline at end of file