Daniel Martinez
Daniel Martinez

Reputation: 537

Telegram bot only allowed to post upon events?

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.

Upvotes: 3

Views: 1275

Answers (1)

Beppe C
Beppe C

Reputation: 13973

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.

Upvotes: 6

Related Questions