From 0e7379ecc8b28495e70ccee8c57f38b634e69b6a Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sun, 4 Feb 2024 15:33:01 +0800 Subject: [PATCH] :bookmark: Update to v1.4.8 --- pagermaid/__init__.py | 4 ++-- pagermaid/modules/account.py | 21 ++++++++++++--------- pagermaid/modules/message.py | 20 ++------------------ pagermaid/modules/plugin.py | 1 + pagermaid/modules/prune.py | 6 +++--- pagermaid/modules/system.py | 3 ++- pagermaid/single_utils.py | 5 +++++ pagermaid/utils.py | 3 ++- pyromod/listen/listen.py | 11 ----------- 9 files changed, 29 insertions(+), 45 deletions(-) diff --git a/pagermaid/__init__.py b/pagermaid/__init__.py index 8d5fed4..447683f 100644 --- a/pagermaid/__init__.py +++ b/pagermaid/__init__.py @@ -22,8 +22,8 @@ import pyromod.listen from pyrogram import Client -pgm_version = "1.4.7" -pgm_version_code = 1407 +pgm_version = "1.4.8" +pgm_version_code = 1408 CMD_LIST = {} module_dir = __path__[0] working_dir = getcwd() diff --git a/pagermaid/modules/account.py b/pagermaid/modules/account.py index 02ca108..65456cd 100644 --- a/pagermaid/modules/account.py +++ b/pagermaid/modules/account.py @@ -85,19 +85,22 @@ async def profile(client: Client, message: Message): f"{lang('profile_type')}: {user_type} \n" 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 = ( message.reply_to_message.id if message.reply_to_message - else message.reply_to_top_message_id + else None ) - try: - await client.send_photo( - message.chat.id, photo, caption=caption, reply_to_message_id=reply_to - ) - await message.delete() - return remove(photo) - except TypeError: + if photo: + try: + await client.send_photo( + message.chat.id, photo, caption=caption, reply_to_message_id=reply_to + ) + await message.delete() + return remove(photo) + except TypeError: + await message.edit(caption) + else: await message.edit(caption) diff --git a/pagermaid/modules/message.py b/pagermaid/modules/message.py index 4ee27dd..2dac80d 100644 --- a/pagermaid/modules/message.py +++ b/pagermaid/modules/message.py @@ -169,29 +169,13 @@ async def re(bot: Client, message: Message): for _ in range(num): try: 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: await reply.copy( reply.chat.id, - reply_to_message_id=message.reply_to_top_message_id, + message_thread_id=message.message_thread_id, ) except (Forbidden, FloodWait, Exception): return else: 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, - ) - ) diff --git a/pagermaid/modules/plugin.py b/pagermaid/modules/plugin.py index f57e830..82d478c 100644 --- a/pagermaid/modules/plugin.py +++ b/pagermaid/modules/plugin.py @@ -181,6 +181,7 @@ async def plugin(message: Message): file_name, message.chat.id, reply_id, + message_thread_id=message.message_thread_id, thumb=f"pagermaid{sep}assets{sep}logo.jpg", caption=f"{lang('apt_name')}\n\n" f"PagerMaid-Pyro {message.parameter[1]} plugin.", diff --git a/pagermaid/modules/prune.py b/pagermaid/modules/prune.py index 63d108f..f8b0971 100644 --- a/pagermaid/modules/prune.py +++ b/pagermaid/modules/prune.py @@ -26,9 +26,9 @@ async def prune(client: Client, message: Message): messages = [] count = 0 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( - input_chat, message.reply_to_top_message_id, limit=limit + input_chat, message.message_thread_id, limit=limit ) else: 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( message.chat.id, 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, ) diff --git a/pagermaid/modules/system.py b/pagermaid/modules/system.py index 15a4e49..2645f53 100644 --- a/pagermaid/modules/system.py +++ b/pagermaid/modules/system.py @@ -91,7 +91,8 @@ async def send_log(message: Message): await upload_attachment( "data/pagermaid.log.txt", 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", caption=lang("send_log_caption"), ) diff --git a/pagermaid/single_utils.py b/pagermaid/single_utils.py index 87c2b88..0cbfdc4 100644 --- a/pagermaid/single_utils.py +++ b/pagermaid/single_utils.py @@ -19,6 +19,11 @@ "AlreadyInConversationError", "TimeoutConversationError", "ListenerCanceled", + "get_sudo_list", + "_status_sudo", + "Message", + "sqlite", + "safe_remove", ] # init folders if not exists("data"): diff --git a/pagermaid/utils.py b/pagermaid/utils.py index d8c9364..729b06a 100644 --- a/pagermaid/utils.py +++ b/pagermaid/utils.py @@ -53,7 +53,7 @@ async def attach_log(plaintext, chat_id, file_name, reply_id=None, caption=None) 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.""" if not exists(file_path): return False @@ -61,6 +61,7 @@ async def upload_attachment(file_path, chat_id, reply_id, caption=None, thumb=No await bot.send_document( chat_id, file_path, + message_thread_id=message_thread_id, thumb=thumb, reply_to_message_id=reply_id, caption=caption, diff --git a/pyromod/listen/listen.py b/pyromod/listen/listen.py index 9094c41..e90e842 100644 --- a/pyromod/listen/listen.py +++ b/pyromod/listen/listen.py @@ -372,17 +372,6 @@ async def _parse( parsed = await pyrogram.types.Message.old_parse( client, message, users, chats, is_scheduled, replies ) # 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 parsed.text = parsed.text or parsed.caption return parsed