From e677b6dff8337790fd3409711183bd99084a96a4 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 6 May 2025 18:07:09 +0000 Subject: [PATCH] Filter useless messages --- main.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 7df3180..d4eb1d2 100644 --- a/main.py +++ b/main.py @@ -132,6 +132,26 @@ async def get_messages(): return messages +async def bot_send(destination, message): + silent = False + + if 'tristen' and 'cardinal' in message.lower(): + logging.info('Tristen Cardinal spam, skipping.') + return + + if '@Y@o@u@' in message: + logging.info('Voice mail alert, muting.') + silent = True + + if '@M@e@s@s@a@g@e@' in message: + logging.info('Voice mail alert, muting.') + silent = True + + tg = await bot.send_message(destination, message, link_preview=False, silent=silent) + + logging.info('Sent TG bot message %s', tg.id) + + async def check_messages(): messages = await get_messages() @@ -147,9 +167,7 @@ async def check_messages(): message['text'], ) - tg = await bot.send_message(settings.TANNER_ID, bot_message, link_preview=False) - - logging.info('Sent TG bot message %s', tg.id) + await bot_send(settings.TANNER_ID, bot_message) await delete_message(message['mid']) @@ -182,7 +200,7 @@ async def send(event): if res: await event.reply('ok') else: - await event.reply('Error sending SMS.') + await event.reply('Error sending SMS. Not allowed special characters?') @bot.on(events.NewMessage(pattern='^(?!\/).*$')) async def new_message(event): @@ -212,7 +230,7 @@ async def new_message(event): res = await send_message(from_field, event.raw_text) if not res: - await event.reply('Error sending SMS.') + await event.reply('Error sending SMS. Not allowed special characters?') async def main():