Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/362.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 Bot导致claimer.py中出现双post_Python - Fatal编程技术网

Python Bot导致claimer.py中出现双post

Python Bot导致claimer.py中出现双post,python,Python,在我的机器人上,我一直在使用claim命令,但它一直让机器人在def claimer中双重发布两条消息。代码如下: def claimer(user, name, room): if user.lower() == name.lower(): room.message("Pfft. You can't catch yourself.") elif name.lower() not in room.usernames: room.message

在我的机器人上,我一直在使用claim命令,但它一直让机器人在def claimer中双重发布两条消息。代码如下:

   def claimer(user, name, room):
     if user.lower() == name.lower():
       room.message("Pfft. You can't catch yourself.")
     elif name.lower() not in room.usernames:
       room.message("You can't capture %s they are not here." % name.title())
     else:
       if not user in claim.claimDB:
         claim.claimDB[user] = []
       num = len(claim.claimDB[user])
       if claim.limit(num) == True:
         room.message("You have reached your limit on captures %s. You must release some people in order to catch %s" % (user.title(), name.title()))
       else:
         for a, b in claim.claimDB.items():
           if name.lower() in b:
             room.message("%s has already been caught by %s." % (name.title(), a.title())) 
           else:
             escapechance = random.choice([True,True,True,False])
             if escapechance == True:
               claim.claimDB[user] = claim.claimDB[user]+[name]
               room.message("//Pokeball wiggles three times before stopping// You have successfully captured %s! \o/" % name.title()) <----this message.
             else:
                room.message("Failed to capture them")<----- this one too at the same time.
def claimer(用户、姓名、房间):
如果user.lower()==name.lower():
房间信息(“Pfft,你抓不住自己。”)
elif name.lower()不在文件室中。用户名:
文件室消息(“您无法捕获%s,因为它们不在这里。”%name.title()
其他:
如果不是claim.claimDB中的用户:
claim.claimDB[user]=[]
num=len(claim.claimDB[用户])
如果索赔限额(num)=真:
room.message(“您已达到捕获%s的限制。您必须释放一些人才能捕获%s”%(user.title(),name.title()))
其他:
对于索赔.claimDB.items()中的a、b:
如果b中有name.lower():
文件室消息(“%s已被%s捕获”。”%(name.title(),a.title())
其他:
escapechance=random.choice([True,True,True,False])
如果escapechance==真:
claim.claimDB[user]=claim.claimDB[user]+[name]

room.message(“//Pokeball在停止前摆动三次//您已成功捕获%s!\o/%name.title())您的行,该行追加
name
(应使用
list.append()
)追加
name
,而不是
name.lower()
<代码>'foo'
不在
['foo']
中。我对此有点困惑。你的意思是什么?
claim.claimDB[user]=claim.claimDB[user]+[name]
噢,所以我应该用.append(name.lower())来代替+[name],还是用+[name.lower()]?第一个最好。或者将b:中的
if name.lower()更改为b:
中的
if name。