blob: 2661fd881e0e7161097719f6218fc99dfbce3e0b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
import re
from telethon import TelegramClient, events
from telethon.tl.types import PeerUser, InputPeerChannel
from telethon.tl.custom.chatgetter import ChatGetter
from config import API_ID, API_HASH, WORDLIST, GROUP_ID
client = TelegramClient("notify me on untagged", API_ID, API_HASH)
client.parse_mode = "markdown"
@client.on(events.NewMessage())
async def handler(event: events.NewMessage.Event):
me = await client.get_me()
from_ = event.message.from_id
chan = event.message.peer_id
message = event.message
if isinstance(event.message.peer_id, PeerUser):
return
if from_.user_id == me.id:
return
if message.message == "" or message.message is None:
return
if message.mentioned:
return
for word in WORDLIST:
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"
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(client.get_entity(GROUP_ID), msg)
return
def main():
client.start()
client.run_until_disconnected()
if __name__ == "__main__":
main()
|
XMR address: 854DmXNrxULU3ZFJVs4Wc8PFhbq29RhqHhY8W6cdWrtFN3qmooKyyeYPcDzZTNRxphhJ5UzASQfAdEMwSteVqymk28aLhqj