编写 Reddit 自动机器人代码,不评论列表的所有部分

Writing Reddit Automatic Bot code, Not commenting all parts of a list

所以我正在为我在 python 中主持的 subreddit 编写一个机器人。 Bot 能够执行,并且能够正确回复评论,除了它只回复列表的最后一部分。(评论是给使用该子程序的其他人的)。代码还没有完成,到目前为止我只为一个地区完成了代码,但除了那一部分之外一切似乎都有效。请你告诉我我应该怎么做。

示例:

评论: u/crazy_angel1:automaester raven north 回复: u/AutoMaesterGOT:u/CptAwsome12345

代码:

import time
#importing time module
import praw
#importing the thing that allows you to run all the code, if you want to run this on your own computer, you will need to install it, look for a tutorial on how to install PRAW online
reddit = praw.Reddit(client_id='redacted',
                     username='AutoMaesterGOT',
                     client_secret='redacted',
                     password='redacted',
                     user_agent='It is a script that messages people every time a certain phrase is passed in my subreddit. Created by /u/crazy_angel1')
print("logging in...")
print(reddit.user.me())
#singing on to the bot with OAuth, again look up online if you want to use it

WordCalls=['AUTOMAESTER RAVEN NORTH', 'AUTOMAESTER RAVEN CROWNLANDS', 'AUTOMAESTER RAVEN CROWNLANDS','AUTOMAESTER RAVEN WESTERLANDS', 'AUTOMAESTER RAVEN DORNE','AUTOMAESTER RAVEN VALE','AUTOMAESTER REACH', 'AUTOMAESTER RAVEN IRON ISLANDS']
#the terms that will call the bot
CommentCache=[]
#storing comments already sorted through
NorthMembers=['u/crazy_angel1','u/StraightOuttaNYC','u/jgames2000','u/CptAwsome12345']

def BOTRUN(): #the bots main code for North
    subreddit = reddit.subreddit('StormOfSwordsRP')#connecting to the subreddit
    comments = subreddit.stream.comments()#sorting through comments
    for comment in comments:
        comment_body = comment.body#storing each individual comment
        comment_body = comment_body.upper()#making every comment uppercase
        isMatch = any(string in comment_body for string in WordCalls)#setting conditions for calling bot 
        if isMatch and comment.id not in CommentCache:#checking if anybody has called bot and it hasnt already been replied to yet
            print("match found, comment id" +comment.id)
            comment.reply(NorthMembers)#calling North members
            CommentCache.append(comment.id)#adding the comment id to the cache
            print("reply succesful")

while True: #infinite loop
    BOTRUN()# executing bot
    time.sleep(10)

很明显,reddit 不喜欢列表,所以如果您尝试正常回复列表,它就无法正常工作。所以而不是行

Comment.reply(北方成员)

您将要使用以下行:

Comment.reply(‘‘.join (NorthMembers))

感谢@xay 的帮助