I wanna receive messages from a specific Group Topic, Topics end their ID’s with a _[number] but I don’t know how I can make that work in this case, i’ve tried it like this and this doesn’t work.
Does anyone have an idea how I can fix this? Thanks
from telethon import TelegramClient, events
api_id =
api_hash = ''
phone_number = ''
source_chat_ids = [100123456789, 100987654321_13]
specific_user_ids = [xyx, yxy] # Voeg hier de gebruikers-IDs toe
history = []
client = TelegramClient('session_name', api_id, api_hash)
async def send_telegram_message(message):
await client.send_message(xxx, message)
async def main():
await client.start(phone=phone_number)
print("Client is gestart")
@client.on(events.NewMessage(chats=source_chat_ids))
async def handler(event):
if event.sender_id in specific_user_ids:
if event.message.message not in history:
message = event.message.message
history.append(message)
await send_telegram_message(message)
print("Listening for messages...")
await client.run_until_disconnected()
with client:
client.loop.run_until_complete(main())
That simply adding the _XYZ to the id would work