1 回答

TA貢獻(xiàn)1825條經(jīng)驗(yàn) 獲得超6個(gè)贊
您可以添加條件以僅直接從
follow
id 響應(yīng)推文。這應(yīng)該只允許對(duì)所關(guān)注的帳戶做出響應(yīng)。
tweetId
因此,在這種情況下,僅當(dāng)關(guān)注的帳戶回復(fù)時(shí)才會(huì)回復(fù)。對(duì)于多個(gè)用戶,測(cè)試包含
in
:if user_id in [25073877, id2, id3,...]:
class StdOutListener(StreamListener):
def on_data(self, data):
clean_data = json.loads(data)
tweetId = clean_data["id"]
user_id = clean_data['user']['id']
tweet = 'Trying to figure out this code to answer a question on SO, just ignore this'
if user_id == 25073877:
print('Tweeting a reply now') # optional
respondToTweet(tweet, tweetId)
添加回答
舉報(bào)