mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-27 16:45:19 +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
|
import pyrogram
|
||||||
from pyrogram import raw
|
from pyrogram import raw
|
||||||
from pyrogram import types
|
from pyrogram import types
|
||||||
|
from pyrogram import utils
|
||||||
|
|
||||||
|
|
||||||
class GetPinnedStories:
|
class GetPinnedStories:
|
||||||
@ -60,8 +61,9 @@ class GetPinnedStories:
|
|||||||
total = abs(limit) or (1 << 31)
|
total = abs(limit) or (1 << 31)
|
||||||
limit = min(100, total)
|
limit = min(100, total)
|
||||||
|
|
||||||
while True:
|
|
||||||
peer = await self.resolve_peer(chat_id)
|
peer = await self.resolve_peer(chat_id)
|
||||||
|
|
||||||
|
while True:
|
||||||
r = await self.invoke(
|
r = await self.invoke(
|
||||||
raw.functions.stories.GetPinnedStories(
|
raw.functions.stories.GetPinnedStories(
|
||||||
peer=peer,
|
peer=peer,
|
||||||
@ -73,6 +75,15 @@ class GetPinnedStories:
|
|||||||
if not r.stories:
|
if not r.stories:
|
||||||
return
|
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]
|
last = r.stories[-1]
|
||||||
offset_id = last.id
|
offset_id = last.id
|
||||||
|
|
||||||
@ -80,8 +91,8 @@ class GetPinnedStories:
|
|||||||
yield await types.Story._parse(
|
yield await types.Story._parse(
|
||||||
self,
|
self,
|
||||||
story,
|
story,
|
||||||
{i.id: i for i in r.users},
|
users,
|
||||||
{i.id: i for i in r.chats},
|
chats,
|
||||||
peer
|
peer
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -196,6 +196,7 @@ class Story(Object, Update):
|
|||||||
peer_id = utils.get_input_peer_id(peer)
|
peer_id = utils.get_input_peer_id(peer)
|
||||||
elif isinstance(peer, raw.types.InputPeerChannel):
|
elif isinstance(peer, raw.types.InputPeerChannel):
|
||||||
peer_id = utils.get_input_peer_id(peer)
|
peer_id = utils.get_input_peer_id(peer)
|
||||||
|
if peer_id not in chats:
|
||||||
r = await client.invoke(raw.functions.channels.GetChannels(id=[peer]))
|
r = await client.invoke(raw.functions.channels.GetChannels(id=[peer]))
|
||||||
chats.update({peer_id: r.chats[0]})
|
chats.update({peer_id: r.chats[0]})
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user