Add restriction_reason to User and Chat types. Closes #144

This commit is contained in:
Dan 2018-10-18 11:10:37 +02:00
parent d580a78787
commit e88972a8f6
3 changed files with 17 additions and 4 deletions

View File

@ -168,6 +168,7 @@ def parse_user(user: types.User) -> pyrogram_types.User or None:
phone_number=user.phone,
photo=parse_chat_photo(user.photo),
status=parse_user_status(user.status, is_bot=user.bot),
restriction_reason=user.restriction_reason
) if user else None
@ -187,7 +188,8 @@ def parse_user_chat(user: types.User) -> pyrogram_types.Chat:
username=user.username,
first_name=user.first_name,
last_name=user.last_name,
photo=parse_chat_photo(user.photo)
photo=parse_chat_photo(user.photo),
restriction_reason=user.restriction_reason
)
@ -212,7 +214,8 @@ def parse_channel_chat(channel: types.Channel) -> pyrogram_types.Chat:
type="supergroup" if channel.megagroup else "channel",
title=channel.title,
username=getattr(channel, "username", None),
photo=parse_chat_photo(getattr(channel, "photo", None))
photo=parse_chat_photo(getattr(channel, "photo", None)),
restriction_reason=channel.restriction_reason
)

View File

@ -69,6 +69,9 @@ class Chat(Object):
members_count (``int``, *optional*):
Chat members count, for groups and channels only.
restriction_reason (``str``, *optional*):
The reason why this chat might be unavailable to some users.
"""
ID = 0xb0700002
@ -88,7 +91,8 @@ class Chat(Object):
pinned_message=None,
sticker_set_name: str = None,
can_set_sticker_set: bool = None,
members_count: int = None
members_count: int = None,
restriction_reason: str = None
):
self.id = id
self.type = type
@ -104,3 +108,4 @@ class Chat(Object):
self.sticker_set_name = sticker_set_name
self.can_set_sticker_set = can_set_sticker_set
self.members_count = members_count
self.restriction_reason = restriction_reason

View File

@ -61,6 +61,9 @@ class User(Object):
photo (:obj:`ChatPhoto <pyrogram.ChatPhoto>`, *optional*):
User's or bot's current profile photo. Suitable for downloads only.
restriction_reason (``str``, *optional*):
The reason why this bot might be unavailable for some users.
"""
ID = 0xb0700001
@ -79,7 +82,8 @@ class User(Object):
username: str = None,
language_code: str = None,
phone_number: str = None,
photo=None
photo=None,
restriction_reason: str = None
):
self.id = id
self.is_self = is_self
@ -94,3 +98,4 @@ class User(Object):
self.language_code = language_code
self.phone_number = phone_number
self.photo = photo
self.restriction_reason = restriction_reason