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 (将#修改为@)