-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtweethack.py
More file actions
45 lines (35 loc) · 1.35 KB
/
tweethack.py
File metadata and controls
45 lines (35 loc) · 1.35 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from twython import Twython
from creds import *
twitter = Twython(APP_KEY, APP_SECRET, FINAL_OAUTH_TOKEN, FINAL_OAUTH_TOKEN_SECRET)
quit = ""
while quit != True:
exit = ""
tos = raw_input("Would you like to tweet, search, or exit? (tweet, search or quit) ")
if tos == "quit":
quit = True
elif tos == "tweet":
print "Let's tweet from the command line!"
while exit != True:
tweet = raw_input("What would you like to tweet? ")
twitter.update_status(status = tweet)
exit = raw_input("Type exit to go back or press enter to Tweet again. ")
if exit == "exit":
exit = True
elif tos == "search":
print "Let's search from the command line!"
while exit != True:
query = raw_input("What would you like to search? ")
result = twitter.search(q=query, result_type='popular')
tweets = result['statuses']
for tweet in tweets:
tweetid = int(tweet['id'])
print tweetid
if "security" in tweet['text']:
twitter.retweet(id = tweetid)
print "retweeted", tweetid
elif "update" in tweet['text']:
twitter.retweet(id = tweetid)
print "retweeted", tweetid
exit = raw_input("Type exit to go back or press enter to search again. ")
if exit == "exit":
exit = True