过滤掉自己的转发Tweepy

时间:2016-05-09 13:16:15

标签: python-3.x twitter tweepy

我的应用程序(Python3 + Tweepy)找到一个标签并转发它。 由于转发自己的推文,我得到“转发此状态不允许转发”错误。

如何过滤掉?

# retweet function
def hashtag_Retweet():    
    print (tweet.id)   
    api.retweet(tweet.id) # retweet
    print(tweet.text)
    return

query = '#foosball'
our_own_id = '3678887154' #Made up for this post
tweets = api.search(query)
for tweet in tweets:
# make sure that tweet does not come from host    
    hashtag_Retweet()

1 个答案:

答案 0 :(得分:1)

这样的事情会起作用。

for tweet in tweets:
    if tweet.user.id != our_own_id:     
        hashtag_Retweet()

希望它有所帮助。