3

Am trying to send a message to a Telegram channel after a new message event is invoked in another. The code i have below utilizes the channel name as the entity but it doesn't work all the time. Any ideas how i would go about it in better and effecient way.

@client.on(events.NewMessage(chats=channel))
async def my_event_handler(event):
    values = formatter(event.raw_text)
    await client.send_message('destination', template.format(coin=values[0], buy=values[1]))

client.start()
client.run_until_disconnected()
Caleb Njiiri
  • 1,563
  • 1
  • 11
  • 20

1 Answers1

-1

This is the Documentation :
So i've send a message that said "Hello python" with the username "abdx".

client = TelegramClient('session_name',
                    api_id,
                    api_hash,
                    )
client.start()
destination_user_username='abdx'
entity=client.get_entity(destination_user_username)
client.send_message(entity=entity,message="Hello python")

By Alihossein shahabi.