Update API schema to Layer 126

This commit is contained in:
Dan 2021-03-21 16:32:10 +01:00
parent e01ac7a3d3
commit b1dc0315a1
8 changed files with 31 additions and 23 deletions

View File

@ -598,8 +598,8 @@ channelParticipant#15ebac1d user_id:int date:int = ChannelParticipant;
channelParticipantSelf#a3289a6d user_id:int inviter_id:int date:int = ChannelParticipant; channelParticipantSelf#a3289a6d user_id:int inviter_id:int date:int = ChannelParticipant;
channelParticipantCreator#447dca4b flags:# user_id:int admin_rights:ChatAdminRights rank:flags.0?string = ChannelParticipant; channelParticipantCreator#447dca4b flags:# user_id:int admin_rights:ChatAdminRights rank:flags.0?string = ChannelParticipant;
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; 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;
channelParticipantBanned#1c0facaf flags:# left:flags.0?true user_id:int kicked_by:int date:int banned_rights:ChatBannedRights = ChannelParticipant; channelParticipantBanned#50a1dfd6 flags:# left:flags.0?true peer:Peer kicked_by:int date:int banned_rights:ChatBannedRights = ChannelParticipant;
channelParticipantLeft#c3c6796b user_id:int = ChannelParticipant; channelParticipantLeft#1b03f006 peer:Peer = ChannelParticipant;
channelParticipantsRecent#de3f3c79 = ChannelParticipantsFilter; channelParticipantsRecent#de3f3c79 = ChannelParticipantsFilter;
channelParticipantsAdmins#b4608969 = ChannelParticipantsFilter; channelParticipantsAdmins#b4608969 = ChannelParticipantsFilter;
@ -610,10 +610,10 @@ channelParticipantsSearch#656ac4b q:string = ChannelParticipantsFilter;
channelParticipantsContacts#bb6ae88d q:string = ChannelParticipantsFilter; channelParticipantsContacts#bb6ae88d q:string = ChannelParticipantsFilter;
channelParticipantsMentions#e04b5ceb flags:# q:flags.0?string top_msg_id:flags.1?int = ChannelParticipantsFilter; channelParticipantsMentions#e04b5ceb flags:# q:flags.0?string top_msg_id:flags.1?int = ChannelParticipantsFilter;
channels.channelParticipants#f56ee2a8 count:int participants:Vector<ChannelParticipant> users:Vector<User> = channels.ChannelParticipants; channels.channelParticipants#9ab0feaf count:int participants:Vector<ChannelParticipant> chats:Vector<Chat> users:Vector<User> = channels.ChannelParticipants;
channels.channelParticipantsNotModified#f0173fe9 = channels.ChannelParticipants; channels.channelParticipantsNotModified#f0173fe9 = channels.ChannelParticipants;
channels.channelParticipant#d0d9b163 participant:ChannelParticipant users:Vector<User> = channels.ChannelParticipant; channels.channelParticipant#dfb80317 participant:ChannelParticipant chats:Vector<Chat> users:Vector<User> = channels.ChannelParticipant;
help.termsOfService#780a0310 flags:# popup:flags.0?true id:DataJSON text:string entities:Vector<MessageEntity> min_age_confirm:flags.1?int = help.TermsOfService; help.termsOfService#780a0310 flags:# popup:flags.0?true id:DataJSON text:string entities:Vector<MessageEntity> min_age_confirm:flags.1?int = help.TermsOfService;
@ -1535,7 +1535,7 @@ channels.deleteUserHistory#d10dd71b channel:InputChannel user_id:InputUser = mes
channels.reportSpam#fe087810 channel:InputChannel user_id:InputUser id:Vector<int> = Bool; channels.reportSpam#fe087810 channel:InputChannel user_id:InputUser id:Vector<int> = Bool;
channels.getMessages#ad8c9a23 channel:InputChannel id:Vector<InputMessage> = messages.Messages; channels.getMessages#ad8c9a23 channel:InputChannel id:Vector<InputMessage> = messages.Messages;
channels.getParticipants#123e05e9 channel:InputChannel filter:ChannelParticipantsFilter offset:int limit:int hash:int = channels.ChannelParticipants; channels.getParticipants#123e05e9 channel:InputChannel filter:ChannelParticipantsFilter offset:int limit:int hash:int = channels.ChannelParticipants;
channels.getParticipant#546dd7a6 channel:InputChannel user_id:InputUser = channels.ChannelParticipant; channels.getParticipant#a0ab6cc6 channel:InputChannel participant:InputPeer = channels.ChannelParticipant;
channels.getChannels#a7f6bbb id:Vector<InputChannel> = messages.Chats; channels.getChannels#a7f6bbb id:Vector<InputChannel> = messages.Chats;
channels.getFullChannel#8736a09 channel:InputChannel = messages.ChatFull; channels.getFullChannel#8736a09 channel:InputChannel = messages.ChatFull;
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; 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;
channels.exportMessageLink#e63fadeb flags:# grouped:flags.0?true thread:flags.1?true channel:InputChannel id:int = ExportedMessageLink; channels.exportMessageLink#e63fadeb flags:# grouped:flags.0?true thread:flags.1?true channel:InputChannel id:int = ExportedMessageLink;
channels.toggleSignatures#1f69b606 channel:InputChannel enabled:Bool = Updates; channels.toggleSignatures#1f69b606 channel:InputChannel enabled:Bool = Updates;
channels.getAdminedPublicChannels#f8b036af flags:# by_location:flags.0?true check_limit:flags.1?true = messages.Chats; channels.getAdminedPublicChannels#f8b036af flags:# by_location:flags.0?true check_limit:flags.1?true = messages.Chats;
channels.editBanned#72796912 channel:InputChannel user_id:InputUser banned_rights:ChatBannedRights = Updates; channels.editBanned#96e6cd81 channel:InputChannel participant:InputPeer banned_rights:ChatBannedRights = Updates;
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; 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;
channels.setStickers#ea8ca4f9 channel:InputChannel stickerset:InputStickerSet = Bool; channels.setStickers#ea8ca4f9 channel:InputChannel stickerset:InputStickerSet = Bool;
channels.readMessageContents#eab5dc38 channel:InputChannel id:Vector<int> = Bool; channels.readMessageContents#eab5dc38 channel:InputChannel id:Vector<int> = Bool;
@ -1623,4 +1623,4 @@ stats.getMegagroupStats#dcdf8607 flags:# dark:flags.0?true channel:InputChannel
stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;
stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats; stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats;
// LAYER 125 // LAYER 126

