aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--userbot.py9
1 files changed, 5 insertions, 4 deletions
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)
XMR address: 854DmXNrxULU3ZFJVs4Wc8PFhbq29RhqHhY8W6cdWrtFN3qmooKyyeYPcDzZTNRxphhJ5UzASQfAdEMwSteVqymk28aLhqj