Merge branch 'develop' into asyncio

# Conflicts:
#	pyrogram/client/methods/chats/promote_chat_member.py
#	pyrogram/client/methods/chats/restrict_chat_member.py
#	pyrogram/client/methods/chats/unban_chat_member.py
This commit is contained in:
Dan 2019-03-13 13:08:58 +01:00
commit 7cdcb515b1
21 changed files with 316 additions and 191 deletions

View File

@ -83,7 +83,7 @@ fileLocationUnavailable#7c596b46 volume_id:long local_id:int secret:long = FileL
fileLocation#91d11eb dc_id:int volume_id:long local_id:int secret:long file_reference:bytes = FileLocation; fileLocation#91d11eb dc_id:int volume_id:long local_id:int secret:long file_reference:bytes = FileLocation;
userEmpty#200250ba id:int = User; userEmpty#200250ba id:int = User;
user#2e13f4c3 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true id:int access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?string bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User; user#2e13f4c3 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true id:int access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?string bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User;
userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto;
userProfilePhoto#d559d8c8 photo_id:long photo_small:FileLocation photo_big:FileLocation = UserProfilePhoto; userProfilePhoto#d559d8c8 photo_id:long photo_small:FileLocation photo_big:FileLocation = UserProfilePhoto;
@ -96,12 +96,12 @@ userStatusLastWeek#7bf09fc = UserStatus;
userStatusLastMonth#77ebc742 = UserStatus; userStatusLastMonth#77ebc742 = UserStatus;
chatEmpty#9ba2d800 id:int = Chat; chatEmpty#9ba2d800 id:int = Chat;
chat#d91cdd54 flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true admins_enabled:flags.3?true admin:flags.4?true deactivated:flags.5?true id:int title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel = Chat; chat#3bda1bde flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true deactivated:flags.5?true id:int title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat;
chatForbidden#7328bdb id:int title:string = Chat; chatForbidden#7328bdb id:int title:string = Chat;
channel#c88974ac flags:# creator:flags.0?true left:flags.2?true editor:flags.3?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true democracy:flags.10?true signatures:flags.11?true min:flags.12?true id:int access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int version:int restriction_reason:flags.9?string admin_rights:flags.14?ChannelAdminRights banned_rights:flags.15?ChannelBannedRights participants_count:flags.17?int = Chat; channel#4df30834 flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true id:int access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int version:int restriction_reason:flags.9?string admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int = Chat;
channelForbidden#289da732 flags:# broadcast:flags.5?true megagroup:flags.8?true id:int access_hash:long title:string until_date:flags.16?int = Chat; channelForbidden#289da732 flags:# broadcast:flags.5?true megagroup:flags.8?true id:int access_hash:long title:string until_date:flags.16?int = Chat;
chatFull#edd2a791 flags:# id:int participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:flags.3?Vector<BotInfo> pinned_msg_id:flags.6?int = ChatFull; chatFull#22a235da flags:# can_set_username:flags.7?true id:int about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:flags.3?Vector<BotInfo> pinned_msg_id:flags.6?int = ChatFull;
channelFull#1c87a71a flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_view_stats:flags.12?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector<BotInfo> migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int = ChatFull; channelFull#1c87a71a flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_view_stats:flags.12?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector<BotInfo> migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int = ChatFull;
chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant; chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant;
@ -163,6 +163,7 @@ photo#9c477dd8 flags:# has_stickers:flags.0?true id:long access_hash:long file_r
photoSizeEmpty#e17e23c type:string = PhotoSize; photoSizeEmpty#e17e23c type:string = PhotoSize;
photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = PhotoSize; photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = PhotoSize;
photoCachedSize#e9a734fa type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize; photoCachedSize#e9a734fa type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize;
photoStrippedSize#e0b0bc2e type:string bytes:bytes = PhotoSize;
geoPointEmpty#1117dd5f = GeoPoint; geoPointEmpty#1117dd5f = GeoPoint;
geoPoint#296f104 long:double lat:double access_hash:long = GeoPoint; geoPoint#296f104 long:double lat:double access_hash:long = GeoPoint;
@ -186,8 +187,7 @@ peerNotifySettings#af509d20 flags:# show_previews:flags.0?Bool silent:flags.1?Bo
peerSettings#818426cd flags:# report_spam:flags.0?true = PeerSettings; peerSettings#818426cd flags:# report_spam:flags.0?true = PeerSettings;
wallPaper#ccb03657 id:int title:string sizes:Vector<PhotoSize> color:int = WallPaper; wallPaper#a437c3ed id:long flags:# creator:flags.0?true default:flags.1?true pattern:flags.3?true dark:flags.4?true access_hash:long slug:string document:Document settings:flags.2?WallPaperSettings = WallPaper;
wallPaperSolid#63117f24 id:int title:string bg_color:int color:int = WallPaper;
inputReportReasonSpam#58dbcab8 = ReportReason; inputReportReasonSpam#58dbcab8 = ReportReason;
inputReportReasonViolence#1e22c78d = ReportReason; inputReportReasonViolence#1e22c78d = ReportReason;
@ -221,7 +221,7 @@ messages.dialogsSlice#71e094f3 count:int dialogs:Vector<Dialog> messages:Vector<
messages.dialogsNotModified#f0e3e596 count:int = messages.Dialogs; messages.dialogsNotModified#f0e3e596 count:int = messages.Dialogs;
messages.messages#8c718e87 messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages; messages.messages#8c718e87 messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
messages.messagesSlice#b446ae3 count:int messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages; messages.messagesSlice#a6c47aaa flags:# inexact:flags.1?true count:int messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
messages.channelMessages#99262e37 flags:# inexact:flags.1?true pts:int count:int messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages; messages.channelMessages#99262e37 flags:# inexact:flags.1?true pts:int count:int messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
messages.messagesNotModified#74535f21 count:int = messages.Messages; messages.messagesNotModified#74535f21 count:int = messages.Messages;
@ -281,7 +281,6 @@ updateNewChannelMessage#62ba04d9 message:Message pts:int pts_count:int = Update;
updateReadChannelInbox#4214f37f channel_id:int max_id:int = Update; updateReadChannelInbox#4214f37f channel_id:int max_id:int = Update;
updateDeleteChannelMessages#c37521c9 channel_id:int messages:Vector<int> pts:int pts_count:int = Update; updateDeleteChannelMessages#c37521c9 channel_id:int messages:Vector<int> pts:int pts_count:int = Update;
updateChannelMessageViews#98a12b4b channel_id:int id:int views:int = Update; updateChannelMessageViews#98a12b4b channel_id:int id:int views:int = Update;
updateChatAdmins#6e947941 chat_id:int enabled:Bool version:int = Update;
updateChatParticipantAdmin#b6901959 chat_id:int user_id:int is_admin:Bool version:int = Update; updateChatParticipantAdmin#b6901959 chat_id:int user_id:int is_admin:Bool version:int = Update;
updateNewStickerSet#688a30aa stickerset:messages.StickerSet = Update; updateNewStickerSet#688a30aa stickerset:messages.StickerSet = Update;
updateStickerSetsOrder#bb2d201 flags:# masks:flags.0?true order:Vector<long> = Update; updateStickerSetsOrder#bb2d201 flags:# masks:flags.0?true order:Vector<long> = Update;
@ -318,6 +317,7 @@ updateDialogUnreadMark#e16459c3 flags:# unread:flags.0?true peer:DialogPeer = Up
updateUserPinnedMessage#4c43da18 user_id:int id:int = Update; updateUserPinnedMessage#4c43da18 user_id:int id:int = Update;
updateChatPinnedMessage#22893b26 chat_id:int id:int = Update; updateChatPinnedMessage#22893b26 chat_id:int id:int = Update;
updateMessagePoll#aca1657b flags:# poll_id:long poll:flags.0?Poll results:PollResults = Update; updateMessagePoll#aca1657b flags:# poll_id:long poll:flags.0?Poll results:PollResults = Update;
updateChatDefaultBannedRights#54c01850 peer:Peer default_banned_rights:ChatBannedRights version:int = Update;
updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State;
@ -382,7 +382,7 @@ inputDocumentEmpty#72f0eaae = InputDocument;
inputDocument#1abfb575 id:long access_hash:long file_reference:bytes = InputDocument; inputDocument#1abfb575 id:long access_hash:long file_reference:bytes = InputDocument;
documentEmpty#36f8c871 id:long = Document; documentEmpty#36f8c871 id:long = Document;
document#59534e4c id:long access_hash:long file_reference:bytes date:int mime_type:string size:int thumb:PhotoSize dc_id:int attributes:Vector<DocumentAttribute> = Document; document#9ba29cc1 flags:# id:long access_hash:long file_reference:bytes date:int mime_type:string size:int thumbs:flags.0?Vector<PhotoSize> dc_id:int attributes:Vector<DocumentAttribute> = Document;
help.support#17c6b5f6 phone_number:string user:User = help.Support; help.support#17c6b5f6 phone_number:string user:User = help.Support;
@ -544,8 +544,8 @@ channelMessagesFilter#cd77d957 flags:# exclude_new_messages:flags.1?true ranges:
channelParticipant#15ebac1d user_id:int date:int = ChannelParticipant; 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#e3e2e1f9 user_id:int = ChannelParticipant; channelParticipantCreator#e3e2e1f9 user_id:int = ChannelParticipant;
channelParticipantAdmin#a82fa898 flags:# can_edit:flags.0?true user_id:int inviter_id:int promoted_by:int date:int admin_rights:ChannelAdminRights = ChannelParticipant; channelParticipantAdmin#5daa6e23 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 = ChannelParticipant;
channelParticipantBanned#222c1886 flags:# left:flags.0?true user_id:int kicked_by:int date:int banned_rights:ChannelBannedRights = ChannelParticipant; channelParticipantBanned#1c0facaf flags:# left:flags.0?true user_id:int kicked_by:int date:int banned_rights:ChatBannedRights = ChannelParticipant;
channelParticipantsRecent#de3f3c79 = ChannelParticipantsFilter; channelParticipantsRecent#de3f3c79 = ChannelParticipantsFilter;
channelParticipantsAdmins#b4608969 = ChannelParticipantsFilter; channelParticipantsAdmins#b4608969 = ChannelParticipantsFilter;
@ -553,6 +553,7 @@ channelParticipantsKicked#a3b54985 q:string = ChannelParticipantsFilter;
channelParticipantsBots#b0d1865b = ChannelParticipantsFilter; channelParticipantsBots#b0d1865b = ChannelParticipantsFilter;
channelParticipantsBanned#1427a5e1 q:string = ChannelParticipantsFilter; channelParticipantsBanned#1427a5e1 q:string = ChannelParticipantsFilter;
channelParticipantsSearch#656ac4b q:string = ChannelParticipantsFilter; channelParticipantsSearch#656ac4b q:string = ChannelParticipantsFilter;
channelParticipantsContacts#bb6ae88d q:string = ChannelParticipantsFilter;
channels.channelParticipants#f56ee2a8 count:int participants:Vector<ChannelParticipant> users:Vector<User> = channels.ChannelParticipants; channels.channelParticipants#f56ee2a8 count:int participants:Vector<ChannelParticipant> users:Vector<User> = channels.ChannelParticipants;
channels.channelParticipantsNotModified#f0173fe9 = channels.ChannelParticipants; channels.channelParticipantsNotModified#f0173fe9 = channels.ChannelParticipants;
@ -789,10 +790,6 @@ langPackDifference#f385c1f6 lang_code:string from_version:int version:int string
langPackLanguage#eeca5ce3 flags:# official:flags.0?true rtl:flags.2?true beta:flags.3?true name:string native_name:string lang_code:string base_lang_code:flags.1?string plural_code:string strings_count:int translated_count:int translations_url:string = LangPackLanguage; langPackLanguage#eeca5ce3 flags:# official:flags.0?true rtl:flags.2?true beta:flags.3?true name:string native_name:string lang_code:string base_lang_code:flags.1?string plural_code:string strings_count:int translated_count:int translations_url:string = LangPackLanguage;
channelAdminRights#5d7ceba5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true invite_link:flags.6?true pin_messages:flags.7?true add_admins:flags.9?true manage_call:flags.10?true = ChannelAdminRights;
channelBannedRights#58cf4249 flags:# view_messages:flags.0?true send_messages:flags.1?true send_media:flags.2?true send_stickers:flags.3?true send_gifs:flags.4?true send_games:flags.5?true send_inline:flags.6?true embed_links:flags.7?true until_date:int = ChannelBannedRights;
channelAdminLogEventActionChangeTitle#e6dfb825 prev_value:string new_value:string = ChannelAdminLogEventAction; channelAdminLogEventActionChangeTitle#e6dfb825 prev_value:string new_value:string = ChannelAdminLogEventAction;
channelAdminLogEventActionChangeAbout#55188a2e prev_value:string new_value:string = ChannelAdminLogEventAction; channelAdminLogEventActionChangeAbout#55188a2e prev_value:string new_value:string = ChannelAdminLogEventAction;
channelAdminLogEventActionChangeUsername#6a4afc38 prev_value:string new_value:string = ChannelAdminLogEventAction; channelAdminLogEventActionChangeUsername#6a4afc38 prev_value:string new_value:string = ChannelAdminLogEventAction;
@ -809,6 +806,8 @@ channelAdminLogEventActionParticipantToggleBan#e6d83d7e prev_participant:Channel
channelAdminLogEventActionParticipantToggleAdmin#d5676710 prev_participant:ChannelParticipant new_participant:ChannelParticipant = ChannelAdminLogEventAction; channelAdminLogEventActionParticipantToggleAdmin#d5676710 prev_participant:ChannelParticipant new_participant:ChannelParticipant = ChannelAdminLogEventAction;
channelAdminLogEventActionChangeStickerSet#b1c3caa7 prev_stickerset:InputStickerSet new_stickerset:InputStickerSet = ChannelAdminLogEventAction; channelAdminLogEventActionChangeStickerSet#b1c3caa7 prev_stickerset:InputStickerSet new_stickerset:InputStickerSet = ChannelAdminLogEventAction;
channelAdminLogEventActionTogglePreHistoryHidden#5f5c95f1 new_value:Bool = ChannelAdminLogEventAction; channelAdminLogEventActionTogglePreHistoryHidden#5f5c95f1 new_value:Bool = ChannelAdminLogEventAction;
channelAdminLogEventActionDefaultBannedRights#2df5fc0a prev_banned_rights:ChatBannedRights new_banned_rights:ChatBannedRights = ChannelAdminLogEventAction;
channelAdminLogEventActionStopPoll#8f079643 message:Message = ChannelAdminLogEventAction;
channelAdminLogEvent#3b5a3e40 id:long date:int user_id:int action:ChannelAdminLogEventAction = ChannelAdminLogEvent; channelAdminLogEvent#3b5a3e40 id:long date:int user_id:int action:ChannelAdminLogEventAction = ChannelAdminLogEvent;
@ -972,6 +971,20 @@ chatOnlines#f041e250 onlines:int = ChatOnlines;
statsURL#47a971e0 url:string = StatsURL; statsURL#47a971e0 url:string = StatsURL;
chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true = ChatAdminRights;
chatBannedRights#9f120418 flags:# view_messages:flags.0?true send_messages:flags.1?true send_media:flags.2?true send_stickers:flags.3?true send_gifs:flags.4?true send_games:flags.5?true send_inline:flags.6?true embed_links:flags.7?true send_polls:flags.8?true change_info:flags.10?true invite_users:flags.15?true pin_messages:flags.17?true until_date:int = ChatBannedRights;
inputWallPaper#e630b979 id:long access_hash:long = InputWallPaper;
inputWallPaperSlug#72091c80 slug:string = InputWallPaper;
account.wallPapersNotModified#1c199183 = account.WallPapers;
account.wallPapers#702b65a9 hash:int wallpapers:Vector<WallPaper> = account.WallPapers;
codeSettings#302f59f3 flags:# allow_flashcall:flags.0?true current_number:flags.1?true app_hash_persistent:flags.2?true app_hash:flags.3?string = CodeSettings;
wallPaperSettings#a12f40b8 flags:# blur:flags.1?true motion:flags.2?true background_color:flags.0?int intensity:flags.3?int = WallPaperSettings;
---functions--- ---functions---
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
@ -982,7 +995,7 @@ invokeWithoutUpdates#bf9459b7 {X:Type} query:!X = X;
invokeWithMessagesRange#365275f2 {X:Type} range:MessageRange query:!X = X; invokeWithMessagesRange#365275f2 {X:Type} range:MessageRange query:!X = X;
invokeWithTakeout#aca9fd2e {X:Type} takeout_id:long query:!X = X; invokeWithTakeout#aca9fd2e {X:Type} takeout_id:long query:!X = X;
auth.sendCode#86aef0ec flags:# allow_flashcall:flags.0?true phone_number:string current_number:flags.0?Bool api_id:int api_hash:string = auth.SentCode; auth.sendCode#a677244f phone_number:string api_id:int api_hash:string settings:CodeSettings = auth.SentCode;
auth.signUp#1b067634 phone_number:string phone_code_hash:string phone_code:string first_name:string last_name:string = auth.Authorization; auth.signUp#1b067634 phone_number:string phone_code_hash:string phone_code:string first_name:string last_name:string = auth.Authorization;
auth.signIn#bcd51581 phone_number:string phone_code_hash:string phone_code:string = auth.Authorization; auth.signIn#bcd51581 phone_number:string phone_code_hash:string phone_code:string = auth.Authorization;
auth.logOut#5717da40 = Bool; auth.logOut#5717da40 = Bool;
@ -1005,7 +1018,7 @@ account.getNotifySettings#12b3ad31 peer:InputNotifyPeer = PeerNotifySettings;
account.resetNotifySettings#db7e1747 = Bool; account.resetNotifySettings#db7e1747 = Bool;
account.updateProfile#78515775 flags:# first_name:flags.0?string last_name:flags.1?string about:flags.2?string = User; account.updateProfile#78515775 flags:# first_name:flags.0?string last_name:flags.1?string about:flags.2?string = User;
account.updateStatus#6628562c offline:Bool = Bool; account.updateStatus#6628562c offline:Bool = Bool;
account.getWallPapers#c04cfac2 = Vector<WallPaper>; account.getWallPapers#aabb1763 hash:int = account.WallPapers;
account.reportPeer#ae189d5f peer:InputPeer reason:ReportReason = Bool; account.reportPeer#ae189d5f peer:InputPeer reason:ReportReason = Bool;
account.checkUsername#2714d86c username:string = Bool; account.checkUsername#2714d86c username:string = Bool;
account.updateUsername#3e0bdd7c username:string = User; account.updateUsername#3e0bdd7c username:string = User;
@ -1014,7 +1027,7 @@ account.setPrivacy#c9f81ce8 key:InputPrivacyKey rules:Vector<InputPrivacyRule> =
account.deleteAccount#418d4e0b reason:string = Bool; account.deleteAccount#418d4e0b reason:string = Bool;
account.getAccountTTL#8fc711d = AccountDaysTTL; account.getAccountTTL#8fc711d = AccountDaysTTL;
account.setAccountTTL#2442485e ttl:AccountDaysTTL = Bool; account.setAccountTTL#2442485e ttl:AccountDaysTTL = Bool;
account.sendChangePhoneCode#8e57deb flags:# allow_flashcall:flags.0?true phone_number:string current_number:flags.0?Bool = auth.SentCode; account.sendChangePhoneCode#82574ae5 phone_number:string settings:CodeSettings = auth.SentCode;
account.changePhone#70c32edb phone_number:string phone_code_hash:string phone_code:string = User; account.changePhone#70c32edb phone_number:string phone_code_hash:string phone_code:string = User;
account.updateDeviceLocked#38df3532 period:int = Bool; account.updateDeviceLocked#38df3532 period:int = Bool;
account.getAuthorizations#e320c158 = account.Authorizations; account.getAuthorizations#e320c158 = account.Authorizations;
@ -1022,7 +1035,7 @@ account.resetAuthorization#df77f3bc hash:long = Bool;
account.getPassword#548a30f5 = account.Password; account.getPassword#548a30f5 = account.Password;
account.getPasswordSettings#9cd4eaf9 password:InputCheckPasswordSRP = account.PasswordSettings; account.getPasswordSettings#9cd4eaf9 password:InputCheckPasswordSRP = account.PasswordSettings;
account.updatePasswordSettings#a59b102f password:InputCheckPasswordSRP new_settings:account.PasswordInputSettings = Bool; account.updatePasswordSettings#a59b102f password:InputCheckPasswordSRP new_settings:account.PasswordInputSettings = Bool;
account.sendConfirmPhoneCode#1516d7bd flags:# allow_flashcall:flags.0?true hash:string current_number:flags.0?Bool = auth.SentCode; account.sendConfirmPhoneCode#1b3faa88 hash:string settings:CodeSettings = auth.SentCode;
account.confirmPhone#5f2178c3 phone_code_hash:string phone_code:string = Bool; account.confirmPhone#5f2178c3 phone_code_hash:string phone_code:string = Bool;
account.getTmpPassword#449e0b51 password:InputCheckPasswordSRP period:int = account.TmpPassword; account.getTmpPassword#449e0b51 password:InputCheckPasswordSRP period:int = account.TmpPassword;
account.getWebAuthorizations#182e6d6f = account.WebAuthorizations; account.getWebAuthorizations#182e6d6f = account.WebAuthorizations;
@ -1034,7 +1047,7 @@ account.saveSecureValue#899fe31d value:InputSecureValue secure_secret_id:long =
account.deleteSecureValue#b880bc4b types:Vector<SecureValueType> = Bool; account.deleteSecureValue#b880bc4b types:Vector<SecureValueType> = Bool;
account.getAuthorizationForm#b86ba8e1 bot_id:int scope:string public_key:string = account.AuthorizationForm; account.getAuthorizationForm#b86ba8e1 bot_id:int scope:string public_key:string = account.AuthorizationForm;
account.acceptAuthorization#e7027c94 bot_id:int scope:string public_key:string value_hashes:Vector<SecureValueHash> credentials:SecureCredentialsEncrypted = Bool; account.acceptAuthorization#e7027c94 bot_id:int scope:string public_key:string value_hashes:Vector<SecureValueHash> credentials:SecureCredentialsEncrypted = Bool;
account.sendVerifyPhoneCode#823380b4 flags:# allow_flashcall:flags.0?true phone_number:string current_number:flags.0?Bool = auth.SentCode; account.sendVerifyPhoneCode#a5a356f9 phone_number:string settings:CodeSettings = auth.SentCode;
account.verifyPhone#4dd3a7f6 phone_number:string phone_code_hash:string phone_code:string = Bool; account.verifyPhone#4dd3a7f6 phone_number:string phone_code_hash:string phone_code:string = Bool;
account.sendVerifyEmailCode#7011509f email:string = account.SentEmailCode; account.sendVerifyEmailCode#7011509f email:string = account.SentEmailCode;
account.verifyEmail#ecba39db email:string code:string = Bool; account.verifyEmail#ecba39db email:string code:string = Bool;
@ -1046,6 +1059,11 @@ account.cancelPasswordEmail#c1cbd5b6 = Bool;
account.getContactSignUpNotification#9f07c728 = Bool; account.getContactSignUpNotification#9f07c728 = Bool;
account.setContactSignUpNotification#cff43f61 silent:Bool = Bool; account.setContactSignUpNotification#cff43f61 silent:Bool = Bool;
account.getNotifyExceptions#53577479 flags:# compare_sound:flags.1?true peer:flags.0?InputNotifyPeer = Updates; account.getNotifyExceptions#53577479 flags:# compare_sound:flags.1?true peer:flags.0?InputNotifyPeer = Updates;
account.getWallPaper#fc8ddbea wallpaper:InputWallPaper = WallPaper;
account.uploadWallPaper#dd853661 file:InputFile mime_type:string settings:WallPaperSettings = WallPaper;
account.saveWallPaper#6c5a5b37 wallpaper:InputWallPaper unsave:Bool settings:WallPaperSettings = Bool;
account.installWallPaper#feed5769 wallpaper:InputWallPaper settings:WallPaperSettings = Bool;
account.resetWallPapers#bb3b9804 = Bool;
users.getUsers#d91a548 id:Vector<InputUser> = Vector<User>; users.getUsers#d91a548 id:Vector<InputUser> = Vector<User>;
users.getFullUser#ca30a5b1 id:InputUser = UserFull; users.getFullUser#ca30a5b1 id:InputUser = UserFull;
@ -1107,7 +1125,7 @@ messages.readMessageContents#36a73f77 id:Vector<int> = messages.AffectedMessages
messages.getStickers#43d4f2c emoticon:string hash:int = messages.Stickers; messages.getStickers#43d4f2c emoticon:string hash:int = messages.Stickers;
messages.getAllStickers#1c9618b1 hash:int = messages.AllStickers; messages.getAllStickers#1c9618b1 hash:int = messages.AllStickers;
messages.getWebPagePreview#8b68b0cc flags:# message:string entities:flags.3?Vector<MessageEntity> = MessageMedia; messages.getWebPagePreview#8b68b0cc flags:# message:string entities:flags.3?Vector<MessageEntity> = MessageMedia;
messages.exportChatInvite#7d885289 chat_id:int = ExportedChatInvite; messages.exportChatInvite#df7534c peer:InputPeer = ExportedChatInvite;
messages.checkChatInvite#3eadb1bb hash:string = ChatInvite; messages.checkChatInvite#3eadb1bb hash:string = ChatInvite;
messages.importChatInvite#6c50051c hash:string = Updates; messages.importChatInvite#6c50051c hash:string = Updates;
messages.getStickerSet#2619a90e stickerset:InputStickerSet = messages.StickerSet; messages.getStickerSet#2619a90e stickerset:InputStickerSet = messages.StickerSet;
@ -1115,7 +1133,6 @@ messages.installStickerSet#c78fe460 stickerset:InputStickerSet archived:Bool = m
messages.uninstallStickerSet#f96e55de stickerset:InputStickerSet = Bool; messages.uninstallStickerSet#f96e55de stickerset:InputStickerSet = Bool;
messages.startBot#e6df7378 bot:InputUser peer:InputPeer random_id:long start_param:string = Updates; messages.startBot#e6df7378 bot:InputUser peer:InputPeer random_id:long start_param:string = Updates;
messages.getMessagesViews#c4c8a55d peer:InputPeer id:Vector<int> increment:Bool = Vector<int>; messages.getMessagesViews#c4c8a55d peer:InputPeer id:Vector<int> increment:Bool = Vector<int>;
messages.toggleChatAdmins#ec8bd9e1 chat_id:int enabled:Bool = Updates;
messages.editChatAdmin#a9e69f2e chat_id:int user_id:InputUser is_admin:Bool = Bool; messages.editChatAdmin#a9e69f2e chat_id:int user_id:InputUser is_admin:Bool = Bool;
messages.migrateChat#15a3b8e3 chat_id:int = Updates; messages.migrateChat#15a3b8e3 chat_id:int = Updates;
messages.searchGlobal#9e3cacb0 q:string offset_date:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; messages.searchGlobal#9e3cacb0 q:string offset_date:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;
@ -1174,6 +1191,8 @@ messages.sendVote#10ea6184 peer:InputPeer msg_id:int options:Vector<bytes> = Upd
messages.getPollResults#73bb643b peer:InputPeer msg_id:int = Updates; messages.getPollResults#73bb643b peer:InputPeer msg_id:int = Updates;
messages.getOnlines#6e2be050 peer:InputPeer = ChatOnlines; messages.getOnlines#6e2be050 peer:InputPeer = ChatOnlines;
messages.getStatsURL#83f6c0cd peer:InputPeer = StatsURL; messages.getStatsURL#83f6c0cd peer:InputPeer = StatsURL;
messages.editChatAbout#def60797 peer:InputPeer about:string = Bool;
messages.editChatDefaultBannedRights#a5866b41 peer:InputPeer banned_rights:ChatBannedRights = Updates;
updates.getState#edd4882a = updates.State; updates.getState#edd4882a = updates.State;
updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference; updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference;
@ -1223,8 +1242,7 @@ channels.getParticipant#546dd7a6 channel:InputChannel user_id:InputUser = channe
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#f4893d7f flags:# broadcast:flags.0?true megagroup:flags.1?true title:string about:string = Updates; channels.createChannel#f4893d7f flags:# broadcast:flags.0?true megagroup:flags.1?true title:string about:string = Updates;
channels.editAbout#13e27f1e channel:InputChannel about:string = Bool; channels.editAdmin#70f893ba channel:InputChannel user_id:InputUser admin_rights:ChatAdminRights = Updates;
channels.editAdmin#20b88214 channel:InputChannel user_id:InputUser admin_rights:ChannelAdminRights = Updates;
channels.editTitle#566decd0 channel:InputChannel title:string = Updates; channels.editTitle#566decd0 channel:InputChannel title:string = Updates;
channels.editPhoto#f12e57c9 channel:InputChannel photo:InputChatPhoto = Updates; channels.editPhoto#f12e57c9 channel:InputChannel photo:InputChatPhoto = Updates;
channels.checkUsername#10e6bd2c channel:InputChannel username:string = Bool; channels.checkUsername#10e6bd2c channel:InputChannel username:string = Bool;
@ -1232,13 +1250,11 @@ channels.updateUsername#3514b3de channel:InputChannel username:string = Bool;
channels.joinChannel#24b524c5 channel:InputChannel = Updates; channels.joinChannel#24b524c5 channel:InputChannel = Updates;
channels.leaveChannel#f836aa95 channel:InputChannel = Updates; channels.leaveChannel#f836aa95 channel:InputChannel = Updates;
channels.inviteToChannel#199f3a6c channel:InputChannel users:Vector<InputUser> = Updates; channels.inviteToChannel#199f3a6c channel:InputChannel users:Vector<InputUser> = Updates;
channels.exportInvite#c7560885 channel:InputChannel = ExportedChatInvite;
channels.deleteChannel#c0111fe3 channel:InputChannel = Updates; channels.deleteChannel#c0111fe3 channel:InputChannel = Updates;
channels.toggleInvites#49609307 channel:InputChannel enabled:Bool = Updates;
channels.exportMessageLink#ceb77163 channel:InputChannel id:int grouped:Bool = ExportedMessageLink; channels.exportMessageLink#ceb77163 channel:InputChannel id:int grouped:Bool = ExportedMessageLink;
channels.toggleSignatures#1f69b606 channel:InputChannel enabled:Bool = Updates; channels.toggleSignatures#1f69b606 channel:InputChannel enabled:Bool = Updates;
channels.getAdminedPublicChannels#8d8d82d7 = messages.Chats; channels.getAdminedPublicChannels#8d8d82d7 = messages.Chats;
channels.editBanned#bfd915cd channel:InputChannel user_id:InputUser banned_rights:ChannelBannedRights = Updates; channels.editBanned#72796912 channel:InputChannel user_id:InputUser 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;
@ -1272,8 +1288,8 @@ phone.saveCallDebug#277add7e peer:InputPhoneCall debug:DataJSON = Bool;
langpack.getLangPack#f2f2330a lang_pack:string lang_code:string = LangPackDifference; langpack.getLangPack#f2f2330a lang_pack:string lang_code:string = LangPackDifference;
langpack.getStrings#efea3803 lang_pack:string lang_code:string keys:Vector<string> = Vector<LangPackString>; langpack.getStrings#efea3803 lang_pack:string lang_code:string keys:Vector<string> = Vector<LangPackString>;
langpack.getDifference#9d51e814 lang_code:string from_version:int = LangPackDifference; langpack.getDifference#cd984aa5 lang_pack:string lang_code:string from_version:int = LangPackDifference;
langpack.getLanguages#42c6978f lang_pack:string = Vector<LangPackLanguage>; langpack.getLanguages#42c6978f lang_pack:string = Vector<LangPackLanguage>;
langpack.getLanguage#6a596502 lang_pack:string lang_code:string = LangPackLanguage; langpack.getLanguage#6a596502 lang_pack:string lang_code:string = LangPackLanguage;
// LAYER 91 // LAYER 95

