booster- twitter bot that builds followers |
git clone git://git.acid.vegas/booster.git |
Log | Files | Refs | Archive | README | LICENSE |
booster.py (5203B)
1 #!/usr/bin/env python 2 # Booster Twitter Bot - Developed by acidvegas in Python (https://acid.vegas/booster) 3 # booster.py 4 5 import random 6 import threading 7 import time 8 import sys 9 10 sys.dont_write_bytecode = True 11 12 import config 13 14 class Booster(object): 15 def __init__(self): 16 self.api = None 17 self.me = None 18 19 def run(self): 20 self.login() 21 self.stats() 22 threading.Thread(target=self.loop_boost).start() 23 threading.Thread(target=self.loop_favorite).start() 24 threading.Thread(target=self.loop_follow).start() 25 threading.Thread(target=self.loop_search).start() 26 threading.Thread(target=self.loop_trend).start() 27 28 def login(self): 29 try: 30 auth = tweepy.OAuthHandler(config.api.consumer_key, config.api.consumer_secret) 31 auth.set_access_token(config.api.access_token, config.api.access_token_secret) 32 self.api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True) 33 self.me = self.api.me() 34 except tweepy.TweepError as ex: 35 raise SystemExit(f'Failed to login to Twitter! ({ex!s})') 36 37 def loop_boost(self): 38 while True: 39 try: 40 if 'boost_tweet' in locals(): 41 self.api.destroy_status(boost_tweet.id) 42 boost_tweet = self.api.update_status('RT for followers! #' + ' #'.join(random.sample(config.settings.keywords, len(config.settings.keywords)))) 43 print('[+] - Reposted boost tweet.') 44 except tweepy.TweepError as ex: 45 print(f'[!] - Error occured in the boost loop ({ex!s})') 46 finally: 47 time.sleep(60*5) 48 49 def loop_favorite(self): 50 while True: 51 try: 52 for tweet in tweepy.Cursor(self.api.home_timeline, exclude_replies=True).items(50): 53 if tweet.user.screen_name != self.me.screen_name: 54 if not tweet.favorited: 55 if random.choice((True, False, False, False, False)): 56 self.api.create_favorite(tweet.id) 57 print('[+] - Favorited a friends tweet!') 58 time.sleep(60*60) 59 except tweepy.TweepError as ex: 60 print(f'[!] - Error occured in the favorite loop! ({ex!s})') 61 finally: 62 time.sleep(60*15) 63 64 def loop_follow(self): 65 while True: 66 try: 67 followers = self.api.followers_ids(self.me.screen_name) 68 friends = self.api.friends_ids(self.me.screen_name) 69 non_friends = [friend for friend in followers if friend not in friends] 70 print(f'[~] - Following back {len(non_friends)} supporters...') 71 for follower in non_friends: 72 self.api.create_friendship(follower) 73 print('[+] - Followed back a follower!') 74 if config.settings.message: 75 self.api.send_direct_message(screen_name=follower, text=self.message) 76 time.sleep(60*60) 77 except tweepy.TweepError as ex: 78 print(f'[!] - Error occured in the follow loop! ({ex!s})') 79 finally: 80 time.sleep(60*15) 81 82 def loop_search(self): 83 while True: 84 try: 85 query = random.choice(config.settings.keywords) 86 for item in self.api.search(q='#' + query, count=50, lang='en', result_type='recent'): 87 if not item.user.following and not item.favorited: 88 try: 89 self.api.create_favorite(item.id) 90 self.api.create_friendship(item.user.screen_name) 91 print('[+] - Followed a booster twitter!') 92 except tweepy.TweepError as ex: 93 print('[!] - Unknown error occured in the search loop! ({ex!s})') 94 time.sleep(60*60) 95 except tweepy.TweepError as ex: 96 debug.error('Error occured in the search loop!', ex) 97 finally: 98 time.sleep(60*15) 99 100 def loop_trend(self): 101 while True: 102 try: 103 trends = self.api.trends_place(str(config.settings.woeid)) 104 hashtags = [x['name'] for x in trends[0]['trends'] if x['name'].startswith('#')] 105 for trend in hashtags: 106 for item in self.api.search(q=trend, count=5, lang='en', result_type='top'): 107 self.api.update_status(item.tweet) 108 time.sleep(60*60) 109 except tweepy.TweepError as ex: 110 print('[!] - Error occured in the trend loop! ({ex!s})') 111 finally: 112 time.sleep(60*15) 113 114 def loop_unfollow(self): 115 try: 116 followers = self.api.followers_ids(self.me.screen_name) 117 friends = self.api.friends_ids(self.me.screen_name) 118 non_friends = [friend for friend in friends if friend not in followers] 119 non_friends.reverse() 120 print(f'[~] - Unfollowing {len(non_friends)} unsupporting friends...') 121 for friend in non_friends: 122 self.api.destroy_friendship(friend) 123 print('[+] - Unfollowed an unsupporting friend!') 124 time.sleep(60*30) 125 except tweepy.TweepError as ex: 126 debug.error('Error occured in the unfollow loop!', ex) 127 128 def stats(self): 129 print('[~] - SceenName : ' + self.me.screen_name) 130 print('[~] - Registered : ' + self.me.created_at) 131 print('[~] - Favorites : ' + self.me.favourites_count) 132 print('[~] - Following : ' + self.me.friends_count) 133 print('[~] - Followers : ' + self.me.followers_count) 134 print('[~] - Tweets : ' + self.me.statuses_count) 135 136 # Main 137 print('#'*56) 138 print('#{:^54}#'.format('')) 139 print('#{:^54}#'.format('Booster Twitter Bot')) 140 print('#{:^54}#'.format('Developed by acidvegas in Python')) 141 print('#{:^54}#'.format('https://acid.vegas/booster')) 142 print('#{:^54}#'.format('')) 143 print('#'*56) 144 try: 145 import tweepy 146 except ImportError: 147 raise SystemExit('Failed to import the Tweepy library! (http://pypi.python.org/pypi/tweepy)') 148 BOOSTER = Booster() 149 BOOSTER.run() 150 while True:input('')