diff --git a/src/autobioebbing.py b/src/autobioebbing.py index 626d907..5156d46 100644 --- a/src/autobioebbing.py +++ b/src/autobioebbing.py @@ -109,7 +109,8 @@ async def eb(client, c, conn, con, d, get_id, my_id, message_q): u2url = r[0][1] u1id = await get_id(u1url) u2id = await get_id(u2url) - bio_excludes = [x[0] for x in c.execute('select user_id from avocado_exclude').fetchall()] + bio_excludes = [x[0] for x in c.execute( + 'select user_id from avocado_exclude').fetchall()] # print(f'{u1url} [@{u1id}] подверг(ла) {u2url} [@{u2id}]')#показать when = int(datetime.timestamp(m.date)) days = int(re.findall(bio_attack_themes[trying_theme_index][2], t)[ @@ -214,10 +215,12 @@ async def eb(client, c, conn, con, d, get_id, my_id, message_q): f"SELECT COUNT(*) FROM `avocado` WHERE expr_int <= {when} ORDER BY expr_int,when_int ASC LIMIT {limit}").fetchone()[0]) patients = list(c.execute( f"SELECT * FROM `avocado` WHERE expr_int <= {when} ORDER BY expr_int,when_int ASC LIMIT {limit}").fetchall()) - bio_excludes = [x[0] for x in c.execute('select user_id from avocado_exclude').fetchall()] + bio_excludes = [x[0] for x in c.execute( + 'select user_id from avocado_exclude').fetchall()] for p in patients: if p[0] in bio_excludes: - logger.warning(f'skipping patient {p[0]}, excluded from bioebinng') + logger.warning( + f'skipping patient {p[0]}, excluded from bioebinng') patients.remove(p) return count, patients @@ -258,7 +261,8 @@ async def eb(client, c, conn, con, d, get_id, my_id, message_q): logger.debug( f'latency avocado reply: {delta_avocado} secs') if delta_avocado > states.avocado_reply_timeout: - interval_with_lag = rs + random.uniform(9.18299148, 40.9201412499) + interval_with_lag = rs + \ + random.uniform(9.18299148, 40.9201412499) logger.debug( f'bioeb sleep [increased, because avocado have lag]: {interval_with_lag}s') await asyncio.sleep(interval_with_lag) @@ -297,12 +301,14 @@ async def eb(client, c, conn, con, d, get_id, my_id, message_q): t = reply.raw_text h = utils.sanitize_parse_mode( 'html').unparse(t, reply.entities) # HTML - r = re.findall(r'', h) + r = re.findall( + r'', h) insertion_status = [] for link in r: user_id = await get_id(link) try: - c.execute("INSERT INTO avocado_exclude(user_id, reason) VALUES (?, ?)", (user_id, reason)) + c.execute( + "INSERT INTO avocado_exclude(user_id, reason) VALUES (?, ?)", (user_id, reason)) insertion_status.append(f'{user_id}: ok') except: insertion_status.append(f'{user_id}: exists') @@ -324,7 +330,8 @@ async def eb(client, c, conn, con, d, get_id, my_id, message_q): h = utils.sanitize_parse_mode( 'html').unparse(t, reply.entities) # HTML r_as_list = [] - r = re.findall(r'|(@\d+)', h) + r = re.findall( + r'|(@\d+)', h) for x in r: r_as_list.extend(x) r = r_as_list @@ -334,11 +341,13 @@ async def eb(client, c, conn, con, d, get_id, my_id, message_q): return def filter_bioeb(victims_ids): - bio_excludes = [x[0] for x in c.execute('SELECT user_id FROM avocado_exclude').fetchall()] + bio_excludes = [x[0] for x in c.execute( + 'SELECT user_id FROM avocado_exclude').fetchall()] filted_victims = [] for v in victims_ids: if v in bio_excludes: - logger.warning(f'skipping patient {v}, excluded from bioebinng') + logger.warning( + f'skipping patient {v}, excluded from bioebinng') elif c.execute(f'SELECT user_id FROM avocado WHERE expr_int >= {when} and user_id == {v}').fetchone(): logger.warning(f'skipping patient {v}, already eaten') else: diff --git a/src/avocmine.py b/src/avocmine.py index 061cea6..2cc58b7 100644 --- a/src/avocmine.py +++ b/src/avocmine.py @@ -33,10 +33,12 @@ async def automine_avocado_task(client): wait_before_mine = 1 minutes = 0 if states.latest_successfull_mine: - wait_before_mine = (time.time() - states.latest_successfull_mine) + random.uniform(240 * 60, 242 * 60) + wait_before_mine = ( + time.time() - states.latest_successfull_mine) + random.uniform(240 * 60, 242 * 60) minutes = wait_before_mine / 60 elif states.wait_before_next_mine: - wait_before_mine = random.uniform(states.wait_before_next_mine, states.wait_before_next_mine + 3) + wait_before_mine = random.uniform( + states.wait_before_next_mine, states.wait_before_next_mine + 3) minutes = wait_before_mine / 60 logger.debug(f'Waiting {minutes} minutes before mining of gems') diff --git a/src/updatenotif.py b/src/updatenotif.py index c8d0732..5ea1b9d 100644 --- a/src/updatenotif.py +++ b/src/updatenotif.py @@ -13,16 +13,21 @@ async def git_notifications_update(): logger.info('Checking for updates...') fetching_git = os.system('git fetch') if fetching_git == 0: - commits = os.popen("git log --pretty=format:'%h %s%n%b' HEAD..origin/$(git rev-parse --abbrev-ref HEAD)").read() + commits = os.popen( + "git log --pretty=format:'%h %s%n%b' HEAD..origin/$(git rev-parse --abbrev-ref HEAD)").read() if len(commits) <= 5: logger.info('updates not found, nothing to do') else: - os.system(f"termux-notification --title 'ub4tg: update avalaible!' --content 'For apply tap button Get update and restart bot\nChanges:\n{commits}' --button1 'Get update' --button1-action 'cd {cwd}; git pull'") + os.system( + f"termux-notification --title 'ub4tg: update avalaible!' --content 'For apply tap button Get update and restart bot\nChanges:\n{commits}' --button1 'Get update' --button1-action 'cd {cwd}; git pull'") else: - os.system("termux-toast '[ub4tg]: failed fetching update, maybe connection error, check console log for more info'") + os.system( + "termux-toast '[ub4tg]: failed fetching update, maybe connection error, check console log for more info'") else: - logger.warning('For getting updates via notifications, you should:') + logger.warning( + 'For getting updates via notifications, you should:') logger.warning('pkg install termux-api') - logger.warning('download the apk: https://f-droid.org/repo/com.termux.api_51.apk') + logger.warning( + 'download the apk: https://f-droid.org/repo/com.termux.api_51.apk') logger.debug('next update will be check after 6 hours') await asyncio.sleep(6 * 60 * 60) diff --git a/src/victimsbackup.py b/src/victimsbackup.py index bb62bc2..a1e646d 100644 --- a/src/victimsbackup.py +++ b/src/victimsbackup.py @@ -95,7 +95,8 @@ async def bio_backup_stealing(client, c, conn, default_directory): logger.success('backup success stealed') if cmd == 'me': my_victims_ids = tuple(my_victims_ids) - result = c.execute(f'UPDATE avocado SET expr_int = 0 WHERE user_id NOT IN {my_victims_ids}').fetchall() + result = c.execute( + f'UPDATE avocado SET expr_int = 0 WHERE user_id NOT IN {my_victims_ids}').fetchall() conn.commit() logger.success('database rebased') del my_victims_ids diff --git a/ubot.py b/ubot.py index 244c8aa..c46986a 100644 --- a/ubot.py +++ b/ubot.py @@ -83,7 +83,8 @@ async def main(): if is_termux: conn = sqlite3.connect(f"{default_directory}/{my_id}.sqlite") else: - conn = sqlite3.connect(f"{my_id}.sqlite") # покласти базу рядом + # покласти базу рядом + conn = sqlite3.connect(f"{my_id}.sqlite") c = conn.cursor() c.execute('''CREATE TABLE IF NOT EXISTS avocado ( user_id INTEGER NOT NULL DEFAULT 0 UNIQUE,