File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121import pyrogram
2222from pyrogram import raw
2323from pyrogram import types
24+ from pyrogram import utils
2425
2526
2627class GetPinnedStories :
@@ -60,8 +61,9 @@ async def get_pinned_stories(
6061 total = abs (limit ) or (1 << 31 )
6162 limit = min (100 , total )
6263
64+ peer = await self .resolve_peer (chat_id )
65+
6366 while True :
64- peer = await self .resolve_peer (chat_id )
6567 r = await self .invoke (
6668 raw .functions .stories .GetPinnedStories (
6769 peer = peer ,
@@ -73,15 +75,24 @@ async def get_pinned_stories(
7375 if not r .stories :
7476 return
7577
78+ users = {i .id : i for i in r .users }
79+ chats = {i .id : i for i in r .chats }
80+
81+ if isinstance (peer , raw .types .InputPeerChannel ):
82+ peer_id = utils .get_input_peer_id (peer )
83+ if peer_id not in r .chats :
84+ channel = await self .invoke (raw .functions .channels .GetChannels (id = [peer ]))
85+ chats .update ({peer_id : channel .chats [0 ]})
86+
7687 last = r .stories [- 1 ]
7788 offset_id = last .id
7889
7990 for story in r .stories :
8091 yield await types .Story ._parse (
8192 self ,
8293 story ,
83- { i . id : i for i in r . users } ,
84- { i . id : i for i in r . chats } ,
94+ users ,
95+ chats ,
8596 peer
8697 )
8798
Original file line number Diff line number Diff line change @@ -196,8 +196,9 @@ async def _parse(
196196 peer_id = utils .get_input_peer_id (peer )
197197 elif isinstance (peer , raw .types .InputPeerChannel ):
198198 peer_id = utils .get_input_peer_id (peer )
199- r = await client .invoke (raw .functions .channels .GetChannels (id = [peer ]))
200- chats .update ({peer_id : r .chats [0 ]})
199+ if peer_id not in chats :
200+ r = await client .invoke (raw .functions .channels .GetChannels (id = [peer ]))
201+ chats .update ({peer_id : r .chats [0 ]})
201202 else :
202203 peer_id = utils .get_raw_peer_id (peer )
203204
You can’t perform that action at this time.
0 commit comments