-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider using message entities instead of converting to Telegram-specific Markdown #55
Comments
If you mean Telegram HTML rendering. It is good! But it will take some time. |
Have you ever encountered a 400 error when using the Markdown V2 format? If so, we should probably maintain an additional HTML semantics |
No. Try this: import asyncio
from aiogram import Bot
from aiogram.types import MessageEntity
TOKEN = ""
CHAT_ID = 0
async def main() -> None:
async with Bot(TOKEN) as bot:
await bot.send_message(
CHAT_ID,
"This text is bold\nThis text is strikethrough",
entities=[
MessageEntity(type="bold", offset=0, length=17),
MessageEntity(type="strikethrough", offset=18, length=26),
],
)
asyncio.run(main()) As you can see, it does all the formatting without any special syntax. |
In fact, |
I've had this 1 time with |
I am thinking whether this is feasible. It stands to reason that after grammar parsing, many block tokens can be matched with message entities. I'll investigate further when I have time. |
Some libraries do not support MarkdownV2 format. Perhaps this issue must be resolved. |
I started working on my own library, which will use pyromark for Markdown parsing and it will use message entities. |
Interesting!, maybe you'll solve the puzzle of the century |
Instead of converting Markdown to Telegram-specific Markdown, you could remove all Markdown syntax from the original string and send message entities in the Telegram request. This would make the library more robust and simpler, I believe. There will no longer be 400 Bad Requests from Telegram. It will also allow for a more correct maximum message length, since Telegram counts the length after parsing the message entities. Let me know if you need more explanation with examples.
The text was updated successfully, but these errors were encountered: