-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
31 lines (23 loc) · 819 Bytes
/
bot.py
File metadata and controls
31 lines (23 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import tweepy
consumer_key = ''
consumer_secret = ''
access_token = ''
access_secret = ''
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
api = tweepy.API(auth)
mentions = api.mentions_timeline()
for mention in mentions:
#print(str(mention.id + ' \t ' + mention.text))
#print('{} {}'.format(mention.id, mention.text))
if 'helloworld' in mention.text.lower():
print('{} {}'.format(mention.id, mention.text))
try:
api.update_status('@' + mention.user.screen_name +
'#helloworld back to you', mention.id)
print('replied to {}'.format(mention.user.screen_name))
except tweepy.TweepError:
pass
#print('found helloworld')
else:
break