dmcallejo / ASFBot

Control your ArchiSteamFarm with Telegram
GNU General Public License v3.0
43 stars 10 forks source link

Got the Entity error. This is most likely due to parse_mode. #5

Closed lzrdblzzrd closed 3 years ago

lzrdblzzrd commented 3 years ago
C:\ASFBot-master>python bot.py --token token --alias alias --host host --port 1242 --password ipc_password
2020-12-29 16:50:56,735 - ASFBot - INFO - Starting up bot...
2020-12-29 16:50:56,759 - ASFBot - INFO - ASF Instance replied: OK
2020-12-29 16:51:00,497 - ASFBot - INFO - Command: !status. Response: <bot> The bot doesn't farm anything.
2020-12-29 16:51:00,658 (__init__.py:489 MainThread) ERROR - TeleBot: "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 7"
lzrdblzzrd commented 3 years ago

Changing parse_mode in bot.py from Markdown to MarkdownV2 gave this result:

C:\ASFBot-master>python bot.py --token token --alias alias --host host --port 1242 --password ipc_password
2020-12-29 17:13:34,864 - ASFBot - INFO - Starting up bot...
2020-12-29 17:13:34,926 - ASFBot - INFO - ASF Instance replied: OK
2020-12-29 16:51:00,497 - ASFBot - INFO - Command: !status. Response: <bot> The bot doesn't farm anything.
2020-12-29 17:13:38,390 (__init__.py:489 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: can't parse entities: Character '>' is reserved and must be escaped with the preceding '\'"

Changing to HTML gave:

C:\ASFBot-master>python bot.py --token token --alias alias --host host --port 1242 --password ipc_password
2020-12-29 17:15:26,908 - ASFBot - INFO - Starting up bot...
2020-12-29 17:15:26,969 - ASFBot - INFO - ASF Instance replied: OK
2020-12-29 16:51:00,497 - ASFBot - INFO - Command: !status. Response: <bot> The bot doesn't farm anything.
2020-12-29 17:15:30,862 (__init__.py:489 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: can't parse entities: Unsupported start tag "bot" at byte offset 0"

P.S. Bot commands on the ASF side are executed. The problem is that the bot in Telegram does not send feedback.

lzrdblzzrd commented 3 years ago

Complete removal , parse_mode= "Markdown" from every function in bot.py fixed the problem.

For example

from
bot.reply_to(message, "Invalid command. Usage:\n`/status <bot>`", parse_mode="Markdown")
to
bot.reply_to(message, "Invalid command. Usage:\n`/status <bot>`")

Let me know if deleting parse_mode somehow messes up some bot replies.

lzrdblzzrd commented 3 years ago

As I noticed, deleting parse_mode creates formatting errors, but only if you use /command instead of !command. So it would be nice if you fixed this bug. image

dmcallejo commented 3 years ago

Hi, thanks for the debugging. markdown parse mode should be refactored into html markdown which is way less problematic. I'll look into it

dmcallejo commented 3 years ago

@lzrdblzzrd I just pushed to the develop branch the changes that should solve this problem. Please check them out and report back any issues you may encounter!

lzrdblzzrd commented 3 years ago

I checked the bot's work with HTML formatting and didn't find any problems. Thanks.

dmcallejo commented 3 years ago

Cool, I'll merge into master then. Thank you!