From 4aa166882444c039b5a977eb28595df141697f49 Mon Sep 17 00:00:00 2001 From: Mroik Date: Sat, 13 Apr 2024 21:50:09 +0200 Subject: Better output --- userbot.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'userbot.py') diff --git a/userbot.py b/userbot.py index 1835b13..bd338d8 100644 --- a/userbot.py +++ b/userbot.py @@ -1,6 +1,6 @@ from telethon import TelegramClient, events from telethon.tl.patched import Message -from telethon.tl.types import Chat +from telethon.tl.types import Chat, User from config import API_ID, API_HASH, WORDLIST, BOTNICK client = TelegramClient("notify-on-untagged", int(API_ID), API_HASH) @@ -11,9 +11,10 @@ client.parse_mode = "markdown" async def check_message(event): message: Message = event.message c: Chat = await message.get_chat() + sender: User = await message.get_sender() + name = sender.username or sender.first_name found = len(list(filter(lambda x: x in message.message.lower(), WORDLIST))) > 0 - if found and not message.mentioned: - print(f"[{message.chat_id}](https://t.me/c/{message.chat_id}/{message.id})") - to_send = f"[{message.from_id.user_id}](tg://user?id={message.from_id.user_id}) " + if found and (message.mentioned is False or message.mentioned is None): + to_send = f"[{name}](tg://user?id={message.from_id.user_id}) " to_send += f"tagged you in [{c.id}](https://t.me/c/{c.id}/{message.id})" await client.send_message(BOTNICK, to_send) -- cgit v1.3