From a0e2ee1cfc32bed264e5416154766e16b741f764 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 13 Dec 2024 03:59:54 +0300 Subject: [PATCH] mass bioeb command just added... --- ubot.py | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/ubot.py b/ubot.py index 012238a..e5c357b 100644 --- a/ubot.py +++ b/ubot.py @@ -490,7 +490,53 @@ async def main(): conn.commit() insertion_status = '\n'.join(insertion_status) await event.edit(f'{insertion_status}\nreason: {reason}') - + + @client.on(events.NewMessage(outgoing=True, pattern=r'\.bioebmass$')) + async def bioeb_mass(event): + reply = await client.get_messages(event.peer_id, ids=event.reply_to.reply_to_msg_id) + when = int(datetime.timestamp(event.date)) + t = reply.raw_text + h = utils.sanitize_parse_mode( + 'html').unparse(t, reply.entities) # HTML + r_as_list = [] + r = re.findall(r'|(@\d+)', h) + for x in r: + r_as_list.extend(x) + r = r_as_list + + if r == []: + await event.edit('nothing to do: ids not found') + return + + def filter_bioeb(victims_ids): + 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') + 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: + filted_victims.append(v) + + return list(set(filted_victims)) + bioebbing_ids = [] + for i in r: + if i == '': + continue + if i.startswith('@'): + bioebbing_ids.append(int(i.replace('@', ''))) + else: + bioebbing_ids.append(await get_id(i)) + bioebbing_ids = filter_bioeb(bioebbing_ids) + bioebbing_len = len(bioebbing_ids) + if bioebbing_len == 0: + await event.edit('already eaten or excluded') + return + await event.edit(f'trying eat {bioebbing_len} patients...') + for patient in bioebbing_ids: + await asyncio.sleep(random.uniform(1.234, 4.222)) + await event.respond(f'биоеб {patient}') @client.on(events.NewMessage(outgoing=True, pattern=r'\.biocheck$')) async def set_default_check_chat(event):