我用三个if语句来搜索我提到的三个特定短语。有些时候会找到匹配项,但大多数时候会被忽略。你知道吗
我看不到任何不合适的地方。当我对另一个Twitter帐户使用类似的代码来搜索不同的短语时,总会找到匹配的短语。你知道吗
下面是搜索提及和回复的python代码。如果剩下的是上下文需要让我知道,这样我可以编辑我的问题。你知道吗
def reply_to_tweets():
print('retrieving and replying to tweets...')
last_seen_id = retrieve_last_seen_id(file_name)
mentions = api.mentions_timeline(last_seen_id, tweet_mode='extended')
for mention in reversed(mentions):
print(str(mention.id) + ' - ' + mention.full_text)
last_seen_id = mention.id
store_last_seen_id(last_seen_id, file_name)
if 'that\'s a million bucks' in mention.full_text.lower():
print('replying about AirMiles')
api.update_status('@' + mention.user.screen_name + ' Just swipe your AirMiles card to enter.', mention.id)
if 'fruit is always so fresh' in mention.full_text.lower():
print('replying about shopping')
api.update_status('@' + mention.user.screen_name + ' Cassie, are you shopping?', mention.id)
if 'i play to win gord' in mention.full_text.lower():
print('replying about Sobeys and Safeway')
api.update_status('@' + mention.user.screen_name + ' And that\'s why it pays to shop at Sobeys and Safeway.', mention.id)
当有人用在tweet@my account上留言时,那是一百万美元我希望python用回复,只要刷你的air miles卡就可以了。这种情况偶尔会发生,但通常不会
当有人推特@my account with水果总是那么新鲜我希望python回复卡西,你在购物吗?这种情况偶尔会发生,但通常不会
当有人推特@my account with时,我玩游戏就是为了赢戈尔。我希望python会回复,这就是为什么它需要与Sobeys和Safeway一起购物。这种情况偶尔会发生,但通常不会
目前没有回答
相关问题 更多 >
编程相关推荐