我正在嘗試使用twisted.words.protocols.irc模塊制作一個IRC機器人。機器人將解析來自通道的消息并解析它們以獲取命令字符串。一切正常,除非我需要機器人通過發送whois命令來識別昵稱。在privmsg方法(我正在從中進行解析的方法)返回之前,不會處理whois答復。例子:from twisted.words.protocols import ircclass MyBot(irc.IRClient):.......... def privmsg(self, user, channel, msg): """This method is called when the client recieves a message""" if msg.startswith(':whois '): nick = msg.split()[1] self.whois(nick) print(self.whoislist) def irc_RPL_WHOISCHANNELS(self, prefix, params): """This method is called when the client recieves a reply for whois""" self.whoislist[prefix] = params有什么辦法可以使機器人在self.whois(nick)之后等待回復嗎?也許使用線程(我對此沒有任何經驗)。
添加回答
舉報
0/150
提交
取消