如何解决Twitter机器人回复
我正在尝试按照此处找到的教程 https://realpython.com/twitter-bot-python-tweepy/#how-to-make-a-twitter-bot-in-python-with-tweepy。我稍微编辑了它以尝试标记其回复的用户。它正在回复推文,但不标记原始用户。我不确定这是否是获取用户名并向用户发送推文的正确方法。
for tweet in tweepy.Cursor(api.mentions_timeline,since_id=since_id).items():
new_since_id = max(tweet.id,new_since_id)
sn = tweet.user.screen_name
if tweet.in_reply_to_status_id is not None:
continue
if any(keyword in tweet.text.lower() for keyword in keywords):
logger.info(f"Answering to {sn}")
if not tweet.user.following:
tweet.user.follow()
m = "@%s new test reply" % (sn)
api.update_status(
m,in_reply_to_status_id=tweet.id
)
return new_since_id
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。