Fix and update usage of parse_mode

This commit is contained in:
Lonami Exo
2022-02-04 12:19:53 +01:00
parent 4b477e5b27
commit 56faccf151
7 changed files with 35 additions and 74 deletions

View File

@@ -2196,7 +2196,8 @@ class TelegramClient:
await client.send_message('me', 'Hello **world**!')
# Default to another parse mode
client.parse_mode = 'html'
from telethon.types import Message
Message.set_default_parse_mode('html')
await client.send_message('me', 'Some <b>bold</b> and <i>italic</i> text')
await client.send_message('me', 'An <a href="https://example.com">URL</a>')
@@ -2204,8 +2205,8 @@ class TelegramClient:
await client.send_message('me', '<a href="tg://user?id=me">Mentions</a>')
# Explicit parse mode
# No parse mode by default
client.parse_mode = None
# No parse mode by default (import Message first)
Message.set_default_parse_mode(None)
# ...but here I want markdown
await client.send_message('me', 'Hello, **world**!', parse_mode='md')