aboutsummaryrefslogtreecommitdiff
path: root/mentioned.py
diff options
context:
space:
mode:
authormroik <mroik@delayed.space>2021-11-25 14:45:23 +0100
committermroik <mroik@delayed.space>2021-11-25 14:45:23 +0100
commit6ff65935c878a9dc83eb7d81f1c9e745e543595b (patch)
treee85dd18f8de0ddfd72eb89f4d31602ee57e3eb55 /mentioned.py
parent3bc56ef4428524ccba37c8a68654576a395bba1d (diff)
Messages are now sent by a bot in a group
This way when someone mentions you without tagging you, there will be a notification from that group, because the message will be sent by the bot.
Diffstat (limited to 'mentioned.py')
-rw-r--r--mentioned.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/mentioned.py b/mentioned.py
index b199c60..b3cd7ff 100644
--- a/mentioned.py
+++ b/mentioned.py
@@ -1,13 +1,14 @@
import re
from telethon import TelegramClient, events
-from telethon.tl.types import PeerUser, PeerChannel
+from telethon.tl.types import PeerUser
+from telegram import Bot
-from config import API_ID, API_HASH, WORDLIST, GROUP_ID
+from config import API_ID, API_HASH, WORDLIST, GROUP_ID, BOT_TOKEN
client = TelegramClient("notify me on untagged", API_ID, API_HASH)
-client.parse_mode = "markdown"
+bot = Bot(BOT_TOKEN)
@client.on(events.NewMessage())
@@ -38,7 +39,7 @@ async def handler(event: events.NewMessage.Event):
msg += f"{message.message[:found.start()]}__"\
f"{message.message[found.start():found.end()]}__"\
f"{message.message[found.end():]}"
- await client.send_message(await client.get_input_entity((int(GROUP_ID))), msg)
+ bot.send_message(GROUP_ID, msg, parse_mode="markdown")
return
XMR address: 854DmXNrxULU3ZFJVs4Wc8PFhbq29RhqHhY8W6cdWrtFN3qmooKyyeYPcDzZTNRxphhJ5UzASQfAdEMwSteVqymk28aLhqj