Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Twisted IRC bot密钥错误_Python_Twisted_Bots_Irc - Fatal编程技术网

Python Twisted IRC bot密钥错误

Python Twisted IRC bot密钥错误,python,twisted,bots,irc,Python,Twisted,Bots,Irc,我试图让机器人上的反垃圾邮件工作,但当有人垃圾邮件时,我不断遇到以下错误 Exception in thread Thread-249: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 505, in run

我试图让机器人上的反垃圾邮件工作,但当有人垃圾邮件时,我不断遇到以下错误

Exception in thread Thread-249:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/ircbot/ftb/system/irc.py", line 455, in privmsg
    difference = msg_time - self.chanlist[channel][user]["last_time"]
KeyError: 'last_time'
这是反垃圾邮件的代码

if self.use_antispam:
            msg_time = float(time.time())
            if not ((authorized) or self.is_voice(user, channel)) and channel.startswith("#"):
                difference = msg_time - self.chanlist[channel][user]["last_time"]
                if difference < 0.15:
                    # User is a dirty spammer!
                    if self.is_op(channel, self.nickname):
                        if not user in self.kicked:
                            self.sendLine("KICK %s %s :%s is a dirty spammer!" % (channel, user, user))
                            self.logs.warn("Kicked %s from %s for spamming." % (user, channel))
                            self.kicked.append(user)
                            return

                        else:
                            self.sendLine(
                                "MODE %s +bbb *!%s@* %s!*@* *!*@%s" % (
                                    channel, userhost.split("@")[0].split("!")[1], user, userhost.split("@")[1]))
                            self.sendLine("KICK %s %s :%s is a dirty spammer!" % (channel, user, user))
                            self.logs.warn(" Banned %s from %s for spamming." % (user, channel))
                            return

非常感谢您的帮助

您是否打印了self.chanlist[channel][user]以查看有什么内容?如果该值间歇性丢失,请使用self.chanlist[channel][user]。getlast_time@Padraic坎宁安似乎解决了我的问题,谢谢:不用担心,不客气。