mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-09 05:19:41 +00:00
Fix and update usage of parse_mode
This commit is contained in:
@@ -5,6 +5,7 @@ import hypercorn.asyncio
|
||||
from quart import Quart, render_template_string, request
|
||||
|
||||
from telethon import TelegramClient, utils
|
||||
from telethon.types import Message
|
||||
from telethon.errors import SessionPasswordNeededError
|
||||
|
||||
|
||||
@@ -51,9 +52,11 @@ SESSION = os.environ.get('TG_SESSION', 'quart')
|
||||
API_ID = int(get_env('TG_API_ID', 'Enter your API ID: '))
|
||||
API_HASH = get_env('TG_API_HASH', 'Enter your API hash: ')
|
||||
|
||||
# Render things nicely (global setting)
|
||||
Message.set_default_parse_mode('html')
|
||||
|
||||
# Telethon client
|
||||
client = TelegramClient(SESSION, API_ID, API_HASH)
|
||||
client.parse_mode = 'html' # <- Render things nicely
|
||||
phone = None
|
||||
|
||||
# Quart app
|
||||
@@ -69,7 +72,7 @@ async def format_message(message):
|
||||
message.raw_text
|
||||
)
|
||||
else:
|
||||
# client.parse_mode = 'html', so bold etc. will work!
|
||||
# The Message parse_mode is 'html', so bold etc. will work!
|
||||
content = (message.text or '(action message)').replace('\n', '<br>')
|
||||
|
||||
return '<p><strong>{}</strong>: {}<sub>{}</sub></p>'.format(
|
||||
|
Reference in New Issue
Block a user