File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ import random # random is a python built-in module
2+
3+
4+ def roll_dice ():
5+ dice_side = random .randrange (1 , 7 )
6+ print (dice_side )
7+
8+
9+ if __name__ == '__main__' :
10+ roll_dice ()
Original file line number Diff line number Diff line change 1+ import tweepy # This is a Twitter API helper library.
2+ import time
3+
4+
5+ # You should get the following keys and authentication codes for your Twitter account
6+ # Visit apps.twitter.com
7+ consumer_key = 'consumer_key'
8+ consumer_secret = 'consumer_secret'
9+ access_token = 'access_token'
10+ access_token_secret = 'access_token_secret'
11+
12+
13+ # Twitter requires 0Auth2 authentication. You can readup about this.
14+ auth = tweepy .OAuthHandler (consumer_key , consumer_secret )
15+ auth .set_access_token (access_token , access_token_secret )
16+ api = tweepy .API (auth )
17+
18+
19+ def retweet_bot ():
20+ for tweet in tweepy .Cursor (api .search , q = 'Hashtag to listen for' ).items (10 ):
21+ try :
22+ print ('Twitter user: ' + '@' + tweet .user .screen_name )
23+ tweet .retweet ()
24+ print ('\n Done' )
25+ time .sleep (5 ) # You can remove the time module, if you want the program to continuously retweet
26+ except tweepy .error .TweepError :
27+ pass
28+
29+
30+ if __name__ == '__main__' :
31+ retweet_bot ()
You can’t perform that action at this time.
0 commit comments