Skip to content

Commit 6d0e2f7

Browse files
committed
Fix minified peers being erroneously stored because of server changes
1 parent 840a9d1 commit 6d0e2f7

1 file changed

Lines changed: 9 additions & 38 deletions

File tree

pyrogram/client/client.py

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,62 +1162,33 @@ def set_parse_mode(self, parse_mode: Union[str, None] = "combined"):
11621162

11631163
self.parse_mode = parse_mode
11641164

1165-
def fetch_peers(
1166-
self,
1167-
peers: List[
1168-
Union[
1169-
types.User,
1170-
types.Chat, types.ChatForbidden,
1171-
types.Channel, types.ChannelForbidden
1172-
]
1173-
]
1174-
) -> bool:
1165+
def fetch_peers(self, peers: List[Union[types.User, types.Chat, types.Channel]]) -> bool:
11751166
is_min = False
11761167
parsed_peers = []
11771168

11781169
for peer in peers:
1170+
if getattr(peer, "min", False):
1171+
is_min = True
1172+
continue
1173+
11791174
username = None
11801175
phone_number = None
11811176

11821177
if isinstance(peer, types.User):
11831178
peer_id = peer.id
11841179
access_hash = peer.access_hash
1185-
1186-
username = peer.username
1180+
username = (peer.username or "").lower() or None
11871181
phone_number = peer.phone
1188-
1189-
if peer.bot:
1190-
peer_type = "bot"
1191-
else:
1192-
peer_type = "user"
1193-
1194-
if access_hash is None:
1195-
is_min = True
1196-
continue
1197-
1198-
if username is not None:
1199-
username = username.lower()
1182+
peer_type = "bot" if peer.bot else "user"
12001183
elif isinstance(peer, (types.Chat, types.ChatForbidden)):
12011184
peer_id = -peer.id
12021185
access_hash = 0
12031186
peer_type = "group"
12041187
elif isinstance(peer, (types.Channel, types.ChannelForbidden)):
12051188
peer_id = utils.get_channel_id(peer.id)
12061189
access_hash = peer.access_hash
1207-
1208-
username = getattr(peer, "username", None)
1209-
1210-
if peer.broadcast:
1211-
peer_type = "channel"
1212-
else:
1213-
peer_type = "supergroup"
1214-
1215-
if access_hash is None:
1216-
is_min = True
1217-
continue
1218-
1219-
if username is not None:
1220-
username = username.lower()
1190+
username = (getattr(peer, "username", None) or "").lower() or None
1191+
peer_type = "channel" if peer.broadcast else "supergroup"
12211192
else:
12221193
continue
12231194

0 commit comments

Comments
 (0)