forked from uniborg/uniborg
Compare commits
No commits in common. "5dd06471dbec179d3692ebf228934bedbde52862" and "e810a977c531ed2ce59170742280e175a56b3acb" have entirely different histories.
5dd06471db
...
e810a977c5
|
@ -1,5 +1,5 @@
|
||||||
"""
|
"""
|
||||||
Reply to a message with .p to toggle the webpage preview of a message
|
Reply to a message with .p <y/n> to toggle the webpage preview of a message
|
||||||
"""
|
"""
|
||||||
from telethon.errors import MessageNotModifiedError
|
from telethon.errors import MessageNotModifiedError
|
||||||
from telethon.tl.functions.messages import EditMessageRequest
|
from telethon.tl.functions.messages import EditMessageRequest
|
||||||
|
@ -7,13 +7,16 @@ from telethon.tl.functions.messages import EditMessageRequest
|
||||||
from stdplugins.kbass_core import self_reply_cmd
|
from stdplugins.kbass_core import self_reply_cmd
|
||||||
|
|
||||||
|
|
||||||
@self_reply_cmd(borg, r"^\.p$")
|
@self_reply_cmd(borg, r"^\.p(?: ?)([yn])?$")
|
||||||
async def on_edit_preview(event, target):
|
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:
|
try:
|
||||||
await borg(EditMessageRequest(
|
await borg(EditMessageRequest(
|
||||||
peer=await event.get_input_chat(),
|
peer=await event.get_input_chat(),
|
||||||
id=target.id,
|
id=target.id,
|
||||||
no_webpage=bool(target.media),
|
no_webpage=not preview,
|
||||||
message=target.message,
|
message=target.message,
|
||||||
entities=target.entities
|
entities=target.entities
|
||||||
))
|
))
|
||||||
|
|
|
@ -10,7 +10,7 @@ from uniborg import util
|
||||||
DELETE_TIMEOUT = 2
|
DELETE_TIMEOUT = 2
|
||||||
|
|
||||||
|
|
||||||
@borg.on(util.admin_cmd(r"^\.(?:(?:re)?load|enable|add) (?P<shortname>\w+)$"))
|
@borg.on(util.admin_cmd(r"^\.(?:re)?load (?P<shortname>\w+)$"))
|
||||||
async def load_reload(event):
|
async def load_reload(event):
|
||||||
await event.delete()
|
await event.delete()
|
||||||
shortname = event.pattern_match["shortname"]
|
shortname = event.pattern_match["shortname"]
|
||||||
|
|
Loading…
Reference in New Issue