Skip to content

Commit b1dc031

Browse files
committed
Update API schema to Layer 126
1 parent e01ac7a commit b1dc031

File tree

8 files changed

+31
-23
lines changed

8 files changed

+31
-23
lines changed

compiler/api/source/main_api.tl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,8 @@ channelParticipant#15ebac1d user_id:int date:int = ChannelParticipant;
598598
channelParticipantSelf#a3289a6d user_id:int inviter_id:int date:int = ChannelParticipant;
599599
channelParticipantCreator#447dca4b flags:# user_id:int admin_rights:ChatAdminRights rank:flags.0?string = ChannelParticipant;
600600
channelParticipantAdmin#ccbebbaf flags:# can_edit:flags.0?true self:flags.1?true user_id:int inviter_id:flags.1?int promoted_by:int date:int admin_rights:ChatAdminRights rank:flags.2?string = ChannelParticipant;
601-
channelParticipantBanned#1c0facaf flags:# left:flags.0?true user_id:int kicked_by:int date:int banned_rights:ChatBannedRights = ChannelParticipant;
602-
channelParticipantLeft#c3c6796b user_id:int = ChannelParticipant;
601+
channelParticipantBanned#50a1dfd6 flags:# left:flags.0?true peer:Peer kicked_by:int date:int banned_rights:ChatBannedRights = ChannelParticipant;
602+
channelParticipantLeft#1b03f006 peer:Peer = ChannelParticipant;
603603

604604
channelParticipantsRecent#de3f3c79 = ChannelParticipantsFilter;
605605
channelParticipantsAdmins#b4608969 = ChannelParticipantsFilter;
@@ -610,10 +610,10 @@ channelParticipantsSearch#656ac4b q:string = ChannelParticipantsFilter;
610610
channelParticipantsContacts#bb6ae88d q:string = ChannelParticipantsFilter;
611611
channelParticipantsMentions#e04b5ceb flags:# q:flags.0?string top_msg_id:flags.1?int = ChannelParticipantsFilter;
612612

613-
channels.channelParticipants#f56ee2a8 count:int participants:Vector<ChannelParticipant> users:Vector<User> = channels.ChannelParticipants;
613+
channels.channelParticipants#9ab0feaf count:int participants:Vector<ChannelParticipant> chats:Vector<Chat> users:Vector<User> = channels.ChannelParticipants;
614614
channels.channelParticipantsNotModified#f0173fe9 = channels.ChannelParticipants;
615615

616-
channels.channelParticipant#d0d9b163 participant:ChannelParticipant users:Vector<User> = channels.ChannelParticipant;
616+
channels.channelParticipant#dfb80317 participant:ChannelParticipant chats:Vector<Chat> users:Vector<User> = channels.ChannelParticipant;
617617

618618
help.termsOfService#780a0310 flags:# popup:flags.0?true id:DataJSON text:string entities:Vector<MessageEntity> min_age_confirm:flags.1?int = help.TermsOfService;
619619

