如何通过python Aigram中的bot在同步函数中发送消息?

2024-03-28 22:59:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个同步函数,其中我需要使用python Aigram中的bot实现发送消息。我发现您可以不使用bot.send_message(…)而使用requests.get(…)发送消息。但这种方式不能指定parse_模式并附加内联按钮。有没有其他方法来实现这一点?由于某些原因,此选项不起作用:

requests.get(f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage?chat_id={chat_id}&text={parse_message}&reply_markup={open_tp}&parse_mode=HTML")

Tags: 方法函数sendid消息messagegetparse
2条回答

我们需要在此结构中包装发送消息:

dp.loop.run_until_complete(bot.send_message(STEAMTRADEBOT_UNLIMITED_ID, parse_message, reply_markup = open_tp))

使用<b>AK-47 | Vulcan (Battle-Scarred)</b>而不是<strong>标记。电报机器人API的HTML和Makrdown语法可在此处找到: https://core.telegram.org/bots/api#formatting-options

相关问题 更多 >