How to use Twisted to get an IRC channel's user list

后端 未结 1 1499
时光说笑
时光说笑 2021-01-13 04:26

I\'m trying to get channel\'s user list using {{self.say(channel, \"WHO\",100)}}. How can I get the response? Which method I should override?

相关标签:
1条回答
  • 2021-01-13 04:47

    Here are some additional methods which should help you get further along. You handle a given reply RPL_NAME by defining a method irc_RPL_NAME. So for RPL_WHOREPLY you define irc_WHOREPLY:

        def who(self, channel):
            "List the users in 'channel', usage: client.who('#testroom')"
            self.sendLine('WHO %s' % channel)
    
        def irc_RPL_WHOREPLY(self, *nargs):
            "Receive WHO reply from server"
            print 'WHO:', nargs
    
        def irc_RPL_ENDOFWHO(self, *nargs):
            "Called when WHO output is complete"
            print 'WHO COMPLETE'
    
        def irc_unknown(self, prefix, command, params):
            "Print all unhandled replies, for debugging."
            print 'UNKNOWN:', prefix, command, params
    
    0 讨论(0)
提交回复
热议问题