Telegram bot only allowed to post upon events?
Asked Answered
E

1

3

It seems like Telegram bot revolves around the idea of reacting to human events (whether in channel or private messages).

Is there any way to have the Telegram bot post on a channel independently?

Am I really forced to use webhooks for this?

I would like my bot to read blockchain operations and post these on my particular channel regardless of human events.

Erective answered 4/11, 2020 at 11:35 Comment(0)
P
6

You can use polling (instead webhook) in the Python Telegram Bot framework

updater = Updater('token', use_context=True)

dp = updater.dispatcher
updater.start_polling()

# initiate message from backend
dp.bot.send_message(chat_id='xxxx', text='Hello')

As you notice you need a valid chat_id which you get when there is an incoming message/command or the bot is added to a group. You will need to capture that event and save it.

Pohai answered 4/11, 2020 at 13:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.