Python 如何向此reddit bot代码添加更多子reddit/关键字?
我在GitHub上发现了这个reddit机器人代码,它实际上只是一个注释机器人 我对Python知之甚少,因此我尝试修改代码,使其具有多个子项和关键字,并添加了以下内容:Python 如何向此reddit bot代码添加更多子reddit/关键字?,python,bots,reddit,Python,Bots,Reddit,我在GitHub上发现了这个reddit机器人代码,它实际上只是一个注释机器人 我对Python知之甚少,因此我尝试修改代码,使其具有多个子项和关键字,并添加了以下内容: keywords = ["hello", "okay"] subreddits = ["test", "bottest"] for comment in r.subreddit(any(subreddits)).comments(limit=100): if any(keywords) in comm
keywords = ["hello", "okay"]
subreddits = ["test", "bottest"]
for comment in r.subreddit(any(subreddits)).comments(limit=100):
if any(keywords) in comment.body and comment.id not in comments_replied_to
and comment.author != r.user.me():
这段代码似乎不起作用,主要是因为我对Python的知识有限。我想让机器人扫描多个子网站,搜索多个关键字
谢谢。您可以像这样包含多个子项
subreddits_list = "test+bottest"
subreddits = r.subreddit(subreddits_list)
要检查多个关键字,可以使用
keywords = ["hello", "okay"]
for comment in subreddits.comments(limit=100):
for keyword in keywords:
if keyword in comment.body and comment.id not in comments_replied_to and comment.author != r.user.me():