26 lines
924 B
Python
26 lines
924 B
Python
"""Temporary script to detect group_id from incoming messages."""
|
|
import asyncio
|
|
import os
|
|
from dotenv import load_dotenv
|
|
from telegram import Update
|
|
from telegram.ext import Application, MessageHandler, filters, ContextTypes
|
|
|
|
load_dotenv()
|
|
|
|
async def on_any(update: Update, ctx: ContextTypes.DEFAULT_TYPE):
|
|
msg = update.effective_message
|
|
if not msg:
|
|
return
|
|
print(f"chat_id={msg.chat_id} type={msg.chat.type} thread={msg.message_thread_id} from={msg.from_user.full_name if msg.from_user else '?'} text={msg.text}")
|
|
|
|
async def main():
|
|
app = Application.builder().token(os.getenv("TELEGRAM_BOT_TOKEN")).build()
|
|
app.add_handler(MessageHandler(filters.ALL, on_any))
|
|
print("Listening for messages... Send something in the group.")
|
|
await app.initialize()
|
|
await app.start()
|
|
await app.updater.start_polling(drop_pending_updates=True)
|
|
await asyncio.Event().wait()
|
|
|
|
asyncio.run(main())
|