1

I have a synchronous function and in it I need to implement sending messages using a bot in python aiogram. I found that you can send a message not using bot.send_message (...), but requests.get (...). But this way you cannot specify parse_mode and attach an inline button. Are there any other ways to implement this? For some reason, this option does not work.:

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")
429
  • 63
  • 8

2 Answers2

0

Use <b>AK-47 | Vulcan (Battle-Scarred)</b> and not <strong> tag. The HTML and Makrdown syntax for Telegram Bot API you can find here: https://core.telegram.org/bots/api#formatting-options

MyZik
  • 220
  • 2
  • 15
  • this does not work. Moreover, I have a button in my message, it is not added either – 429 Jun 22 '21 at 12:36
  • pls post full code, why you say aiogram and do it with python requests? – MyZik Jun 22 '21 at 13:00
  • There is a lot of code, but I can explain it without it. I get such a structure that in an asynchronous function there is a call to a regular function, in which, in turn, a call to another asynchronous function. Because of this structure, I get an error, which can be solved by changing the sending of messages from bot.send_message to requests.get requests. Messages are sent, but all parameters like parse_mode and reply_markup are not taken into account and I receive a message with html tags and without a button – 429 Jun 23 '21 at 09:53
0

We need to wrap sending the message in this structure:

dp.loop.run_until_complete(bot.send_message(STEAMTRADEBOT_UNLIMITED_ID, parse_message, reply_markup = open_tp))
429
  • 63
  • 8