tweepy api的新手。
我在这里使用github脚本:https://github.com/twitterdev/sample-python-autoreply
if retweeted is not None and not retweeted and not from_self:
tweetId = tweet.get('id_str')
screenName = tweet.get('user',{}).get('screen_name')
tweetText = tweet.get('text')
chatResponse = chatbot.respond(tweetText)
replyText = '@' + screenName + ' ' + chatResponse
#check if repsonse is over 140 char
if len(replyText) > 140:
replyText = replyText[0:139] + '…'
print('Tweet ID: ' + tweetId)
print('From: ' + screenName)
print('Tweet Text: ' + tweetText)
print('Reply Text: ' + replyText)
# If rate limited, the status posts should be queued up and sent on an interval
twitterApi.update_status(status=replyText, in_reply_to_status_id=tweetId)
def on_error(self, status):
print status
我设法让它工作但它似乎无限回应自己。有没有办法限制这个?或者修复它以便它不回复自己?我假设它只检查@botusername并回复那些推文。其余的代码在github链接中可用(它的autoreply.py)。