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

@@ -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(