aboutsummaryrefslogtreecommitdiff
path: root/mentioned.py
diff options
context:
space:
mode:
authormroik <mroik@delayed.space>2021-11-25 00:48:12 +0100
committermroik <mroik@delayed.space>2021-11-25 00:48:12 +0100
commit15e9047c6cdde34662f86fa0b1156c7a860cb895 (patch)
tree1f3ff8c737ed1c169055796c717301bf30d6b090 /mentioned.py
parent9ac7fd007bb935f708be95ed1dcdba4cc8330d76 (diff)
Highlighting
Diffstat (limited to 'mentioned.py')
-rw-r--r--mentioned.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/mentioned.py b/mentioned.py
index 1cc9f20..429791e 100644
--- a/mentioned.py
+++ b/mentioned.py
@@ -1,3 +1,5 @@
+import re
+
from telethon import TelegramClient, events
from telethon.tl.types import PeerUser
@@ -24,10 +26,18 @@ async def handler(event: events.NewMessage.Event):
if message.mentioned:
return
for word in WORDLIST:
- if word.upper() in message.message.upper():
+ if f" {word.upper()} " in message.message.upper()\
+ or message.message.upper().startswith(f"{word.upper()} ")\
+ or message.message.upper().endswith(f" {word.upper()}"):
msg = f"[{from_.user_id}](tg://user?id={from_.user_id}) tagged you in"
msg += f" [{chan.channel_id}](https://t.me/c/{chan.channel_id}/{str(message.id)}):\n"
- msg += f"{message.message}"
+ found = re.search(f"{word.upper()}", message.message.upper())
+ if found is None:
+ msg += f"{message.message}"
+ else:
+ msg += f"{message.message[:found.start()]}__"\
+ f"{message.message[found.start():found.end()]}__"\
+ f"{message.message[found.end():]}"
await client.send_message("me", msg)
return
XMR address: 854DmXNrxULU3ZFJVs4Wc8PFhbq29RhqHhY8W6cdWrtFN3qmooKyyeYPcDzZTNRxphhJ5UzASQfAdEMwSteVqymk28aLhqj