View File

@ -16,6 +16,7 @@ Users & Chats
ChatPhoto ChatPhoto
ChatMember ChatMember
ChatMembers ChatMembers
ChatPermissions
Dialog Dialog
Dialogs Dialogs

View File

@ -47,7 +47,7 @@ from .client.types import (
UserProfilePhotos, Venue, Animation, Video, VideoNote, Voice, CallbackQuery, Messages, ForceReply, UserProfilePhotos, Venue, Animation, Video, VideoNote, Voice, CallbackQuery, Messages, ForceReply,
InlineKeyboardButton, InlineKeyboardMarkup, KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove, InlineKeyboardButton, InlineKeyboardMarkup, KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove,
Poll, PollOption, ChatPreview, StopPropagation, ContinuePropagation, Game, CallbackGame, GameHighScore, Poll, PollOption, ChatPreview, StopPropagation, ContinuePropagation, Game, CallbackGame, GameHighScore,
GameHighScores GameHighScores, ChatPermissions
) )
from .client import ( from .client import (
Client, ChatAction, ParseMode, Emoji, Client, ChatAction, ParseMode, Emoji,

View File

@ -549,9 +549,10 @@ class Client(Methods, BaseClient):
try: try:
r = await self.send( r = await self.send(
functions.auth.SendCode( functions.auth.SendCode(
self.phone_number, phone_number=self.phone_number,
self.api_id, api_id=self.api_id,
self.api_hash api_hash=self.api_hash,
settings=types.CodeSettings()
) )
) )
except (PhoneMigrate, NetworkMigrate) as e: except (PhoneMigrate, NetworkMigrate) as e:

View File

@ -65,7 +65,7 @@ class KickChatMember(BaseClient):
functions.channels.EditBanned( functions.channels.EditBanned(
channel=chat_peer, channel=chat_peer,
user_id=user_peer, user_id=user_peer,
banned_rights=types.ChannelBannedRights( banned_rights=types.ChatBannedRights(
until_date=until_date, until_date=until_date,
view_messages=True, view_messages=True,
send_messages=True, send_messages=True,

View File

@ -30,11 +30,12 @@ class PromoteChatMember(BaseClient):
can_post_messages: bool = False, can_post_messages: bool = False,
can_edit_messages: bool = False, can_edit_messages: bool = False,
can_delete_messages: bool = True, can_delete_messages: bool = True,
can_invite_users: bool = True,
can_restrict_members: bool = True, can_restrict_members: bool = True,
can_invite_users: bool = True,
can_pin_messages: bool = False, can_pin_messages: bool = False,
can_promote_members: bool = False) -> bool: can_promote_members: bool = False) -> bool:
"""Use this method to promote or demote a user in a supergroup or a channel. """Use this method to promote or demote a user in a supergroup or a channel.
You must be an administrator in the chat for this to work and must have the appropriate admin rights. You must be an administrator in the chat for this to work and must have the appropriate admin rights.
Pass False for all boolean parameters to demote a user. Pass False for all boolean parameters to demote a user.
@ -58,12 +59,12 @@ class PromoteChatMember(BaseClient):
can_delete_messages (``bool``, *optional*): can_delete_messages (``bool``, *optional*):
Pass True, if the administrator can delete messages of other users. Pass True, if the administrator can delete messages of other users.
can_invite_users (``bool``, *optional*):
Pass True, if the administrator can invite new users to the chat.
can_restrict_members (``bool``, *optional*): can_restrict_members (``bool``, *optional*):
Pass True, if the administrator can restrict, ban or unban chat members. Pass True, if the administrator can restrict, ban or unban chat members.
can_invite_users (``bool``, *optional*):
Pass True, if the administrator can invite new users to the chat.
can_pin_messages (``bool``, *optional*): can_pin_messages (``bool``, *optional*):
Pass True, if the administrator can pin messages, supergroups only. Pass True, if the administrator can pin messages, supergroups only.
@ -82,17 +83,15 @@ class PromoteChatMember(BaseClient):
functions.channels.EditAdmin( functions.channels.EditAdmin(
channel=await self.resolve_peer(chat_id), channel=await self.resolve_peer(chat_id),
user_id=await self.resolve_peer(user_id), user_id=await self.resolve_peer(user_id),
admin_rights=types.ChannelAdminRights( admin_rights=types.ChatAdminRights(
change_info=can_change_info or None, change_info=can_change_info or None,
post_messages=can_post_messages or None, post_messages=can_post_messages or None,
edit_messages=can_edit_messages or None, edit_messages=can_edit_messages or None,
delete_messages=can_delete_messages or None, delete_messages=can_delete_messages or None,
ban_users=can_restrict_members or None, ban_users=can_restrict_members or None,
invite_users=can_invite_users or None, invite_users=can_invite_users or None,
invite_link=can_invite_users or None,
pin_messages=can_pin_messages or None, pin_messages=can_pin_messages or None,
add_admins=can_promote_members or None, add_admins=can_promote_members or None,
manage_call=None
) )
) )
) )

View File

@ -98,7 +98,7 @@ class RestrictChatMember(BaseClient):
functions.channels.EditBanned( 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), user_id=await self.resolve_peer(user_id),
banned_rights=types.ChannelBannedRights( banned_rights=types.ChatBannedRights(
until_date=until_date, until_date=until_date,
send_messages=send_messages, send_messages=send_messages,
send_media=send_media, send_media=send_media,

View File

@ -48,7 +48,7 @@ class UnbanChatMember(BaseClient):
functions.channels.EditBanned( 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), user_id=await self.resolve_peer(user_id),
banned_rights=types.ChannelBannedRights( banned_rights=types.ChatBannedRights(
until_date=0 until_date=0
) )
) )

View File

@ -33,5 +33,5 @@ from .messages_and_media import (
from .update import StopPropagation, ContinuePropagation from .update import StopPropagation, ContinuePropagation
from .user_and_chats import ( from .user_and_chats import (
Chat, ChatMember, ChatMembers, ChatPhoto, Chat, ChatMember, ChatMembers, ChatPhoto,
Dialog, Dialogs, User, UserStatus, ChatPreview Dialog, Dialogs, User, UserStatus, ChatPreview, ChatPermissions
) )

View File

@ -97,7 +97,7 @@ class Animation(PyrogramType):
width=getattr(video_attributes, "w", 0), width=getattr(video_attributes, "w", 0),
height=getattr(video_attributes, "h", 0), height=getattr(video_attributes, "h", 0),
duration=getattr(video_attributes, "duration", 0), duration=getattr(video_attributes, "duration", 0),
thumb=PhotoSize._parse(client, animation.thumb), thumb=PhotoSize._parse(client, animation.thumbs),
mime_type=animation.mime_type, mime_type=animation.mime_type,
file_size=animation.size, file_size=animation.size,
file_name=file_name, file_name=file_name,

View File

@ -99,7 +99,7 @@ class Audio(PyrogramType):
title=audio_attributes.title, title=audio_attributes.title,
mime_type=audio.mime_type, mime_type=audio.mime_type,
file_size=audio.size, file_size=audio.size,
thumb=PhotoSize._parse(client, audio.thumb), thumb=PhotoSize._parse(client, audio.thumbs),
file_name=file_name, file_name=file_name,
date=audio.date, date=audio.date,
client=client client=client

View File

@ -78,7 +78,7 @@ class Document(PyrogramType):
document.access_hash document.access_hash
) )
), ),
thumb=PhotoSize._parse(client, document.thumb), thumb=PhotoSize._parse(client, document.thumbs),
file_name=file_name, file_name=file_name,
mime_type=document.mime_type, mime_type=document.mime_type,
file_size=document.size, file_size=document.size,

