如何解决在推文中检查ID tweepy bot时回复帐户
我想让一个机器人检查Twitter的个人资料,以便在发推文时立即回答他们。 我已经做到了,但是我只能将已经发布的推文发送到垃圾邮件,而且我不知道如何检查它是否发布了新推文并回复该新推文。我需要知道如何处理推文的ID,以便选择最近发布过的推文。
import tweepy as tp
import time
import os
import keys
# credentials to login to twitter api
consumer_key = keys.c_k
consumer_secret = keys.c_s
access_token = keys.a_t
access_secret = keys.a_s
# login to twitter account api
auth = tp.OAuthHandler(consumer_key,consumer_secret)
auth.set_access_token(access_token,access_secret)
api = tp.API(auth)
#twit
def mainthing():
toReply = #Screen name of the user
text = "hola"
tweets = api.user_timeline(screen_name = toReply,count=1)
while True:
for tweet in api.user_timeline(toReply):
api.update_status('@' + toReply + ' ' + text,in_reply_to_status_id = tweet.id)
#main-------------------------------------------------
mainthing()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。