View File

@ -64,7 +64,7 @@ class GetChatMember(Scaffold):
users = {i.id: i for i in r.users} users = {i.id: i for i in r.users}
for member in members: for member in members:
member = types.ChatMember._parse(self, member, users) member = types.ChatMember._parse(self, member, users, {})
if isinstance(user, raw.types.InputPeerSelf): if isinstance(user, raw.types.InputPeerSelf):
if member.user.is_self: if member.user.is_self:
@ -78,12 +78,13 @@ class GetChatMember(Scaffold):
r = await self.send( r = await self.send(
raw.functions.channels.GetParticipant( raw.functions.channels.GetParticipant(
channel=chat, channel=chat,
user_id=user participant=user
) )
) )
users = {i.id: i for i in r.users} users = {i.id: i for i in r.users}
chats = {i.id: i for i in r.chats}
return types.ChatMember._parse(self, r.participant, users) return types.ChatMember._parse(self, r.participant, users, chats)
else: else:
raise ValueError(f'The chat_id "{chat_id}" belongs to a user') raise ValueError(f'The chat_id "{chat_id}" belongs to a user')

View File

@ -115,7 +115,7 @@ class GetChatMembers(Scaffold):
members = r.full_chat.participants.participants members = r.full_chat.participants.participants
users = {i.id: i for i in r.users} users = {i.id: i for i in r.users}
return types.List(types.ChatMember._parse(self, member, users) for member in members) return types.List(types.ChatMember._parse(self, member, users, {}) for member in members)
elif isinstance(peer, raw.types.InputPeerChannel): elif isinstance(peer, raw.types.InputPeerChannel):
filter = filter.lower() filter = filter.lower()
@ -147,7 +147,8 @@ class GetChatMembers(Scaffold):
members = r.participants members = r.participants
users = {i.id: i for i in r.users} users = {i.id: i for i in r.users}
chats = {i.id: i for i in r.chats}
return types.List(types.ChatMember._parse(self, member, users) for member in members) return types.List(types.ChatMember._parse(self, member, users, chats) for member in members)
else: else:
raise ValueError(f'The chat_id "{chat_id}" belongs to a user') raise ValueError(f'The chat_id "{chat_id}" belongs to a user')

View File

