我在github上找到了此reddit bot代码,它实际上只是一个注释bot。
https://github.com/yashar1/reddit-comment-bot
我对Python一无所知,所以我试图对代码医生进行多个子列表和关键字,并添加以下内容:
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的了解有限。我希望机器人扫描多个子列表并搜索多个关键字。
谢谢。
您可以包含多个so. so。
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():