Compare commits
3 Commits
b18d2ea20e
...
e2c26d5b46
Author | SHA1 | Date | |
---|---|---|---|
e2c26d5b46 | |||
42ee67a107 | |||
408d766d6d |
7
.gitignore
vendored
7
.gitignore
vendored
@ -2,6 +2,7 @@
|
|||||||
/rsc*/
|
/rsc*/
|
||||||
/md5/
|
/md5/
|
||||||
/src/cfg*.py
|
/src/cfg*.py
|
||||||
|
/log.txt
|
||||||
|
|
||||||
# Virtual environment
|
# Virtual environment
|
||||||
/venv*
|
/venv*
|
||||||
@ -18,8 +19,9 @@
|
|||||||
/notes.txt
|
/notes.txt
|
||||||
/compile.sh
|
/compile.sh
|
||||||
/upload.sh
|
/upload.sh
|
||||||
/balance_*.csv
|
/balance*.csv
|
||||||
/balance.ods
|
/balance*.ods
|
||||||
|
/default*.csv
|
||||||
/DEFAULT.csv
|
/DEFAULT.csv
|
||||||
/generate_random.sh
|
/generate_random.sh
|
||||||
/print_1_txt.sh
|
/print_1_txt.sh
|
||||||
@ -32,3 +34,4 @@
|
|||||||
/profile/
|
/profile/
|
||||||
/gnu_header.txt
|
/gnu_header.txt
|
||||||
/backup*
|
/backup*
|
||||||
|
/resum_default.sh
|
||||||
|
@ -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,9 +334,7 @@ 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.
|
|
||||||
if not self.primed:
|
|
||||||
self.prime_bot()
|
self.prime_bot()
|
||||||
|
|
||||||
# Begin posting
|
# Begin posting
|
||||||
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,9 +21,6 @@
|
|||||||
# yandereBot, or manipulate hash files in some way. Typically instantiating a yandereBot object is unnecessary for this.
|
# yandereBot, or manipulate hash files in some way. Typically instantiating a yandereBot object is unnecessary for this.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import datetime
|
|
||||||
import shutil
|
|
||||||
import contextlib
|
|
||||||
|
|
||||||
|
|
||||||
# Requires properly formatted MD5 checksum lines.
|
# Requires properly formatted MD5 checksum lines.
|
||||||
@ -75,33 +72,34 @@ class HashObject:
|
|||||||
# Checking for the binary character when comparing hash string is usually overkill since the CoreUtils package reads
|
# Checking for the binary character when comparing hash string is usually overkill since the CoreUtils package reads
|
||||||
# files in binary mode regardless of whether the -b switch is passed.
|
# files in binary mode regardless of whether the -b switch is passed.
|
||||||
# It is included here since it may be useful for some other applications besides the bot.
|
# It is included here since it may be useful for some other applications besides the bot.
|
||||||
def is_matching_atter_binary(v_list, v_hash, v_atter):
|
def is_matching_atter_binary(v_list, v_hash, callback):
|
||||||
atter_bin = "get_binary_char"
|
|
||||||
return next(
|
return next(
|
||||||
(x for x in v_list if
|
(x for x in v_list if
|
||||||
getattr(v_hash, v_atter)() == getattr(x, v_atter)() and
|
callback(v_hash) == callback(x) and
|
||||||
getattr(v_hash, atter_bin)() == getattr(x, atter_bin)()
|
v_hash.get_binary_char() == x.get_binary_char()
|
||||||
), None)
|
), None)
|
||||||
|
|
||||||
|
|
||||||
def is_matching_atter(v_list, v_hash, v_atter):
|
def is_matching_atter(v_list, v_hash, callback):
|
||||||
return next((x for x in v_list if getattr(v_hash, v_atter)() == getattr(x, v_atter)()), None)
|
return next(
|
||||||
|
(x for x in v_list if
|
||||||
|
callback(v_hash) == callback(x)
|
||||||
|
), None)
|
||||||
|
|
||||||
|
def get_matching(v_list, v_hash, callback, match_bin=False):
|
||||||
def get_matching(v_list, v_hash, atter, match_bin=False):
|
return is_matching_atter(v_list, v_hash, callback) if not match_bin else is_matching_atter_binary(v_list, v_hash, callback)
|
||||||
return is_matching_atter(v_list, v_hash, atter) if not match_bin else is_matching_atter_binary(v_list, v_hash, atter)
|
|
||||||
|
|
||||||
|
|
||||||
def get_matching_hash_in_list(v_list, v_hash, match_bin=False):
|
def get_matching_hash_in_list(v_list, v_hash, match_bin=False):
|
||||||
return get_matching(v_list, v_hash, "get_hash_string", match_bin)
|
return get_matching(v_list, v_hash, lambda x: x.get_hash_string(), match_bin)
|
||||||
|
|
||||||
|
|
||||||
def get_matching_path_in_list(v_list, v_hash, match_bin=False):
|
def get_matching_path_in_list(v_list, v_hash, match_bin=False):
|
||||||
return get_matching(v_list, v_hash, "get_hash_path", match_bin)
|
return get_matching(v_list, v_hash, lambda x: x.get_hash_path(), match_bin)
|
||||||
|
|
||||||
|
|
||||||
def get_matching_full_string_in_list(v_list, v_hash, match_bin=False):
|
def get_matching_full_string_in_list(v_list, v_hash, match_bin=False):
|
||||||
return get_matching(v_list, v_hash, "get_full_string", match_bin)
|
return get_matching(v_list, v_hash, lambda x: x.get_full_string(), match_bin)
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------- HASH LIST FUNCTIONS --------------------------------------------
|
# ---------------------------- HASH LIST FUNCTIONS --------------------------------------------
|
||||||
|
Reference in New Issue
Block a user