我的推特回复在原始状态后没有出现

My twitter reply doesnt appear after original status

我制作了一个机器人,每当他们用关键词给我打电话时都会回复他们。但是回复只出现在我的帐户上。收到回复的人未看到回复或收到通知

import tweepy
import random
import time

CONSUMER_KEY = 'xxxxx'
CONSUMER_SECRET = 'xxxxx'
ACCESS_KEY = 'xx-xx'
ACCESS_SECRET = 'xxxx'

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)

max_tweets = 20

list_delirio = ['coisa escrita', 'yes']

list_isso = ['ok', 'nope']

list_acabou = ['bye', 'see you']

delirio = random.choice(list_delirio)
isso = random.choice(list_isso)
acabou = random.choice(list_acabou)


def get_id():
    with open('ultimoid.txt', 'r') as f:
        ultimoid = f.read()
    return ultimoid


def salva_id(novo_ultimo_id):
    with open('ultimoid.txt', 'w') as f:
        f.write(str(novo_ultimo_id))


def responde():
    ultimoid = get_id()
    ids_pegos = []
    time.sleep(20)
    try:
        for tweet in tweepy.Cursor(api.mentions_timeline, since_id=ultimoid).items(max_tweets):
            ids_pegos.append(tweet.id)
            user_name = tweet.user.screen_name
            status = api.get_status(tweet.id)
            if 'frota' in status.text.lower():
                api.update_status('@' + user_name + '\n hello...', in_reply_to_status_id=tweet.id, auto_populate_reply_metadata=True)
            elif 'hello' in status.text.lower():
                api.update_status('@' + user_name + '\n wtf!', in_reply_to_status_id=tweet.id, auto_populate_reply_metadata=True)
            elif 'delírio' in status.text.lower():
                api.update_status('@' + user_name + '\n' + delirio, in_reply_to_status_id=tweet.id, auto_populate_reply_metadata=True)
            elif 'é isso?' in status.text.lower():
                api.update_status('@' + user_name + '\n' + isso, in_reply_to_status_id=tweet.id, auto_populate_reply_metadata=True)
                time.sleep(6)
            else:
                api.update_status('@' + user_name + '\n' + acabou, in_reply_to_status_id=tweet.id, auto_populate_reply_metadata=True)
                time.sleep(6)
        salva_id(max(ids_pegos))
    except Exception:
        time.sleep(30)
        pass


if __name__ == '__main__':
    while True:
        responde()
        time.sleep(30)

我正在尝试了解问题所在。我已经放了

in_reply_to_status_id=tweet.id, auto_populate_reply_metadata=True

如文档所述,但仍然无法正常工作

我找到了解决方案:

status = api.get_status(tweet.id) 不应该存在。所以每个 status.text.lower() 应该是 tweet.text.lower()

但是 最重要的,代码必须使用字符串而不是 Id 上的整数,所以每个 tweet.id 保持

tweet.id_str

因此将 salva_id(max(ids_pegos)) 更改为 salva_id(ids_pegos[0])