Skip to content

Commit 2fc432b

Browse files
committed
Fix topics errors.
Signed-off-by: Aliwoto <[email protected]>
1 parent 382c639 commit 2fc432b

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

pyrogram/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
__version__ = "2.0.142"
19+
__version__ = "2.0.143"
2020
__license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)"
2121
__copyright__ = "Copyright (C) 2017-present Dan <https://github.com/delivrance>"
2222

pyrogram/methods/chats/get_forum_topics_by_id.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,28 +70,33 @@ async def get_forum_topics_by_id(
7070
)
7171
)
7272

73-
topics = types.List()
73+
topics_list = []
74+
parsed_messages = {}
7475
users = {u.id: u for u in getattr(r, "users", [])}
7576
chats = {c.id: c for c in getattr(r, "chats", [])}
77+
topics = {t.id: t for t in getattr(r, "topics", [])}
7678
messages = {m.id: m for m in getattr(r, "messages", [])}
7779

78-
for message in messages:
80+
for message in messages.values():
7981
if isinstance(message, raw.types.MessageEmpty):
8082
continue
8183

82-
messages[message.id] = await types.Message._parse(
83-
client=self,
84-
message=message,
85-
users=users,
86-
chats=chats,
87-
replies=0
88-
)
89-
90-
for current in getattr(r, "topics", []):
91-
topics.append(types.ForumTopic._parse(
84+
try:
85+
parsed_messages[message.id] = await types.Message._parse(
86+
client=self,
87+
message=message,
88+
users=users,
89+
chats=chats,
90+
replies=0,
91+
from_topic=True if len(topics_list) != 1 else topics_list[topic_ids[0]]
92+
)
93+
except: pass
94+
95+
for current in topics.values():
96+
topics_list.append(types.ForumTopic._parse(
9297
self,
9398
forum_topic=current,
94-
messages=messages,
99+
messages=parsed_messages,
95100
users=users,
96101
chats=chats
97102
))

0 commit comments

Comments
 (0)