@@ -1535,7 +1535,7 @@ channels.deleteUserHistory#d10dd71b channel:InputChannel user_id:InputUser = mes
15351535
channels.reportSpam#fe087810 channel:InputChannel user_id:InputUser id:Vector<int> = Bool;
15361536
channels.getMessages#ad8c9a23 channel:InputChannel id:Vector<InputMessage> = messages.Messages;
15371537
channels.getParticipants#123e05e9 channel:InputChannel filter:ChannelParticipantsFilter offset:int limit:int hash:int = channels.ChannelParticipants;
1538-
channels.getParticipant#546dd7a6 channel:InputChannel user_id:InputUser = channels.ChannelParticipant;
1538+
channels.getParticipant#a0ab6cc6 channel:InputChannel participant:InputPeer = channels.ChannelParticipant;
15391539
channels.getChannels#a7f6bbb id:Vector<InputChannel> = messages.Chats;
15401540
channels.getFullChannel#8736a09 channel:InputChannel = messages.ChatFull;
15411541
channels.createChannel#3d5fb10f flags:# broadcast:flags.0?true megagroup:flags.1?true for_import:flags.3?true title:string about:string geo_point:flags.2?InputGeoPoint address:flags.2?string = Updates;
@@ -1551,7 +1551,7 @@ channels.deleteChannel#c0111fe3 channel:InputChannel = Updates;
15511551
channels.exportMessageLink#e63fadeb flags:# grouped:flags.0?true thread:flags.1?true channel:InputChannel id:int = ExportedMessageLink;
15521552
channels.toggleSignatures#1f69b606 channel:InputChannel enabled:Bool = Updates;
15531553
channels.getAdminedPublicChannels#f8b036af flags:# by_location:flags.0?true check_limit:flags.1?true = messages.Chats;
1554-
channels.editBanned#72796912 channel:InputChannel user_id:InputUser banned_rights:ChatBannedRights = Updates;
1554+
channels.editBanned#96e6cd81 channel:InputChannel participant:InputPeer banned_rights:ChatBannedRights = Updates;
15551555
channels.getAdminLog#33ddf480 flags:# channel:InputChannel q:string events_filter:flags.0?ChannelAdminLogEventsFilter admins:flags.1?Vector<InputUser> max_id:long min_id:long limit:int = channels.AdminLogResults;
15561556
channels.setStickers#ea8ca4f9 channel:InputChannel stickerset:InputStickerSet = Bool;
15571557
channels.readMessageContents#eab5dc38 channel:InputChannel id:Vector<int> = Bool;
@@ -1623,4 +1623,4 @@ stats.getMegagroupStats#dcdf8607 flags:# dark:flags.0?true channel:InputChannel
16231623
stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;
16241624
stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats;
16251625

1626-
// LAYER 125
1626+
// LAYER 126

