2017-07-28 36 views
0

我試圖讓每次有人提到一個字符串時都會增加一個數字的bot。到目前爲止,我只能讓它增加一次,而其他答覆都保持在同一個數字。它在2017年宣佈,但只會在2018年找到字符串時回覆。我知道它很小但我不知道,但我不知道。reddit python bot中增加的數字回覆

for comment in r.subreddit('test').comments(limit = 500): 
     mentions = 2017  
     if "string" in comment.body and comment.id not in comments_replied_to and comment.author != r.user.me(): 
      mentions +=1 
      print ("string found!") and comment.id 
      comment.reply(" delayed until year" + str(mentions)) 
      print("replied to comment") 

回答

0

你聲明mentions的循環體,這意味着它會被設置爲2017在每個迭代上。

另外,print ("string found!") and comment.id應該可能是print("string found!", comment.id)

+0

啊好吧我看到我不知道我怎麼錯過了。謝謝,雖然這解決了它 – bills

+0

如果只是這樣,你可能想要接受其中一個答案。 – SwiftsNamesake

0

聲明提到裏面的循環,而不是外面,它修復了問題