Minor refactor
This commit is contained in:
parent
42ee67a107
commit
e2c26d5b46
@ -165,7 +165,7 @@ class YandereBot:
|
|||||||
# Return a list of hashes with profiles
|
# Return a list of hashes with profiles
|
||||||
try:
|
try:
|
||||||
for f in self.settings_behavior["master_list"]:
|
for f in self.settings_behavior["master_list"]:
|
||||||
add_list = get_list_of_hashes_with_profiles(f, self.settings_post, self.settings_post_default, get_profile)
|
add_list = get_list_of_hashes_with_profiles(f, self.settings_post, self.settings_post_default)
|
||||||
list_pictures.extend(add_list)
|
list_pictures.extend(add_list)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print(e)
|
print(e)
|
||||||
@ -325,6 +325,8 @@ class YandereBot:
|
|||||||
|
|
||||||
# [BEGIN THE PROGRAM]
|
# [BEGIN THE PROGRAM]
|
||||||
def prime_bot(self):
|
def prime_bot(self):
|
||||||
|
if self.primed:
|
||||||
|
return
|
||||||
self.load_picture_list()
|
self.load_picture_list()
|
||||||
self.validate_post_settings()
|
self.validate_post_settings()
|
||||||
if not self.debug_mode:
|
if not self.debug_mode:
|
||||||
@ -332,10 +334,8 @@ class YandereBot:
|
|||||||
self.login()
|
self.login()
|
||||||
self.primed = True
|
self.primed = True
|
||||||
|
|
||||||
def start(self, delay=0):
|
def start(self):
|
||||||
# Prime bot if not already primed.
|
self.prime_bot()
|
||||||
if not self.primed:
|
|
||||||
self.prime_bot()
|
|
||||||
|
|
||||||
# Begin posting
|
# Begin posting
|
||||||
self.main_loop()
|
self.main_loop()
|
||||||
@ -380,16 +380,11 @@ def get_profile(hash_obj, profiles, profiles_default):
|
|||||||
# @param profiles List of profiles -> self.settings_post
|
# @param profiles List of profiles -> self.settings_post
|
||||||
# @param profiles_default The default profile to apply
|
# @param profiles_default The default profile to apply
|
||||||
# @param callback_get_profile Callback function -> should return a single profile. Default: get_profile()
|
# @param callback_get_profile Callback function -> should return a single profile. Default: get_profile()
|
||||||
def get_list_of_hashes_with_profiles(f_name, profiles, profiles_default, callback_get_profile):
|
def get_list_of_hashes_with_profiles(f_name, profiles, profile_default):
|
||||||
r = []
|
r = []
|
||||||
with open(f_name, "r") as f:
|
for item in yanlib.get_hash_list(f_name):
|
||||||
for _line in f:
|
post_setting = get_profile(item, profiles, profile_default)
|
||||||
line = _line.strip()
|
r.append(YanBotHash(item, post_setting))
|
||||||
if not yanlib.is_valid_hash(line):
|
|
||||||
continue
|
|
||||||
hash_obj = yanlib.HashObject(line)
|
|
||||||
post_setting = callback_get_profile(hash_obj, profiles, profiles_default)
|
|
||||||
r.append(YanBotHash(hash_obj, post_setting))
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user