View File

@ -61,7 +61,6 @@ class Photo(PyrogramType):
for raw_size in raw_sizes: for raw_size in raw_sizes:
if isinstance(raw_size, (types.PhotoSize, types.PhotoCachedSize)): if isinstance(raw_size, (types.PhotoSize, types.PhotoCachedSize)):
if isinstance(raw_size, types.PhotoSize): if isinstance(raw_size, types.PhotoSize):
file_size = raw_size.size file_size = raw_size.size
elif isinstance(raw_size, types.PhotoCachedSize): elif isinstance(raw_size, types.PhotoCachedSize):

View File

@ -17,6 +17,7 @@
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from struct import pack from struct import pack
from typing import List, Union
import pyrogram import pyrogram
from pyrogram.api import types from pyrogram.api import types
@ -56,27 +57,30 @@ class PhotoSize(PyrogramType):
self.file_size = file_size self.file_size = file_size
@staticmethod @staticmethod
def _parse(client, photo_size: types.PhotoSize or types.PhotoCachedSize): def _parse(client, thumbs: List) -> Union["PhotoSize", None]:
if isinstance(photo_size, (types.PhotoSize, types.PhotoCachedSize)): if not thumbs:
return None
if isinstance(photo_size, types.PhotoSize): photo_size = thumbs[-1]
file_size = photo_size.size
elif isinstance(photo_size, types.PhotoCachedSize):
file_size = len(photo_size.bytes)
else:
file_size = 0
loc = photo_size.location if not isinstance(photo_size, (types.PhotoSize, types.PhotoCachedSize, types.PhotoStrippedSize)):
return None
if isinstance(loc, types.FileLocation): loc = photo_size.location
return PhotoSize(
file_id=encode( if not isinstance(loc, types.FileLocation):
pack( return None
"<iiqqqqi",
0, loc.dc_id, 0, 0, return PhotoSize(
loc.volume_id, loc.secret, loc.local_id)), file_id=encode(
width=photo_size.w, pack(
height=photo_size.h, "<iiqqqqi",
file_size=file_size, 0, loc.dc_id, 0, 0,
client=client loc.volume_id, loc.secret, loc.local_id
) )
),
width=getattr(photo_size, "w", 0),
height=getattr(photo_size, "h", 0),
file_size=getattr(photo_size, "size", len(getattr(photo_size, "bytes", b""))),
client=client
)

