1
mirror of git://git.acid.vegas/booster.git synced 2024-11-22 15:56:37 +00:00

minor update to prepair for major cleanup

This commit is contained in:
Dionysus 2019-08-02 02:56:47 -04:00
parent 624276b818
commit d9f8aa3cce
No known key found for this signature in database
GPG Key ID: 05114B46832BDBDB
5 changed files with 190 additions and 215 deletions

View File

@ -1,8 +1,8 @@
###### Requirments ## Requirments
* [Tweepy](http://pypi.python.org/pypi/tweepy) - [Tweepy](http://pypi.python.org/pypi/tweepy)
###### Instructions ## Instructions
Register a Twitter account, and [sign up](http://dev.twitter.com/apps/new) for a new developer application. Create a Twitter account & [sign up](http://dev.twitter.com/apps/new) for a new developer application.
Go to your new application settings "Keys and Access Tokens" tab. Go to your new application settings "Keys and Access Tokens" tab.
@ -16,7 +16,7 @@ Change your access to "Read, Write and Access direct messages".
Edit your `config.py` and change the Twitter API settings. Edit your `config.py` and change the Twitter API settings.
###### Mirrors ## Mirrors
- [acid.vegas](https://acid.vegas/booster) *(main)* - [acid.vegas](https://acid.vegas/booster) *(main)*
- [SuperNETs](https://git.supernets.org/acidvegas/booster) - [SuperNETs](https://git.supernets.org/acidvegas/booster)
- [GitHub](https://github.com/acidvegas/booster) - [GitHub](https://github.com/acidvegas/booster)

View File

@ -10,14 +10,13 @@ import time
import config import config
def action(msg): def action(msg):
print('%s | [#] - %s' % (get_time(), msg)) print(f'{get_time()} | [#] - {msg}')
def alert(msg): def alert(msg):
print('%s | [+] - %s' % (get_time(), msg)) print(f'{get_time()} | [+] - {msg}')
def check_config(): def check_config():
for item in (config.consumer_key, config.consumer_secret, config.access_token, config.access_token_secret): if 'CHANGEME' in (config.consumer_key, config.consumer_secret, config.access_token, config.access_token_secret):
if item == 'CHANGEME':
error_exit('Edit your config file!') error_exit('Edit your config file!')
def check_imports(): def check_imports():
@ -28,63 +27,41 @@ def check_imports():
def check_privileges(): def check_privileges():
if check_windows(): if check_windows():
if ctypes.windll.shell32.IsUserAnAdmin() != 0: return True if ctypes.windll.shell32.IsUserAnAdmin() != 0 else return False
return True
else: else:
return False return True if os.getuid() == 0 or os.geteuid() == 0 else return False
else:
if os.getuid() == 0 or os.geteuid() == 0:
return True
else:
return False
def check_version(major): def check_version(major):
if sys.version_info.major == major: return True if sys.version_info.major == major else return False
return True
else:
return False
def check_windows(): def check_windows():
if os.name == 'nt': return True if os.name == 'nt' else return False
return True
else:
return False
def clear(): def clear():
if check_windows(): os.system('cls') if check_windows() else os.system('clear')
os.system('cls')
else:
os.system('clear')
def error(msg, reason=None): def error(msg, reason=None):
if reason: print(f'{get_time()} | [!] - {msg} ({str(reason)})') if reason else print(f'{get_time()} | [!] - {msg}')
print('%s | [!] - %s (%s)' % (get_time(), msg, str(reason)))
else:
print('%s | [!] - %s' % (get_time(), msg))
def error_exit(msg): def error_exit(msg):
raise SystemExit('%s | [!] - %s' % (get_time(), msg)) raise SystemExit(f'{get_time()} | [!] - {msg}')
def get_time(): def get_time():
return time.strftime('%I:%M:%S') return time.strftime('%I:%M:%S')
def get_windows(): def get_windows():
if os.name == 'nt': return True if os.name == 'nt' else False
return True
else:
return False
def info(): def info():
clear() clear()
print(''.rjust(56, '#')) print(''.rjust(56, '#'))
print('#{0}#'.format(''.center(54))) print('#{0}#'.format(''.center(54)))
print('#{0}#'.format('Booster Twitter Bot'.center(54))) print('#{0}#'.format('Booster Twitter Bot'.center(54)))
print('#{0}#'.format('Developed by acidvegas in Python 3'.center(54))) print('#{0}#'.format('Developed by acidvegas in Python'.center(54)))
print('#{0}#'.format('https://acid.vegas/booster'.center(54))) print('#{0}#'.format('https://acid.vegas/booster'.center(54)))
print('#{0}#'.format(''.center(54))) print('#{0}#'.format(''.center(54)))
print(''.rjust(56, '#')) print(''.rjust(56, '#'))
def keep_alive(): def keep_alive():
try: try:
while True: while True:

View File

@ -15,9 +15,7 @@ def get_source(url):
source = urllib.request.urlopen(req, timeout=10) source = urllib.request.urlopen(req, timeout=10)
charset = source.headers.get_content_charset() charset = source.headers.get_content_charset()
if charset: if charset:
return source.read().decode(charset) return source.read().decode(charset) if charset else return source.read().decode()
else:
return source.read().decode()
def random_int(min, max): def random_int(min, max):
return random.randint(min, max) return random.randint(min, max)

View File

@ -35,7 +35,7 @@ class Booster(object):
threading.Thread(target=self.loop_favorite).start() threading.Thread(target=self.loop_favorite).start()
threading.Thread(target=self.loop_follow).start() threading.Thread(target=self.loop_follow).start()
threading.Thread(target=self.loop_search).start() threading.Thread(target=self.loop_search).start()
# threading.Thread(target=self.loop_trend).start() threading.Thread(target=self.loop_trend).start()
def login(self): def login(self):
try: try:
@ -62,11 +62,11 @@ class Booster(object):
def loop_favorite(self): def loop_favorite(self):
while True: while True:
try: try:
for tweet in tweepy.Cursor(api.home_timeline, exclude_replies=True).items(50): for tweet in tweepy.Cursor(self.api.home_timeline, exclude_replies=True).items(50):
if tweet.user.screen_name != me.screen_name: if tweet.user.screen_name != self.me.screen_name:
if not tweet.favorited: if not tweet.favorited:
if random.choice((True, False, False, False, False)): if random.choice((True, False, False, False, False)):
api.create_favorite(tweet.id) self.api.create_favorite(tweet.id)
self.favorites += 1 self.favorites += 1
debug.alert('Favorited a friends tweet!') debug.alert('Favorited a friends tweet!')
time.sleep(30) time.sleep(30)
@ -78,18 +78,18 @@ class Booster(object):
def loop_follow(self): def loop_follow(self):
while True: while True:
try: try:
followers = api.followers_ids(me.screen_name) followers = self.api.followers_ids(self.me.screen_name)
friends = api.friends_ids(me.screen_name) friends = self.api.friends_ids(self.me.screen_name)
non_friends = [friend for friend in followers if friend not in friends] non_friends = [friend for friend in followers if friend not in friends]
debug.action('Following back {0} supporters...'.format(len(non_friends))) debug.action('Following back {0} supporters...'.format(len(non_friends)))
for follower in non_friends: for follower in non_friends:
api.create_friendship(follower) self.api.create_friendship(follower)
self.follows += 1 self.follows += 1
debug.alert('Followed back a follower!') debug.alert('Followed back a follower!')
if self.follows >= self.max_follows: if self.follows >= self.max_follows:
break break
if self.send_message: if self.send_message:
api.send_direct_message(screen_name=follower, text=self.message) self.api.send_direct_message(screen_name=follower, text=self.message)
time.sleep(30) time.sleep(30)
except tweepy.TweepError as ex: except tweepy.TweepError as ex:
debug.error('Error occured in the follow loop!', ex) debug.error('Error occured in the follow loop!', ex)
@ -100,11 +100,11 @@ class Booster(object):
while True: while True:
try: try:
query = random.choice(config.boost_keywords) query = random.choice(config.boost_keywords)
for item in api.search(q='#' + query, count=50, lang='en', result_type='recent'): for item in self.api.search(q='#' + query, count=50, lang='en', result_type='recent'):
if not item.user.following and not item.favorited: if not item.user.following and not item.favorited:
try: try:
api.create_favorite(item.id) self.api.create_favorite(item.id)
api.create_friendship(item.user.screen_name) self.api.create_friendship(item.user.screen_name)
self.favorites += 1 self.favorites += 1
self.follows += 1 self.follows += 1
debug.alert('Followed a booster twitter!') debug.alert('Followed a booster twitter!')
@ -123,7 +123,7 @@ class Booster(object):
hashtags = [x['name'] for x in trends[0]['trends'] if x['name'].startswith('#')] hashtags = [x['name'] for x in trends[0]['trends'] if x['name'].startswith('#')]
for trend in hashtags: for trend in hashtags:
for item in self.api.search(q=trend, count=5, lang='en', result_type='top'): for item in self.api.search(q=trend, count=5, lang='en', result_type='top'):
#self.api.update_status(item.tweet) # FIX THIS PART self.api.update_status(item.tweet)
time.sleep(30) time.sleep(30)
except tweepy.TweepError as ex: except tweepy.TweepError as ex:
debug.error('Error occured in the trend loop!', ex) debug.error('Error occured in the trend loop!', ex)
@ -153,9 +153,9 @@ class Booster(object):
def ratio_check(self): def ratio_check(self):
if self.follows >= max_follows: if self.follows >= max_follows:
time.sleep(86400) time.sleep(86400)
if me.friends_count >= 2000: if self.me.friends_count >= 2000:
ratio = me.friends_count + (me.followers_count/10) ratio = self.me.friends_count + (self.me.followers_count/10)
if me.friends_count >= ratio: if self.me.friends_count >= ratio:
debug.action('Following to follower ratio is off! Starting the unfollow loop...') debug.action('Following to follower ratio is off! Starting the unfollow loop...')
unfollow_loop() unfollow_loop()