最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Aiogram message formatting - Stack Overflow

programmeradmin6浏览0评论

I'm developing a telegram bot on aiogram and faced a problem. I need to highlight the text bold italicized in the MD V1. How do I do it? I tried different formats: triple underline, triple asterisks, asterisk underline. Nothing helped.

I'm developing a telegram bot on aiogram and faced a problem. I need to highlight the text bold italicized in the MD V1. How do I do it? I tried different formats: triple underline, triple asterisks, asterisk underline. Nothing helped.

Share Improve this question edited Mar 24 at 16:34 AsfhtgkDavid asked Mar 24 at 12:12 AsfhtgkDavidAsfhtgkDavid 499 bronze badges 4
  • Please show us the code you've tried – 0stone0 Commented Mar 24 at 12:14
  • I don't know if it makes sense. It's just reading a message from a .md file and sending it. – AsfhtgkDavid Commented Mar 24 at 12:25
  • Well it's hard for us to guess whats wrong if you don't show the code – 0stone0 Commented Mar 24 at 12:38
  • @0stone0 , I don't think there's a problem with the code. The problem is that I don't know how to make bold italics in Telegram MD syntax. – AsfhtgkDavid Commented Mar 24 at 15:02
Add a comment  | 

1 Answer 1

Reset to default 0

For MarkdownV2, you need *foo* for bold, _bar_ for italic and you can combine them like so:

*_combined _*

Test message:

*bold*
_italic_
*_combined_*

Results in:


If you want to use the AioGram classes, use:

  • aiogram.utils.formatting.Underline
  • aiogram.utils.formatting.Bold
from aiogram.utils.formatting import (
    Bold
)

msg = Bold("Foo Bar")
发布评论

评论列表(0)

  1. 暂无评论