我正在制作一个Reddit机器人,该机器人将对某些子Reddit进行评论,并回复具有某些关键短语的人。
我本来没有循环,但工作正常,但是每隔几分钟我必须单击一次run。我正在使用PRAW在pythonanywhere.com上运行python脚本。
import praw
import time
SECONDS_PER_MIN = 60
subreddit = reddit.subreddit('memes+dankmemes+comics+funny+pics')
keyphrase = ('Sauce+Sauce?')
def main():
while True:
for comment in subreddit.stream.comments():
if keyphrase in comment.body:
comment.reply('[Here.](https://www.youtube.com/watch?v=dQw4w9WgXcQ)\n\nI am a bot and this action was performed automatically. Learn more at [https://saucebot.com/](https://www.youtube.com/watch?v=dQw4w9WgXcQ)')
print('Posted!')
time.sleep(SECONDS_PER_MIN * 11)
if __name__ == '__main__':
main()
我希望它能每隔10分钟回应一个随机说“调味”的人,但现在不会回应任何人。