PagerMaid_Plugins/nthmsg.py

23 lines
721 B
Python
Raw Normal View History

2020-08-12 03:58:53 +00:00
from pagermaid.listener import listener
from telethon import functions, types
2021-06-16 07:09:40 +00:00
from pagermaid.utils import alias_command
2020-08-12 03:58:53 +00:00
2021-06-16 07:09:40 +00:00
@listener(outgoing=True, command=alias_command("nthmsg"),
2020-08-12 03:58:53 +00:00
description="获取你发送的第 n 条消息,默认为第一条",
parameters="<n>")
async def nthmsg(context):
await context.edit("获取中 . . .")
try:
n = int(context.parameter[0])
except:
n = 1
m = object()
2021-06-16 07:09:40 +00:00
async for m in context.client.iter_messages(context.chat_id, from_user="me", reverse=True, limit=n):
2020-08-12 03:58:53 +00:00
pass
r = await context.client(
2021-06-16 07:09:40 +00:00
functions.channels.ExportMessageLinkRequest(channel=m.to_id, id=m.id, grouped=True))
2020-08-12 03:58:53 +00:00
await context.edit(r.link)