View File

@ -127,7 +127,7 @@ class Sticker(PyrogramType):
), ),
width=image_size_attributes.w if image_size_attributes else 0, width=image_size_attributes.w if image_size_attributes else 0,
height=image_size_attributes.h if image_size_attributes else 0, height=image_size_attributes.h if image_size_attributes else 0,
thumb=PhotoSize._parse(client, sticker.thumb), thumb=PhotoSize._parse(client, sticker.thumbs),
# TODO: mask_position # TODO: mask_position
set_name=set_name, set_name=set_name,
emoji=sticker_attributes.alt or None, emoji=sticker_attributes.alt or None,

View File

@ -97,7 +97,7 @@ class Video(PyrogramType):
width=video_attributes.w, width=video_attributes.w,
height=video_attributes.h, height=video_attributes.h,
duration=video_attributes.duration, duration=video_attributes.duration,
thumb=PhotoSize._parse(client, video.thumb), thumb=PhotoSize._parse(client, video.thumbs),
mime_type=video.mime_type, mime_type=video.mime_type,
file_size=video.size, file_size=video.size,
file_name=file_name, file_name=file_name,

View File

@ -85,7 +85,7 @@ class VideoNote(PyrogramType):
), ),
length=video_attributes.w, length=video_attributes.w,
duration=video_attributes.duration, duration=video_attributes.duration,
thumb=PhotoSize._parse(client, video_note.thumb), thumb=PhotoSize._parse(client, video_note.thumbs),
file_size=video_note.size, file_size=video_note.size,
mime_type=video_note.mime_type, mime_type=video_note.mime_type,
date=video_note.date, date=video_note.date,