pyrogram/methods/chats/get_chat_member.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ async def get_chat_member(
6464
users = {i.id: i for i in r.users}
6565

6666
for member in members:
67-
member = types.ChatMember._parse(self, member, users)
67+
member = types.ChatMember._parse(self, member, users, {})
6868

6969
if isinstance(user, raw.types.InputPeerSelf):
7070
if member.user.is_self:
@@ -78,12 +78,13 @@ async def get_chat_member(
7878
r = await self.send(
7979
raw.functions.channels.GetParticipant(
8080
channel=chat,
81-
user_id=user
81+
participant=user
8282
)
8383
)
8484

8585
users = {i.id: i for i in r.users}
86+
chats = {i.id: i for i in r.chats}
8687

87-
return types.ChatMember._parse(self, r.participant, users)
88+
return types.ChatMember._parse(self, r.participant, users, chats)
8889
else:
8990
raise ValueError(f'The chat_id "{chat_id}" belongs to a user')

pyrogram/methods/chats/get_chat_members.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ async def get_chat_members(
115115
members = r.full_chat.participants.participants
116116
users = {i.id: i for i in r.users}
117117

118-
return types.List(types.ChatMember._parse(self, member, users) for member in members)
118+
return types.List(types.ChatMember._parse(self, member, users, {}) for member in members)
119119
elif isinstance(peer, raw.types.InputPeerChannel):
120120
filter = filter.lower()
121121

@@ -147,7 +147,8 @@ async def get_chat_members(
147147

148148
members = r.participants
149149
users = {i.id: i for i in r.users}
150+
chats = {i.id: i for i in r.chats}
150151

151-
return types.List(types.ChatMember._parse(self, member, users) for member in members)
152+
return types.List(types.ChatMember._parse(self, member, users, chats) for member in members)
152153
else:
153154
raise ValueError(f'The chat_id "{chat_id}" belongs to a user')

pyrogram/methods/chats/kick_chat_member.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async def kick_chat_member(
7575
r = await self.send(
7676
raw.functions.channels.EditBanned(
7777
channel=chat_peer,
78-
user_id=user_peer,
78+
participant=user_peer,
7979
banned_rights=raw.types.ChatBannedRights(
8080
until_date=until_date,
8181
view_messages=True,

pyrogram/methods/chats/unban_chat_member.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def unban_chat_member(
5252
await self.send(
5353
raw.functions.channels.EditBanned(
5454
channel=await self.resolve_peer(chat_id),
55-
user_id=await self.resolve_peer(user_id),
55+
participant=await self.resolve_peer(user_id),
5656
banned_rights=raw.types.ChatBannedRights(
5757
until_date=0
5858
)

pyrogram/types/user_and_chats/chat_event.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,17 +475,17 @@ async def _parse(
475475
action = ChatEventAction.MESSAGE_EDITED.value
476476

477477
elif isinstance(action, raw.types.ChannelAdminLogEventActionParticipantInvite):
478-
invited_member = types.ChatMember._parse(client, action.participant, users)
478+
invited_member = types.ChatMember._parse(client, action.participant, users, chats)
479479
action = ChatEventAction.MEMBER_INVITED.value
480480

481481
elif isinstance(action, raw.types.ChannelAdminLogEventActionParticipantToggleAdmin):
482-
old_admin_rights = types.ChatMember._parse(client, action.prev_participant, users)
483-
new_admin_rights = types.ChatMember._parse(client, action.new_participant, users)
482+
old_admin_rights = types.ChatMember._parse(client, action.prev_participant, users, chats)
483+
new_admin_rights = types.ChatMember._parse(client, action.new_participant, users, chats)
484484
action = ChatEventAction.ADMIN_RIGHTS_CHANGED.value
485485

486486
elif isinstance(action, raw.types.ChannelAdminLogEventActionParticipantToggleBan):
487-
old_member_permissions = types.ChatMember._parse(client, action.prev_participant, users)
488-
new_member_permissions = types.ChatMember._parse(client, action.new_participant, users)
487+
old_member_permissions = types.ChatMember._parse(client, action.prev_participant, users, chats)
488+
new_member_permissions = types.ChatMember._parse(client, action.new_participant, users, chats)
489489
action = ChatEventAction.MEMBER_PERMISSIONS_CHANGED.value
490490

491491
elif isinstance(action, raw.types.ChannelAdminLogEventActionStopPoll):

pyrogram/types/user_and_chats/chat_member.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,14 @@ def __init__(
212212
self.can_send_polls = can_send_polls
213213

214214
@staticmethod
215-
def _parse(client, member, users) -> "ChatMember":
216-
user = types.User._parse(client, users[member.user_id])
215+
def _parse(client, member, users, chats) -> "ChatMember":
216+
if not isinstance(member, (raw.types.ChannelParticipantBanned, raw.types.ChannelParticipantLeft)):
217+
user = types.User._parse(client, users[member.user_id])
218+
else:
219+
if isinstance(member.peer, raw.types.PeerUser):
220+
user = types.User._parse(client, users[member.peer.user_id])
221+
else:
222+
user = None
217223

218224
invited_by = (
219225
types.User._parse(client, users[member.inviter_id])

pyrogram/types/user_and_chats/chat_member_updated.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ def _parse(
8282
invite_link = None
8383

8484
if update.prev_participant:
85-
old_chat_member = types.ChatMember._parse(client, update.prev_participant, users)
85+
old_chat_member = types.ChatMember._parse(client, update.prev_participant, users, chats)
8686

8787
if update.new_participant:
88-
new_chat_member = types.ChatMember._parse(client, update.new_participant, users)
88+
new_chat_member = types.ChatMember._parse(client, update.new_participant, users, chats)
8989

9090
if update.invite:
9191
invite_link = types.ChatInviteLink._parse(client, update.invite, users)

0 commit comments

Comments
 (0)