Send html file when message is too long

kate
udf 2019-08-03 17:41:48 +02:00
parent 5dd06471db
commit 6dc069afd9
Signed by: kate
GPG Key ID: F17AECB58C3A3096
1 changed files with 15 additions and 2 deletions

View File

@ -4,8 +4,9 @@
from telethon import events
from telethon.utils import add_surrogate
from telethon.tl.types import MessageEntityPre
from telethon.tl.types import MessageEntityPre, DocumentAttributeFilename
from telethon.tl.tlobject import TLObject
from telethon.errors import MessageTooLongError
import datetime
STR_LEN_MAX = 256
@ -91,4 +92,16 @@ async def _(event):
return
msg = await event.message.get_reply_message()
yaml_text = yaml_format(msg)
await event.edit(yaml_text, parse_mode=parse_pre)
try:
await event.edit(yaml_text, parse_mode=parse_pre)
except MessageTooLongError:
await event.delete()
await borg.send_file(
await event.get_input_chat(),
f'<pre>{yaml_text}</pre>'.encode('utf-8'),
reply_to=msg,
attributes=[
DocumentAttributeFilename('info.html')
],
allow_cache=False
)