use native filter from_users in event handler, no more if m.sender_id != blah...

This commit is contained in:
Your Name 2024-12-18 18:53:49 +03:00
parent c6ee992980
commit ccb76a9b19

30
ubot.py
View file

@ -270,7 +270,9 @@ async def main():
asyncio.ensure_future(updatenotif.git_notifications_update()) asyncio.ensure_future(updatenotif.git_notifications_update())
await victimsbackup.bio_backup_stealing(client, c, conn, default_directory) await victimsbackup.bio_backup_stealing(client, c, conn, default_directory)
@client.on(events.NewMessage(pattern='.*йобнув.*|.*подверг(ла)?.*|.*infected.*|.*сикди.*|.*насрал.*|.*выебал.*|.*за допомогою довіреності.*|.*by authorization infected.*|.*при помощи анонимуса атаковала.*')) @client.on(events.NewMessage(
pattern='.*йобнув.*|.*подверг(ла)?.*|.*infected.*|.*сикди.*|.*насрал.*|.*выебал.*|.*за допомогою довіреності.*|.*by authorization infected.*|.*при помощи анонимуса атаковала.*',
from_users=(6333102398, 'me')))
@logger.catch @logger.catch
async def podverg_a(event): async def podverg_a(event):
logger.debug('bio attack detected') logger.debug('bio attack detected')
@ -347,10 +349,7 @@ async def main():
default_pathogen_remaining_theme), default_pathogen_remaining_theme),
) )
if m.sender_id != 6333102398: if len(m.entities) > 1:
logger.debug('not avocado infection, skipping')
pass
elif len(m.entities) > 1:
h = utils.sanitize_parse_mode( h = utils.sanitize_parse_mode(
'html').unparse(t, m.entities) # HTML 'html').unparse(t, m.entities) # HTML
for theme in bio_attack_themes: for theme in bio_attack_themes:
@ -622,17 +621,14 @@ async def main():
states.where_send_check_avocado = event.peer_id states.where_send_check_avocado = event.peer_id
await event.edit('Checks will be send here') await event.edit('Checks will be send here')
@client.on(events.NewMessage(pattern='.+Служба безопасности лаборатории')) @client.on(events.NewMessage(pattern='.+Служба безопасности лаборатории',
from_users=(707693258, 5137994780, 5226378684, 5443619563, 5434504334)))
# Организатор заражения: нада биоебнуть? # Организатор заражения: нада биоебнуть?
async def iris_sb(event): async def iris_sb(event):
# iris off bio 31.12.24 # iris off bio 31.12.24
m = event.message m = event.message
t = m.raw_text t = m.raw_text
irises = [707693258, 5137994780, if a_404_patient and len(m.entities) > 1 and states.where_send_check_avocado:
5226378684, 5443619563, 5434504334]
if m.sender_id not in irises:
pass
elif a_404_patient and len(m.entities) > 1 and states.where_send_check_avocado:
h = utils.sanitize_parse_mode( h = utils.sanitize_parse_mode(
'html').unparse(t, m.entities) # HTML 'html').unparse(t, m.entities) # HTML
r = re.findall( r = re.findall(
@ -648,12 +644,10 @@ async def main():
#################################################################### ####################################################################
@client.on(events.NewMessage(pattern='⏱?🚫 Жертва')) @client.on(events.NewMessage(pattern='⏱?🚫 Жертва', from_users=(6333102398,)))
async def infection_not_found(event): async def infection_not_found(event):
m = event.message m = event.message
if m.sender_id != 6333102398: if a_404_patient and m.mentioned:
pass
elif a_404_patient and m.mentioned:
await asyncio.sleep(random.uniform(1.0001, 2.22394)) await asyncio.sleep(random.uniform(1.0001, 2.22394))
result = await client(functions.messages.GetBotCallbackAnswerRequest( # src https://tl.telethon.dev/methods/messages/get_bot_callback_answer.html result = await client(functions.messages.GetBotCallbackAnswerRequest( # src https://tl.telethon.dev/methods/messages/get_bot_callback_answer.html
peer=m.peer_id, peer=m.peer_id,
@ -665,14 +659,12 @@ async def main():
if result.message: if result.message:
logger.info(f'avocado says: {result.message}') logger.info(f'avocado says: {result.message}')
@client.on(events.NewMessage(pattern='🌡 У вас горячка вызванная')) @client.on(events.NewMessage(pattern='🌡 У вас горячка вызванная', from_users=(6333102398,)))
async def need_h(event): async def need_h(event):
m = event.message m = event.message
# reply = await client.get_messages(m.peer_id, ids=m.reply_to.reply_to_msg_id) # reply = await client.get_messages(m.peer_id, ids=m.reply_to.reply_to_msg_id)
# logger.debug(reply) # logger.debug(reply)
if m.sender_id != 6333102398: if a_h and m.mentioned:
pass
elif a_h and m.mentioned:
# нада хил # нада хил
ah = await message_q( # отправляет сообщение боту ah = await message_q( # отправляет сообщение боту
"Хил", "Хил",