🔖 Update to v1.4.8

This commit is contained in:
xtaodada 2024-02-04 15:33:01 +08:00
parent 3ddd16b744
commit 0e7379ecc8
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
9 changed files with 29 additions and 45 deletions

View File

@ -22,8 +22,8 @@ from pagermaid.scheduler import scheduler
import pyromod.listen import pyromod.listen
from pyrogram import Client from pyrogram import Client
pgm_version = "1.4.7" pgm_version = "1.4.8"
pgm_version_code = 1407 pgm_version_code = 1408
CMD_LIST = {} CMD_LIST = {}
module_dir = __path__[0] module_dir = __path__[0]
working_dir = getcwd() working_dir = getcwd()

View File

@ -85,12 +85,13 @@ async def profile(client: Client, message: Message):
f"{lang('profile_type')}: {user_type} \n" f"{lang('profile_type')}: {user_type} \n"
f"[{first_name}](tg://user?id={user.id})" f"[{first_name}](tg://user?id={user.id})"
) )
photo = await client.download_media(user.photo.big_file_id) photo = await client.download_media(user.photo.big_file_id) if user.photo else None
reply_to = ( reply_to = (
message.reply_to_message.id message.reply_to_message.id
if message.reply_to_message if message.reply_to_message
else message.reply_to_top_message_id else None
) )
if photo:
try: try:
await client.send_photo( await client.send_photo(
message.chat.id, photo, caption=caption, reply_to_message_id=reply_to message.chat.id, photo, caption=caption, reply_to_message_id=reply_to
@ -99,6 +100,8 @@ async def profile(client: Client, message: Message):
return remove(photo) return remove(photo)
except TypeError: except TypeError:
await message.edit(caption) await message.edit(caption)
else:
await message.edit(caption)
@listener( @listener(

View File

@ -169,29 +169,13 @@ async def re(bot: Client, message: Message):
for _ in range(num): for _ in range(num):
try: try:
if not message.chat.has_protected_content: if not message.chat.has_protected_content:
await forward_msg(bot, message.reply_to_message) await reply.forward(reply.chat.id, message_thread_id=reply.message_thread_id)
else: else:
await reply.copy( await reply.copy(
reply.chat.id, reply.chat.id,
reply_to_message_id=message.reply_to_top_message_id, message_thread_id=message.message_thread_id,
) )
except (Forbidden, FloodWait, Exception): except (Forbidden, FloodWait, Exception):
return return
else: else:
await message.edit(lang("not_reply")) await message.edit(lang("not_reply"))
async def forward_msg(bot: Client, message: Message):
message_ids = [message.id]
await bot.invoke(
ForwardMessages(
to_peer=await bot.resolve_peer(message.chat.id),
from_peer=await bot.resolve_peer(message.chat.id),
id=message_ids,
silent=None,
random_id=[bot.rnd_id() for _ in message_ids],
schedule_date=None,
noforwards=None,
top_msg_id=message.reply_to_top_message_id,
)
)

View File

@ -181,6 +181,7 @@ async def plugin(message: Message):
file_name, file_name,
message.chat.id, message.chat.id,
reply_id, reply_id,
message_thread_id=message.message_thread_id,
thumb=f"pagermaid{sep}assets{sep}logo.jpg", thumb=f"pagermaid{sep}assets{sep}logo.jpg",
caption=f"<b>{lang('apt_name')}</b>\n\n" caption=f"<b>{lang('apt_name')}</b>\n\n"
f"PagerMaid-Pyro {message.parameter[1]} plugin.", f"PagerMaid-Pyro {message.parameter[1]} plugin.",

View File

@ -26,9 +26,9 @@ async def prune(client: Client, message: Message):
messages = [] messages = []
count = 0 count = 0
limit = message.id - message.reply_to_message.id + 1 limit = message.id - message.reply_to_message.id + 1
if message.reply_to_top_message_id: if message.message_thread_id:
func = client.get_discussion_replies( func = client.get_discussion_replies(
input_chat, message.reply_to_top_message_id, limit=limit input_chat, message.message_thread_id, limit=limit
) )
else: else:
func = client.get_chat_history(input_chat, limit=limit) func = client.get_chat_history(input_chat, limit=limit)
@ -185,5 +185,5 @@ async def send_prune_notify(bot: Client, message: Message, count_buffer, count):
return await bot.send_message( return await bot.send_message(
message.chat.id, message.chat.id,
f"{lang('spn_deleted')} {str(count_buffer)} / {str(count)} {lang('prune_hint2')}", f"{lang('spn_deleted')} {str(count_buffer)} / {str(count)} {lang('prune_hint2')}",
reply_to_message_id=message.reply_to_top_message_id, message_thread_id=message.message_thread_id,
) )

View File

@ -91,7 +91,8 @@ async def send_log(message: Message):
await upload_attachment( await upload_attachment(
"data/pagermaid.log.txt", "data/pagermaid.log.txt",
message.chat.id, message.chat.id,
message.reply_to_message_id or message.reply_to_top_message_id, message.reply_to_message_id,
message_thread_id=message.message_thread_id,
thumb=f"pagermaid{sep}assets{sep}logo.jpg", thumb=f"pagermaid{sep}assets{sep}logo.jpg",
caption=lang("send_log_caption"), caption=lang("send_log_caption"),
) )

View File

@ -19,6 +19,11 @@ __all__ = [
"AlreadyInConversationError", "AlreadyInConversationError",
"TimeoutConversationError", "TimeoutConversationError",
"ListenerCanceled", "ListenerCanceled",
"get_sudo_list",
"_status_sudo",
"Message",
"sqlite",
"safe_remove",
] ]
# init folders # init folders
if not exists("data"): if not exists("data"):

View File

@ -53,7 +53,7 @@ async def attach_log(plaintext, chat_id, file_name, reply_id=None, caption=None)
remove(file_name) remove(file_name)
async def upload_attachment(file_path, chat_id, reply_id, caption=None, thumb=None): async def upload_attachment(file_path, chat_id, reply_id, message_thread_id=None, caption=None, thumb=None):
"""Uploads a local attachment file.""" """Uploads a local attachment file."""
if not exists(file_path): if not exists(file_path):
return False return False
@ -61,6 +61,7 @@ async def upload_attachment(file_path, chat_id, reply_id, caption=None, thumb=No
await bot.send_document( await bot.send_document(
chat_id, chat_id,
file_path, file_path,
message_thread_id=message_thread_id,
thumb=thumb, thumb=thumb,
reply_to_message_id=reply_id, reply_to_message_id=reply_id,
caption=caption, caption=caption,

View File

@ -372,17 +372,6 @@ class Message(pyrogram.types.Message):
parsed = await pyrogram.types.Message.old_parse( parsed = await pyrogram.types.Message.old_parse(
client, message, users, chats, is_scheduled, replies client, message, users, chats, is_scheduled, replies
) # noqa ) # noqa
# forum topic
if isinstance(message, pyrogram.raw.types.Message):
parsed.forum_topic = getattr(message.reply_to, "forum_topic", None)
if (
message.reply_to
and parsed.forum_topic
and not message.reply_to.reply_to_top_id
):
parsed.reply_to_top_message_id = parsed.reply_to_message_id
parsed.reply_to_message_id = None
parsed.reply_to_message = None
# make message.text as message.caption # make message.text as message.caption
parsed.text = parsed.text or parsed.caption parsed.text = parsed.text or parsed.caption
return parsed return parsed