Skip to content

Commit

Permalink
🔖 Update to v1.4.8
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Feb 4, 2024
1 parent 3ddd16b commit 0e7379e
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 45 deletions.
4 changes: 2 additions & 2 deletions pagermaid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
21 changes: 12 additions & 9 deletions pagermaid/modules/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
20 changes: 2 additions & 18 deletions pagermaid/modules/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)
1 change: 1 addition & 0 deletions pagermaid/modules/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"<b>{lang('apt_name')}</b>\n\n"
f"PagerMaid-Pyro {message.parameter[1]} plugin.",
Expand Down
6 changes: 3 additions & 3 deletions pagermaid/modules/prune.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
)
3 changes: 2 additions & 1 deletion pagermaid/modules/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)
Expand Down
5 changes: 5 additions & 0 deletions pagermaid/single_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"AlreadyInConversationError",
"TimeoutConversationError",
"ListenerCanceled",
"get_sudo_list",
"_status_sudo",
"Message",
"sqlite",
"safe_remove",
]
# init folders
if not exists("data"):
Expand Down
3 changes: 2 additions & 1 deletion pagermaid/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ 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
try:
await bot.send_document(
chat_id,
file_path,
message_thread_id=message_thread_id,
thumb=thumb,
reply_to_message_id=reply_id,
caption=caption,
Expand Down
11 changes: 0 additions & 11 deletions pyromod/listen/listen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0e7379e

Please sign in to comment.