2016-05-09 64 views
0

我的應用程序(Python3 + Tweepy)找到一個hashtag並轉發它。 由於轉發了自己的推文,我收到了「此狀態不允許轉推」錯誤。篩選出自己的轉推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

像這樣的工作。

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

希望它有幫助。