mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +00:00
Fix broken UpdateStatus in case of incoming updates
This commit is contained in:
parent
1873344467
commit
6a0a271d24
@ -104,7 +104,7 @@ class User(PyrogramType):
|
|||||||
is_bot=user.bot,
|
is_bot=user.bot,
|
||||||
first_name=user.first_name,
|
first_name=user.first_name,
|
||||||
last_name=user.last_name,
|
last_name=user.last_name,
|
||||||
status=UserStatus.parse(client, user),
|
status=UserStatus.parse(client, user.status, user.id, user.bot),
|
||||||
username=user.username,
|
username=user.username,
|
||||||
language_code=user.lang_code,
|
language_code=user.lang_code,
|
||||||
phone_number=user.phone,
|
phone_number=user.phone,
|
||||||
|
@ -77,24 +77,23 @@ class UserStatus(PyrogramType):
|
|||||||
self.long_time_ago = long_time_ago
|
self.long_time_ago = long_time_ago
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse(client, user: types.User):
|
def parse(client, user_status, user_id: int, is_bot: bool = False):
|
||||||
if user.bot:
|
if is_bot:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
raw_status = user.status
|
status = UserStatus(user_id=user_id, client=client, raw=user_status)
|
||||||
status = UserStatus(user_id=user.id, client=client, raw=raw_status)
|
|
||||||
|
|
||||||
if isinstance(raw_status, types.UserStatusOnline):
|
if isinstance(user_status, types.UserStatusOnline):
|
||||||
status.online = True
|
status.online = True
|
||||||
status.date = raw_status.expires
|
status.date = user_status.expires
|
||||||
elif isinstance(raw_status, types.UserStatusOffline):
|
elif isinstance(user_status, types.UserStatusOffline):
|
||||||
status.offline = True
|
status.offline = True
|
||||||
status.date = raw_status.was_online
|
status.date = user_status.was_online
|
||||||
elif isinstance(raw_status, types.UserStatusRecently):
|
elif isinstance(user_status, types.UserStatusRecently):
|
||||||
status.recently = True
|
status.recently = True
|
||||||
elif isinstance(raw_status, types.UserStatusLastWeek):
|
elif isinstance(user_status, types.UserStatusLastWeek):
|
||||||
status.within_week = True
|
status.within_week = True
|
||||||
elif isinstance(raw_status, types.UserStatusLastMonth):
|
elif isinstance(user_status, types.UserStatusLastMonth):
|
||||||
status.within_month = True
|
status.within_month = True
|
||||||
else:
|
else:
|
||||||
status.long_time_ago = True
|
status.long_time_ago = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user