remove explicit setting in toggle preview

This commit is contained in:
udf 2019-07-07 00:01:35 +02:00
parent e810a977c5
commit bd271b7e29
Signed by: kate
GPG Key ID: F17AECB58C3A3096
1 changed files with 3 additions and 6 deletions

View File

@ -1,5 +1,5 @@
"""
Reply to a message with .p <y/n> to toggle the webpage preview of a message
Reply to a message with .p to toggle the webpage preview of a message
"""
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.messages import EditMessageRequest
@ -7,16 +7,13 @@ from telethon.tl.functions.messages import EditMessageRequest
from stdplugins.kbass_core import self_reply_cmd
@self_reply_cmd(borg, r"^\.p(?: ?)([yn])?$")
@self_reply_cmd(borg, r"^\.p$")
async def on_edit_preview(event, target):
preview = event.pattern_match.group(1) == 'y'
if not event.pattern_match.group(1):
preview = not bool(target.media)
try:
await borg(EditMessageRequest(
peer=await event.get_input_chat(),
id=target.id,
no_webpage=not preview,
no_webpage=bool(target.media),
message=target.message,
entities=target.entities
))