diff --git a/pyrogram/client/types/user_and_chats/user.py b/pyrogram/client/types/user_and_chats/user.py index 1c1d41fe..ed3ea16d 100644 --- a/pyrogram/client/types/user_and_chats/user.py +++ b/pyrogram/client/types/user_and_chats/user.py @@ -104,7 +104,7 @@ class User(PyrogramType): is_bot=user.bot, first_name=user.first_name, last_name=user.last_name, - status=UserStatus.parse(client, user), + status=UserStatus.parse(client, user.status, user.id, user.bot), username=user.username, language_code=user.lang_code, phone_number=user.phone, diff --git a/pyrogram/client/types/user_and_chats/user_status.py b/pyrogram/client/types/user_and_chats/user_status.py index d6bfa13d..d9e27498 100644 --- a/pyrogram/client/types/user_and_chats/user_status.py +++ b/pyrogram/client/types/user_and_chats/user_status.py @@ -77,24 +77,23 @@ class UserStatus(PyrogramType): self.long_time_ago = long_time_ago @staticmethod - def parse(client, user: types.User): - if user.bot: + def parse(client, user_status, user_id: int, is_bot: bool = False): + if is_bot: return None - raw_status = user.status - status = UserStatus(user_id=user.id, client=client, raw=raw_status) + status = UserStatus(user_id=user_id, client=client, raw=user_status) - if isinstance(raw_status, types.UserStatusOnline): + if isinstance(user_status, types.UserStatusOnline): status.online = True - status.date = raw_status.expires - elif isinstance(raw_status, types.UserStatusOffline): + status.date = user_status.expires + elif isinstance(user_status, types.UserStatusOffline): status.offline = True - status.date = raw_status.was_online - elif isinstance(raw_status, types.UserStatusRecently): + status.date = user_status.was_online + elif isinstance(user_status, types.UserStatusRecently): status.recently = True - elif isinstance(raw_status, types.UserStatusLastWeek): + elif isinstance(user_status, types.UserStatusLastWeek): status.within_week = True - elif isinstance(raw_status, types.UserStatusLastMonth): + elif isinstance(user_status, types.UserStatusLastMonth): status.within_month = True else: status.long_time_ago = True