Dan*_*nez 3 telegram telegram-bot
Telegram 机器人似乎围绕着对人类事件做出反应的想法(无论是在频道还是私人消息中)。
有没有办法让 Telegram 机器人在频道上独立发帖?
我真的被迫为此使用网络钩子吗?
我希望我的机器人能够读取区块链操作并将这些操作发布到我的特定频道上,而不管人类事件如何。
polling您可以在 Python Telegram Bot 框架中使用(而不是 webhook)
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')
Run Code Online (Sandbox Code Playgroud)
正如您所注意到的,您需要一个有效的 chat_id,当有传入消息/命令或机器人被添加到组中时您会获得该 ID。您需要捕获该事件并保存它。