mirror of
https://github.com/TeamPGM/PagerMaid-Pyro.git
synced 2024-11-22 07:47:42 +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
|
import pyromod.listen
|
||||||
from pyrogram import Client
|
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 = {}
|
CMD_LIST = {}
|
||||||
module_dir = __path__[0]
|
module_dir = __path__[0]
|
||||||
working_dir = getcwd()
|
working_dir = getcwd()
|
||||||
@ -69,6 +69,7 @@ bot = Client(
|
|||||||
# temp fix topics group
|
# temp fix topics group
|
||||||
setattr(pyrogram.types.Message, "old_parse", getattr(pyrogram.types.Message, "_parse"))
|
setattr(pyrogram.types.Message, "old_parse", getattr(pyrogram.types.Message, "_parse"))
|
||||||
setattr(pyrogram.types.Message, "_parse", temp_fix)
|
setattr(pyrogram.types.Message, "_parse", temp_fix)
|
||||||
|
pyrogram.Client.read_chat_history = read_chat_history
|
||||||
bot.job = scheduler
|
bot.job = scheduler
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,9 +21,12 @@ async def prune(client: Client, message: Message):
|
|||||||
input_chat = message.chat.id
|
input_chat = message.chat.id
|
||||||
messages = []
|
messages = []
|
||||||
count = 0
|
count = 0
|
||||||
async for msg in client.get_chat_history(
|
limit = message.id - message.reply_to_message.id + 1
|
||||||
input_chat,
|
if message.reply_to_top_message_id:
|
||||||
limit=message.id - message.reply_to_message.id + 1):
|
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:
|
if msg.id < message.reply_to_message.id:
|
||||||
break
|
break
|
||||||
messages.append(msg.id)
|
messages.append(msg.id)
|
||||||
|
@ -178,13 +178,13 @@ def get_uptime():
|
|||||||
minutes, seconds = divmod(remainder, 60)
|
minutes, seconds = divmod(remainder, 60)
|
||||||
days, hours = divmod(hours, 24)
|
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'}"
|
return f"{num} {text}{'' if num == 1 else 's'}"
|
||||||
|
|
||||||
d = includeS("day", days)
|
d = include_s("day", days)
|
||||||
h = includeS("hour", hours)
|
h = include_s("hour", hours)
|
||||||
m = includeS("minute", minutes)
|
m = include_s("minute", minutes)
|
||||||
s = includeS("second", seconds)
|
s = include_s("second", seconds)
|
||||||
|
|
||||||
if days:
|
if days:
|
||||||
output = f"{d}, {h}, {m} and {s}"
|
output = f"{d}, {h}, {m} and {s}"
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
|
import contextlib
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
|
from pyrogram.errors import BadRequest
|
||||||
|
|
||||||
|
|
||||||
async def temp_fix(
|
async def temp_fix(
|
||||||
@ -17,3 +21,47 @@ async def temp_fix(
|
|||||||
parsed.reply_to_message_id = None
|
parsed.reply_to_message_id = None
|
||||||
parsed.reply_to_message = None
|
parsed.reply_to_message = None
|
||||||
return parsed
|
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
|
TgCrypto==1.2.5
|
||||||
Pillow>=8.4.0
|
Pillow>=8.4.0
|
||||||
pytz>=2021.3
|
pytz>=2021.3
|
||||||
|
Loading…
Reference in New Issue
Block a user