0

我正在用 PRAW 开发一个 Reddit 机器人,我想在它的回复中包含机器人正在回复的人的用户名。

for comment in comments:
    comment_text = comment.body.lower()
    isMatch = any(string in comment_text for string in words_to_match)
    if comment.id not in cache and isMatch:
        print("Comment match found;" + comment.id)
        comment.reply('Hello + author.name')
        print("Reply successful!")
        cache.append(comment.id)

但是,这不起作用,它只是像预期的那样以文本形式回复。是否可以使用评论的用户名进行回复,然后再添加更多文字?

4

1 回答 1

0

您可以通过以下方式获取作者作为评论对象的字符串

str(comment.author)
于 2015-05-17T20:33:27.510 回答