View File

@ -19,6 +19,7 @@
from .chat import Chat from .chat import Chat
from .chat_member import ChatMember from .chat_member import ChatMember
from .chat_members import ChatMembers from .chat_members import ChatMembers
from .chat_permissions import ChatPermissions
from .chat_photo import ChatPhoto from .chat_photo import ChatPhoto
from .chat_preview import ChatPreview from .chat_preview import ChatPreview
from .dialog import Dialog from .dialog import Dialog

View File

@ -18,6 +18,7 @@
import pyrogram import pyrogram
from pyrogram.api import types from pyrogram.api import types
from .chat_permissions import ChatPermissions
from .chat_photo import ChatPhoto from .chat_photo import ChatPhoto
from ..pyrogram_type import PyrogramType from ..pyrogram_type import PyrogramType
@ -44,9 +45,6 @@ class Chat(PyrogramType):
last_name (``str``, *optional*): last_name (``str``, *optional*):
Last name of the other party in a private chat. Last name of the other party in a private chat.
all_members_are_administrators (``bool``, *optional*):
True if a basic group has "All Members Are Admins" enabled.
photo (:obj:`ChatPhoto <pyrogram.ChatPhoto>`, *optional*): photo (:obj:`ChatPhoto <pyrogram.ChatPhoto>`, *optional*):
Chat photo. Suitable for downloads only. Chat photo. Suitable for downloads only.
@ -86,7 +84,6 @@ class Chat(PyrogramType):
username: str = None, username: str = None,
first_name: str = None, first_name: str = None,
last_name: str = None, last_name: str = None,
all_members_are_administrators: bool = None,
photo: ChatPhoto = None, photo: ChatPhoto = None,
description: str = None, description: str = None,
invite_link: str = None, invite_link: str = None,
@ -94,7 +91,8 @@ class Chat(PyrogramType):
sticker_set_name: str = None, sticker_set_name: str = None,
can_set_sticker_set: bool = None, can_set_sticker_set: bool = None,
members_count: int = None, members_count: int = None,
restriction_reason: str = None): restriction_reason: str = None,
default_permissions: "pyrogram.ChatPermissions" = None):
super().__init__(client) super().__init__(client)
self.id = id self.id = id
@ -103,7 +101,6 @@ class Chat(PyrogramType):
self.username = username self.username = username
self.first_name = first_name self.first_name = first_name
self.last_name = last_name self.last_name = last_name
self.all_members_are_administrators = all_members_are_administrators
self.photo = photo self.photo = photo
self.description = description self.description = description
self.invite_link = invite_link self.invite_link = invite_link
@ -112,6 +109,7 @@ class Chat(PyrogramType):
self.can_set_sticker_set = can_set_sticker_set self.can_set_sticker_set = can_set_sticker_set
self.members_count = members_count self.members_count = members_count
self.restriction_reason = restriction_reason self.restriction_reason = restriction_reason
self.default_permissions = default_permissions
@staticmethod @staticmethod
def _parse_user_chat(client, user: types.User) -> "Chat": def _parse_user_chat(client, user: types.User) -> "Chat":
@ -128,17 +126,12 @@ class Chat(PyrogramType):
@staticmethod @staticmethod
def _parse_chat_chat(client, chat: types.Chat) -> "Chat": def _parse_chat_chat(client, chat: types.Chat) -> "Chat":
admins_enabled = getattr(chat, "admins_enabled", None)
if admins_enabled is not None:
admins_enabled = not admins_enabled
return Chat( return Chat(
id=-chat.id, id=-chat.id,
type="group", type="group",
title=chat.title, title=chat.title,
all_members_are_administrators=admins_enabled,
photo=ChatPhoto._parse(client, getattr(chat, "photo", None)), photo=ChatPhoto._parse(client, getattr(chat, "photo", None)),
default_permissions=ChatPermissions._parse(chat.default_banned_rights),
client=client client=client
) )
@ -151,6 +144,7 @@ class Chat(PyrogramType):
username=getattr(channel, "username", None), username=getattr(channel, "username", None),
photo=ChatPhoto._parse(client, getattr(channel, "photo", None)), photo=ChatPhoto._parse(client, getattr(channel, "photo", None)),
restriction_reason=getattr(channel, "restriction_reason", None), restriction_reason=getattr(channel, "restriction_reason", None),
default_permissions=ChatPermissions._parse(channel.default_banned_rights),
client=client client=client
) )
@ -197,7 +191,7 @@ class Chat(PyrogramType):
parsed_chat.description = full_chat.about or None parsed_chat.description = full_chat.about or None
# TODO: Add StickerSet type # TODO: Add StickerSet type
parsed_chat.can_set_sticker_set = full_chat.can_set_stickers parsed_chat.can_set_sticker_set = full_chat.can_set_stickers
parsed_chat.sticker_set_name = full_chat.stickerset parsed_chat.sticker_set_name = getattr(full_chat.stickerset, "short_name", None)
if full_chat.pinned_msg_id: if full_chat.pinned_msg_id:
parsed_chat.pinned_message = await client.get_messages( parsed_chat.pinned_message = await client.get_messages(

View File

@ -30,8 +30,8 @@ class ChatMember(PyrogramType):
Information about the user. Information about the user.
status (``str``): status (``str``):
The member's status in the chat. Can be "creator", "administrator", "member", "restricted", The member's status in the chat.
"left" or "kicked". Can be "creator", "administrator", "member", "restricted", "left" or "kicked".
date (``int``, *optional*): date (``int``, *optional*):
Date when the user joined, unix time. Not available for creator. Date when the user joined, unix time. Not available for creator.
@ -46,52 +46,9 @@ class ChatMember(PyrogramType):
restricted_by (:obj:`User <pyrogram.User>`, *optional*): restricted_by (:obj:`User <pyrogram.User>`, *optional*):
Restricted and kicked only. Information about the user who restricted or kicked this member. Restricted and kicked only. Information about the user who restricted or kicked this member.
until_date (``int``, *optional*): permissions (:obj:`ChatPermissions <pyrogram.ChatPermissions>` *optional*):
Restricted and kicked only. Date when restrictions will be lifted for this user, unix time. Administrators, restricted and kicked members only.
Information about the member permissions.
can_be_edited (``bool``, *optional*):
Administrators only. True, if the bot is allowed to edit administrator privileges of that user.
can_change_info (``bool``, *optional*):
Administrators only. True, if the administrator can change the chat title, photo and other settings.
can_post_messages (``bool``, *optional*):
Administrators only. True, if the administrator can post in the channel, channels only.
can_edit_messages (``bool``, *optional*):
Administrators only. True, if the administrator can edit messages of other users and can pin messages,
channels only.
can_delete_messages (``bool``, *optional*):
Administrators only. True, if the administrator can delete messages of other users.
can_invite_users (``bool``, *optional*):
Administrators only. True, if the administrator can invite new users to the chat.
can_restrict_members (``bool``, *optional*):
Administrators only. True, if the administrator can restrict, ban or unban chat members.
can_pin_messages (``bool``, *optional*):
Administrators only. True, if the administrator can pin messages, supergroups only.
can_promote_members (``bool``, *optional*):
Administrators only. True, if the administrator can add new administrators with a subset of his
own privileges or demote administrators that he has promoted, directly or indirectly (promoted by
administrators that were appointed by the user).
can_send_messages (``bool``, *optional*):
Restricted only. True, if the user can send text messages, contacts, locations and venues.
can_send_media_messages (``bool``, *optional*):
Restricted only. True, if the user can send audios, documents, photos, videos, video notes and voice notes,
implies can_send_messages.
can_send_other_messages (``bool``, *optional*):
Restricted only. True, if the user can send animations, games, stickers and use inline bots, implies
can_send_media_messages.
can_add_web_page_previews (``bool``, *optional*):
Restricted only. True, if user may add web page previews to his messages, implies can_send_media_messages.
""" """
def __init__(self, def __init__(self,
@ -103,20 +60,7 @@ class ChatMember(PyrogramType):
invited_by: "pyrogram.User" = None, invited_by: "pyrogram.User" = None,
promoted_by: "pyrogram.User" = None, promoted_by: "pyrogram.User" = None,
restricted_by: "pyrogram.User" = None, restricted_by: "pyrogram.User" = None,
until_date: int = None, permissions: "pyrogram.ChatPermissions" = None):
can_be_edited: bool = None,
can_change_info: bool = None,
can_post_messages: bool = None,
can_edit_messages: bool = None,
can_delete_messages: bool = None,
can_invite_users: bool = None,
can_restrict_members: bool = None,
can_pin_messages: bool = None,
can_promote_members: bool = None,
can_send_messages: bool = None,
can_send_media_messages: bool = None,
can_send_other_messages: bool = None,
can_add_web_page_previews: bool = None):
super().__init__(client) super().__init__(client)
self.user = user self.user = user
@ -125,79 +69,63 @@ class ChatMember(PyrogramType):
self.invited_by = invited_by self.invited_by = invited_by
self.promoted_by = promoted_by self.promoted_by = promoted_by
self.restricted_by = restricted_by self.restricted_by = restricted_by
self.until_date = until_date self.permissions = permissions
self.can_be_edited = can_be_edited
self.can_change_info = can_change_info
self.can_post_messages = can_post_messages
self.can_edit_messages = can_edit_messages
self.can_delete_messages = can_delete_messages
self.can_invite_users = can_invite_users
self.can_restrict_members = can_restrict_members
self.can_pin_messages = can_pin_messages
self.can_promote_members = can_promote_members
self.can_send_messages = can_send_messages
self.can_send_media_messages = can_send_media_messages
self.can_send_other_messages = can_send_other_messages
self.can_add_web_page_previews = can_add_web_page_previews
@staticmethod @staticmethod
def _parse(client, member, users) -> "ChatMember": def _parse(client, member, users) -> "ChatMember":
user = pyrogram.User._parse(client, users[member.user_id]) user = pyrogram.User._parse(client, users[member.user_id])
invited_by = pyrogram.User._parse(client, users[member.inviter_id]) if hasattr(member, "inviter_id") else None
invited_by = (
pyrogram.User._parse(client, users[member.inviter_id])
if getattr(member, "inviter_id", None) else None
)
if isinstance(member, (types.ChannelParticipant, types.ChannelParticipantSelf, types.ChatParticipant)): if isinstance(member, (types.ChannelParticipant, types.ChannelParticipantSelf, types.ChatParticipant)):
return ChatMember(user=user, status="member", date=member.date, invited_by=invited_by, client=client) return ChatMember(
user=user,
status="member",
date=member.date,
invited_by=invited_by,
client=client
)
if isinstance(member, (types.ChannelParticipantCreator, types.ChatParticipantCreator)): if isinstance(member, (types.ChannelParticipantCreator, types.ChatParticipantCreator)):
return ChatMember(user=user, status="creator", client=client) return ChatMember(
user=user,
status="creator",
client=client
)
if isinstance(member, types.ChatParticipantAdmin): if isinstance(member, types.ChatParticipantAdmin):
return ChatMember(user=user, status="administrator", date=member.date, invited_by=invited_by, client=client) return ChatMember(
user=user,
status="administrator",
date=member.date,
invited_by=invited_by,
client=client
)
if isinstance(member, types.ChannelParticipantAdmin): if isinstance(member, types.ChannelParticipantAdmin):
rights = member.admin_rights
return ChatMember( return ChatMember(
user=user, user=user,
status="administrator", status="administrator",
date=member.date, date=member.date,
invited_by=invited_by, invited_by=invited_by,
promoted_by=pyrogram.User._parse(client, users[member.promoted_by]), promoted_by=pyrogram.User._parse(client, users[member.promoted_by]),
can_be_edited=member.can_edit, permissions=pyrogram.ChatPermissions._parse(member),
can_change_info=rights.change_info,
can_post_messages=rights.post_messages,
can_edit_messages=rights.edit_messages,
can_delete_messages=rights.delete_messages,
can_invite_users=rights.invite_users or rights.invite_link,
can_restrict_members=rights.ban_users,
can_pin_messages=rights.pin_messages,
can_promote_members=rights.add_admins,
client=client client=client
) )
if isinstance(member, types.ChannelParticipantBanned): if isinstance(member, types.ChannelParticipantBanned):
rights = member.banned_rights return ChatMember(
chat_member = ChatMember(
user=user, user=user,
status=( status=(
"kicked" if rights.view_messages "kicked" if member.banned_rights.view_messages
else "left" if member.left else "left" if member.left
else "restricted" else "restricted"
), ),
date=member.date, date=member.date,
restricted_by=pyrogram.User._parse(client, users[member.kicked_by]), restricted_by=pyrogram.User._parse(client, users[member.kicked_by]),
until_date=0 if rights.until_date == (1 << 31) - 1 else rights.until_date, permissions=pyrogram.ChatPermissions._parse(member),
client=client client=client
) )
if chat_member.status == "restricted":
chat_member.can_send_messages = not rights.send_messages
chat_member.can_send_media_messages = not rights.send_media
chat_member.can_send_other_messages = (
not rights.send_stickers or not rights.send_gifs or
not rights.send_games or not rights.send_inline
)
chat_member.can_add_web_page_previews = not rights.embed_links
return chat_member

View File

@ -0,0 +1,182 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2019 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from typing import Union
from pyrogram.api import types
from ..pyrogram_type import PyrogramType
class ChatPermissions(PyrogramType):
"""This object represents both a chat default permissions and a single member permissions within a chat.
Some permissions make sense depending on the context: default chat permissions, restricted/kicked member or
administrators in groups or channels.
Args:
until_date (``int``, *optional*):
Applicable to restricted and kicked members only.
Date when user restrictions will be lifted, unix time.
0 means the restrictions will never be lifted (user restricted forever).
can_be_edited (``bool``, *optional*):
Applicable to administrators only.
True, if you are allowed to edit administrator privileges of the user.
can_change_info (``bool``, *optional*):
Applicable to default chat permissions in private groups and administrators in public groups only.
True, if the chat title, photo and other settings can be changed.
can_post_messages (``bool``, *optional*):
Applicable to channel administrators only.
True, if the administrator can post messages in the channel, channels only.
can_edit_messages (``bool``, *optional*):
Applicable to channel administrators only.
True, if the administrator can edit messages of other users and can pin messages, channels only.
can_delete_messages (``bool``, *optional*):
Applicable to administrators only.
True, if the administrator can delete messages of other users.
can_restrict_members (``bool``, *optional*):
Applicable to administrators only.
True, if the administrator can restrict, ban or unban chat members.
can_invite_users (``bool``, *optional*):
Applicable to default chat permissions and administrators only.
True, if new users can be invited to the chat.
can_pin_messages (``bool``, *optional*):
Applicable to default chat permissions in private groups and administrators in public groups only.
True, if messages can be pinned, supergroups only.
can_promote_members (``bool``, *optional*):
Applicable to administrators only.
True, if the administrator can add new administrators with a subset of his own privileges or demote
administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed
by the user).
can_send_messages (``bool``, *optional*):
Applicable to default chat permissions and restricted members only.
True, if text messages, contacts, locations and venues can be sent.
can_send_media_messages (``bool``, *optional*):
Applicable to default chat permissions and restricted members only.
True, if audios, documents, photos, videos, video notes and voice notes can be sent, implies
can_send_messages.
can_send_other_messages (``bool``, *optional*):
Applicable to default chat permissions and restricted members only.
True, if animations, games, stickers and inline bot results can be sent, implies can_send_media_messages.
can_add_web_page_previews (``bool``, *optional*):
Applicable to default chat permissions and restricted members only.
True, if web page previews can be attached to text messages, implies can_send_media_messages.
can_send_polls (``bool``, *optional*):
Applicable to default chat permissions and restricted members only.
True, if polls can be sent, implies can_send_media_messages.
"""
def __init__(
self,
*,
until_date: int = None,
# Admin permissions
can_be_edited: bool = None,
can_change_info: bool = None,
can_post_messages: bool = None, # Channels only
can_edit_messages: bool = None, # Channels only
can_delete_messages: bool = None,
can_restrict_members: bool = None,
can_invite_users: bool = None,
can_pin_messages: bool = None, # Supergroups only
can_promote_members: bool = None,
# Restricted user permissions
can_send_messages: bool = None, # Text, contacts, locations and venues
can_send_media_messages: bool = None, # Audios, documents, photos, videos, video notes and voice notes
can_send_other_messages: bool = None, # Animations (GIFs), games, stickers, inline bot results
can_add_web_page_previews: bool = None,
can_send_polls: bool = None
):
super().__init__(None)
self.until_date = until_date
self.can_be_edited = can_be_edited
self.can_change_info = can_change_info
self.can_post_messages = can_post_messages
self.can_edit_messages = can_edit_messages
self.can_delete_messages = can_delete_messages
self.can_restrict_members = can_restrict_members
self.can_invite_users = can_invite_users
self.can_pin_messages = can_pin_messages
self.can_promote_members = can_promote_members
self.can_send_messages = can_send_messages
self.can_send_media_messages = can_send_media_messages
self.can_send_other_messages = can_send_other_messages
self.can_add_web_page_previews = can_add_web_page_previews
self.can_send_polls = can_send_polls
@staticmethod
def _parse(
entity: Union[
types.ChannelParticipantAdmin,
types.ChannelParticipantBanned,
types.ChatBannedRights
]
) -> "ChatPermissions":
if isinstance(entity, types.ChannelParticipantAdmin):
permissions = entity.admin_rights
return ChatPermissions(
can_be_edited=entity.can_edit,
can_change_info=permissions.change_info,
can_post_messages=permissions.post_messages,
can_edit_messages=permissions.edit_messages,
can_delete_messages=permissions.delete_messages,
can_restrict_members=permissions.ban_users,
can_invite_users=permissions.invite_users,
can_pin_messages=permissions.pin_messages,
can_promote_members=permissions.add_admins
)
if isinstance(entity, (types.ChannelParticipantBanned, types.ChatBannedRights)):
if isinstance(entity, types.ChannelParticipantBanned):
denied_permissions = entity.banned_rights # type: types.ChatBannedRights
else:
denied_permissions = entity
return ChatPermissions(
until_date=0 if denied_permissions.until_date == (1 << 31) - 1 else denied_permissions.until_date,
can_send_messages=not denied_permissions.send_messages,
can_send_media_messages=not denied_permissions.send_media,
can_send_other_messages=(
not denied_permissions.send_stickers or not denied_permissions.send_gifs or
not denied_permissions.send_games or not denied_permissions.send_inline
),
can_add_web_page_previews=not denied_permissions.embed_links,
can_send_polls=not denied_permissions.send_polls,
can_change_info=not denied_permissions.change_info,
can_invite_users=not denied_permissions.invite_users,
can_pin_messages=not denied_permissions.pin_messages
)