C
C
che_aa2021-07-02 20:03:15
Python
che_aa, 2021-07-02 20:03:15

How to use escaping in aiogram?

How to escape text in aiogram to feed it to markdown?
That is, there is a code:

import config
from aiogram import Bot, Dispatcher, executor, types
from aiogram.utils.markdown import escape_md
bot = Bot(token=config.token)
dp = Dispatcher(bot)

@dp.message_handler()
async def text_messages(message: types.Message): 
  text = escape_md(message.text)
  await message.answer(text, parse_mode=types.ParseMode.MARKDOWN)

The escape_md method is supposed to escape problematic characters, but along with them, it also escapes the ones I need.
Example:
Example

#Мое сообщение
Привет. Как дела?
#Ответ бота
Привет\. Как дела?


How can you avoid escaping the dot? To come not \. but simply.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question