eternnoir / pyTelegramBotAPI

Python Telegram bot api.
GNU General Public License v2.0
8.12k stars 2.03k forks source link

400 error on get username from user with special characters in username #2025

Closed sudousercom closed 1 year ago

sudousercom commented 1 year ago

Hi! faced the issue with get username from user with _ character in username, like @user_name api always returns 400,

2023-07-26 14:14:48.696 ERROR async_telebot - _run_middlewares_and_handlers: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 99
2023-07-26 14:14:51.623 ERROR async_telebot - _run_middlewares_and_handlers: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 99
2023-07-26 14:14:52.581 ERROR async_telebot - _run_middlewares_and_handlers: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 99

Is this a bot issue or an API limitation?

bot is runnig on linux, pyTelegramBotAPI 4.12.0, on python Python 3.9.17

coder2020official commented 1 year ago

Hello, if you are using parse mode, you have to escape the character. Read more here: https://core.telegram.org/bots/api#formatting-options

sudousercom commented 1 year ago

thanks for answer!