如何使用 Twisted 获取 IRC 频道的用户列表 [英] How to use Twisted to get an IRC channel's user list
本文介绍了如何使用 Twisted 获取 IRC 频道的用户列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 {{self.say(channel, "WHO",100)}}
获取频道的用户列表.我怎样才能得到回应?我应该覆盖哪个方法?
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?
推荐答案
这里有一些额外的方法,可以帮助你更进一步.您可以通过定义方法 irc_RPL_NAME
来处理给定的回复 RPL_NAME
.所以对于 RPL_WHOREPLY
你定义 irc_WHOREPLY
:
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
这篇关于如何使用 Twisted 获取 IRC 频道的用户列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文