2018-11-24 21:22:44 +00:00
|
|
|
"""
|
2019-07-06 22:01:35 +00:00
|
|
|
Reply to a message with .p to toggle the webpage preview of a message
|
2018-11-24 21:22:44 +00:00
|
|
|
"""
|
2018-11-24 21:14:04 +00:00
|
|
|
from telethon.errors import MessageNotModifiedError
|
|
|
|
from telethon.tl.functions.messages import EditMessageRequest
|
|
|
|
|
|
|
|
from stdplugins.kbass_core import self_reply_cmd
|
|
|
|
|
|
|
|
|
2019-07-06 22:01:35 +00:00
|
|
|
@self_reply_cmd(borg, r"^\.p$")
|
2018-11-24 21:14:04 +00:00
|
|
|
async def on_edit_preview(event, target):
|
|
|
|
try:
|
|
|
|
await borg(EditMessageRequest(
|
|
|
|
peer=await event.get_input_chat(),
|
|
|
|
id=target.id,
|
2019-07-06 22:01:35 +00:00
|
|
|
no_webpage=bool(target.media),
|
2018-11-24 21:14:04 +00:00
|
|
|
message=target.message,
|
|
|
|
entities=target.entities
|
|
|
|
))
|
|
|
|
except MessageNotModifiedError:
|
|
|
|
# There was no preview to modify
|
|
|
|
pass
|