diff options
| -rw-r--r-- | LICENSE | 13 | ||||
| -rw-r--r-- | config.py | 5 | ||||
| -rw-r--r-- | mentioned.py | 40 |
3 files changed, 58 insertions, 0 deletions
@@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + +Copyright (C) 2021 Mroik <mroik@delayed.space> + +Everyone is permitted to copy and distribute verbatim or modified +copies of this license document, and changing it is allowed as long +as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO.
\ No newline at end of file diff --git a/config.py b/config.py new file mode 100644 index 0000000..4fb3498 --- /dev/null +++ b/config.py @@ -0,0 +1,5 @@ +from os import environ + +API_ID = environ.get("TELEGRAM_API_ID") +API_HASH = environ.get("TELEGRAM_API_HASH") +WORDLIST = [] # List of words to be notified about diff --git a/mentioned.py b/mentioned.py new file mode 100644 index 0000000..327ab10 --- /dev/null +++ b/mentioned.py @@ -0,0 +1,40 @@ +from telethon import TelegramClient, events +from telethon.tl.types import PeerUser + +from config import API_ID, API_HASH, WORDLIST + + +client = TelegramClient("mi_chiamano", 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 event.message.mentioned: + return + for word in WORDLIST: + if word.upper() in event.message.message.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)})" + await client.send_message("me", msg) + return + + +def main(): + client.start() + client.run_until_disconnected() + + +if __name__ == "__main__": + main() |