@ -75,7 +75,7 @@ class KickChatMember(Scaffold):
r = await self.send( r = await self.send(
raw.functions.channels.EditBanned( raw.functions.channels.EditBanned(
channel=chat_peer, channel=chat_peer,
user_id=user_peer, participant=user_peer,
banned_rights=raw.types.ChatBannedRights( banned_rights=raw.types.ChatBannedRights(
until_date=until_date, until_date=until_date,
view_messages=True, view_messages=True,

View File

@ -52,7 +52,7 @@ class UnbanChatMember(Scaffold):
await self.send( await self.send(
raw.functions.channels.EditBanned( raw.functions.channels.EditBanned(
channel=await self.resolve_peer(chat_id), channel=await self.resolve_peer(chat_id),
user_id=await self.resolve_peer(user_id), participant=await self.resolve_peer(user_id),
banned_rights=raw.types.ChatBannedRights( banned_rights=raw.types.ChatBannedRights(
until_date=0 until_date=0
) )

View File

@ -475,17 +475,17 @@ class ChatEvent(Object):
action = ChatEventAction.MESSAGE_EDITED.value action = ChatEventAction.MESSAGE_EDITED.value
elif isinstance(action, raw.types.ChannelAdminLogEventActionParticipantInvite): elif isinstance(action, raw.types.ChannelAdminLogEventActionParticipantInvite):
invited_member = types.ChatMember._parse(client, action.participant, users) invited_member = types.ChatMember._parse(client, action.participant, users, chats)
action = ChatEventAction.MEMBER_INVITED.value action = ChatEventAction.MEMBER_INVITED.value
elif isinstance(action, raw.types.ChannelAdminLogEventActionParticipantToggleAdmin): elif isinstance(action, raw.types.ChannelAdminLogEventActionParticipantToggleAdmin):
old_admin_rights = types.ChatMember._parse(client, action.prev_participant, users) old_admin_rights = types.ChatMember._parse(client, action.prev_participant, users, chats)
new_admin_rights = types.ChatMember._parse(client, action.new_participant, users) new_admin_rights = types.ChatMember._parse(client, action.new_participant, users, chats)
action = ChatEventAction.ADMIN_RIGHTS_CHANGED.value action = ChatEventAction.ADMIN_RIGHTS_CHANGED.value
elif isinstance(action, raw.types.ChannelAdminLogEventActionParticipantToggleBan): elif isinstance(action, raw.types.ChannelAdminLogEventActionParticipantToggleBan):
old_member_permissions = types.ChatMember._parse(client, action.prev_participant, users) old_member_permissions = types.ChatMember._parse(client, action.prev_participant, users, chats)
new_member_permissions = types.ChatMember._parse(client, action.new_participant, users) new_member_permissions = types.ChatMember._parse(client, action.new_participant, users, chats)
action = ChatEventAction.MEMBER_PERMISSIONS_CHANGED.value action = ChatEventAction.MEMBER_PERMISSIONS_CHANGED.value
elif isinstance(action, raw.types.ChannelAdminLogEventActionStopPoll): elif isinstance(action, raw.types.ChannelAdminLogEventActionStopPoll):

View File

@ -212,8 +212,14 @@ class ChatMember(Object):
self.can_send_polls = can_send_polls self.can_send_polls = can_send_polls
@staticmethod @staticmethod
def _parse(client, member, users) -> "ChatMember": def _parse(client, member, users, chats) -> "ChatMember":
user = types.User._parse(client, users[member.user_id]) if not isinstance(member, (raw.types.ChannelParticipantBanned, raw.types.ChannelParticipantLeft)):
user = types.User._parse(client, users[member.user_id])
else:
if isinstance(member.peer, raw.types.PeerUser):
user = types.User._parse(client, users[member.peer.user_id])
else:
user = None
invited_by = ( invited_by = (
types.User._parse(client, users[member.inviter_id]) types.User._parse(client, users[member.inviter_id])

View File

@ -82,10 +82,10 @@ class ChatMemberUpdated(Object, Update):
invite_link = None invite_link = None
if update.prev_participant: if update.prev_participant:
old_chat_member = types.ChatMember._parse(client, update.prev_participant, users) old_chat_member = types.ChatMember._parse(client, update.prev_participant, users, chats)
if update.new_participant: if update.new_participant:
new_chat_member = types.ChatMember._parse(client, update.new_participant, users) new_chat_member = types.ChatMember._parse(client, update.new_participant, users, chats)
if update.invite: if update.invite:
invite_link = types.ChatInviteLink._parse(client, update.invite, users) invite_link = types.ChatInviteLink._parse(client, update.invite, users)