TelegramBots icon indicating copy to clipboard operation
TelegramBots copied to clipboard

HTML and Markdown validator

Open laviua opened this issue 6 years ago • 5 comments

Hi,

I faced with the problem when i use broadcasting to the users via telegram bot and could't find any specific markdown and html validator based on telegram api.

Will be it be useful to create validation by this requirements: https://core.telegram.org/bots/api#html-style

or could you please provide existed solution?

Thanks

laviua avatar Dec 13 '19 10:12 laviua

You could probably write a validator, but i might be hard parsing the exact html or markdown that telegram requires and ignoring the rest basically.

Why exactly do you need to validate the text on your bots side? Is it brought in via an external source?

Chase22 avatar Dec 15 '19 11:12 Chase22

Our content manager, from time to time, uses a telegram bot for sending messages with the news, updates, etc. He uses online markdown editors and, after that, pastes to telegram mailing form. I faced the issue when telegram API could not receive the "invalid" markdown and replied with the error. That's why I'm asking...if it's ok and the end-user gets a message without formatting, it's also ok, but an exception is not ok

laviua avatar Dec 16 '19 13:12 laviua

You could either try to write a validator, or handle the error from telegram correctly. Maybe just remove all markdown when telegram replies with an error or show that error to the user

Chase22 avatar Apr 26 '20 09:04 Chase22

I'd like to have this functionality built-in too. My use case is similar, there is an external source which sends messages so it would be really helpful to validate it before executing some send method. It's not so easy to recover from such error because there are multiple send method supporting markdown and I have a single entry point for all outgoing messages, so I have to check for each type and rebuild PartialBotApiMethod for each type.

IvanPavlov1995 avatar Nov 19 '21 14:11 IvanPavlov1995

I write a validator for markdown style message. It can filter out invalid markdown style messages and send normal messages instead. I hope it will help you fix some problem。

SUSTechDXiang avatar May 29 '22 08:05 SUSTechDXiang