mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 04:35:24 +00:00
Request GetChannels as required
This commit is contained in:
parent
01290e882f
commit
dcdf65ebf3
@ -21,6 +21,7 @@ from typing import AsyncGenerator, Union, Optional
|
||||
import pyrogram
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
from pyrogram import utils
|
||||
|
||||
|
||||
class GetPinnedStories:
|
||||
@ -60,8 +61,9 @@ class GetPinnedStories:
|
||||
total = abs(limit) or (1 << 31)
|
||||
limit = min(100, total)
|
||||
|
||||
peer = await self.resolve_peer(chat_id)
|
||||
|
||||
while True:
|
||||
peer = await self.resolve_peer(chat_id)
|
||||
r = await self.invoke(
|
||||
raw.functions.stories.GetPinnedStories(
|
||||
peer=peer,
|
||||
@ -73,6 +75,15 @@ class GetPinnedStories:
|
||||
if not r.stories:
|
||||
return
|
||||
|
||||
users = {i.id: i for i in r.users}
|
||||
chats = {i.id: i for i in r.chats}
|
||||
|
||||
if isinstance(peer, raw.types.InputPeerChannel):
|
||||
peer_id = utils.get_input_peer_id(peer)
|
||||
if peer_id not in r.chats:
|
||||
channel = await self.invoke(raw.functions.channels.GetChannels(id=[peer]))
|
||||
chats.update({peer_id: channel.chats[0]})
|
||||
|
||||
last = r.stories[-1]
|
||||
offset_id = last.id
|
||||
|
||||
@ -80,8 +91,8 @@ class GetPinnedStories:
|
||||
yield await types.Story._parse(
|
||||
self,
|
||||
story,
|
||||
{i.id: i for i in r.users},
|
||||
{i.id: i for i in r.chats},
|
||||
users,
|
||||
chats,
|
||||
peer
|
||||
)
|
||||
|
||||
|
@ -196,8 +196,9 @@ class Story(Object, Update):
|
||||
peer_id = utils.get_input_peer_id(peer)
|
||||
elif isinstance(peer, raw.types.InputPeerChannel):
|
||||
peer_id = utils.get_input_peer_id(peer)
|
||||
r = await client.invoke(raw.functions.channels.GetChannels(id=[peer]))
|
||||
chats.update({peer_id: r.chats[0]})
|
||||
if peer_id not in chats:
|
||||
r = await client.invoke(raw.functions.channels.GetChannels(id=[peer]))
|
||||
chats.update({peer_id: r.chats[0]})
|
||||
else:
|
||||
peer_id = utils.get_raw_peer_id(peer)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user