在带有 PRAW 的机器人回复中包括上面评论的用户名
Including the username of comment above in reply by bot with PRAW
我正在用 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)
但是,这不起作用,它只是像预期的那样以文本形式回复。是否可以回复评论的用户名,然后再回复更多文字?
您可以通过
获取作者作为评论对象的字符串
str(comment.author)
我正在用 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)
但是,这不起作用,它只是像预期的那样以文本形式回复。是否可以回复评论的用户名,然后再回复更多文字?
您可以通过
获取作者作为评论对象的字符串str(comment.author)