[英]How to send a message in a synchronous function by a bot in python aiogram?
我有一個同步 function,我需要在其中使用 python aiogram 中的機器人實現發送消息。 我發現您可以不使用 bot.send_message(...) 發送消息,而是使用 requests.get(...)。 但是這樣你就不能指定 parse_mode 並附加一個內聯按鈕。 還有其他方法可以實現嗎? 由於某種原因,此選項不起作用。:
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")
使用<b>AK-47 | Vulcan (Battle-Scarred)</b>
<b>AK-47 | Vulcan (Battle-Scarred)</b>
而不是<strong>
標簽。 Telegram Bot API 的 HTML 和 Makrdown 語法你可以在這里找到: https://core.telegram.org/bots/api#formatting-options
我們需要在這個結構中包裝發送消息:
dp.loop.run_until_complete(bot.send_message(STEAMTRADEBOT_UNLIMITED_ID, parse_message, reply_markup = open_tp))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.