mirror of
https://github.com/TeamPGM/PagerMaid-Pyro.git
synced 2024-11-21 19:38:17 +00:00
🔖 Update to v1.2.22
This commit is contained in:
parent
0a4dda08ab
commit
eccf9b13c0
@ -13,9 +13,9 @@ from pagermaid.scheduler import scheduler
|
||||
import pyromod.listen
|
||||
from pyrogram import Client
|
||||
|
||||
from pyromod.listen.temp_fix import temp_fix
|
||||
from pyromod.listen.temp_fix import temp_fix, read_chat_history
|
||||
|
||||
pgm_version = "1.2.21"
|
||||
pgm_version = "1.2.22"
|
||||
CMD_LIST = {}
|
||||
module_dir = __path__[0]
|
||||
working_dir = getcwd()
|
||||
@ -69,6 +69,7 @@ bot = Client(
|
||||
# temp fix topics group
|
||||
setattr(pyrogram.types.Message, "old_parse", getattr(pyrogram.types.Message, "_parse"))
|
||||
setattr(pyrogram.types.Message, "_parse", temp_fix)
|
||||
pyrogram.Client.read_chat_history = read_chat_history
|
||||
bot.job = scheduler
|
||||
|
||||
|
||||
|
@ -21,9 +21,12 @@ async def prune(client: Client, message: Message):
|
||||
input_chat = message.chat.id
|
||||
messages = []
|
||||
count = 0
|
||||
async for msg in client.get_chat_history(
|
||||
input_chat,
|
||||
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:
|
||||
func = client.get_discussion_replies(input_chat, message.reply_to_top_message_id, limit=limit)
|
||||
else:
|
||||
func = client.get_chat_history(input_chat, limit=limit)
|
||||
async for msg in func:
|
||||
if msg.id < message.reply_to_message.id:
|
||||
break
|
||||
messages.append(msg.id)
|
||||
|
@ -178,13 +178,13 @@ def get_uptime():
|
||||
minutes, seconds = divmod(remainder, 60)
|
||||
days, hours = divmod(hours, 24)
|
||||
|
||||
def includeS(text: str, num: int):
|
||||
def include_s(text: str, num: int):
|
||||
return f"{num} {text}{'' if num == 1 else 's'}"
|
||||
|
||||
d = includeS("day", days)
|
||||
h = includeS("hour", hours)
|
||||
m = includeS("minute", minutes)
|
||||
s = includeS("second", seconds)
|
||||
d = include_s("day", days)
|
||||
h = include_s("hour", hours)
|
||||
m = include_s("minute", minutes)
|
||||
s = include_s("second", seconds)
|
||||
|
||||
if days:
|
||||
output = f"{d}, {h}, {m} and {s}"
|
||||
|
@ -1,13 +1,17 @@
|
||||
import contextlib
|
||||
from typing import Union
|
||||
|
||||
import pyrogram
|
||||
from pyrogram.errors import BadRequest
|
||||
|
||||
|
||||
async def temp_fix(
|
||||
client: "pyrogram.Client",
|
||||
message: pyrogram.raw.base.Message,
|
||||
users: dict,
|
||||
chats: dict,
|
||||
is_scheduled: bool = False,
|
||||
replies: int = 1
|
||||
client: "pyrogram.Client",
|
||||
message: pyrogram.raw.base.Message,
|
||||
users: dict,
|
||||
chats: dict,
|
||||
is_scheduled: bool = False,
|
||||
replies: int = 1
|
||||
):
|
||||
parsed = await pyrogram.types.Message.old_parse(client, message, users, chats, is_scheduled, replies) # noqa
|
||||
if isinstance(message, pyrogram.raw.types.Message) and message.reply_to \
|
||||
@ -17,3 +21,47 @@ async def temp_fix(
|
||||
parsed.reply_to_message_id = None
|
||||
parsed.reply_to_message = None
|
||||
return parsed
|
||||
|
||||
|
||||
async def read_chat_history(
|
||||
self: "pyrogram.Client",
|
||||
chat_id: Union[int, str],
|
||||
max_id: int = 0
|
||||
) -> bool:
|
||||
|
||||
peer = await self.resolve_peer(chat_id)
|
||||
|
||||
if isinstance(peer, pyrogram.raw.types.InputPeerChannel):
|
||||
q = pyrogram.raw.functions.channels.ReadHistory(
|
||||
channel=peer,
|
||||
max_id=max_id
|
||||
)
|
||||
else:
|
||||
q = pyrogram.raw.functions.messages.ReadHistory(
|
||||
peer=peer,
|
||||
max_id=max_id
|
||||
)
|
||||
|
||||
await self.invoke(q)
|
||||
|
||||
if isinstance(peer, pyrogram.raw.types.InputPeerChannel):
|
||||
with contextlib.suppress(BadRequest):
|
||||
topics: pyrogram.raw.types.messages.ForumTopics = await self.invoke(
|
||||
pyrogram.raw.functions.channels.GetForumTopics(
|
||||
channel=peer,
|
||||
offset_date=0,
|
||||
offset_id=0,
|
||||
offset_topic=0,
|
||||
limit=0
|
||||
)
|
||||
)
|
||||
for i in topics.topics:
|
||||
await self.invoke(
|
||||
pyrogram.raw.functions.messages.ReadDiscussion(
|
||||
peer=peer,
|
||||
msg_id=i.id,
|
||||
read_max_id=i.read_inbox_max_id + i.unread_count,
|
||||
)
|
||||
)
|
||||
|
||||
return True
|
||||
|
@ -1,4 +1,4 @@
|
||||
pyrogram==2.0.93
|
||||
pyrogram==2.0.95
|
||||
TgCrypto==1.2.5
|
||||
Pillow>=8.4.0
|
||||
pytz>=2021.3
|
||||
|
Loading…
Reference in New Issue
Block a user