From 751156535897f513ab6f15e5167a928953c60fa6 Mon Sep 17 00:00:00 2001 From: Max <44889241+Galicarnax@users.noreply.github.com> Date: Wed, 26 May 2021 14:04:32 +0600 Subject: [PATCH] show bot status (#227) --- tg/models.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tg/models.py b/tg/models.py index 95ff57f..15f7ec7 100644 --- a/tg/models.py +++ b/tg/models.py @@ -704,6 +704,8 @@ class UserModel: def get_status(self, user_id: int) -> str: if user_id not in self.users: return "" + if self.is_bot(user_id): + return "bot" user_status = self.users[user_id]["status"] try: @@ -747,6 +749,12 @@ class UserModel: } return order.get(status, sys.maxsize) + def is_bot(self, user_id: int) -> bool: + user = self.get_user(user_id) + if user and user["type"]["@type"] == "userTypeBot": + return True + return False + def is_online(self, user_id: int) -> bool: user = self.get_user(user_id) if (