Skip to content

Commit 8d7eb2c

Browse files
committed
model: Add functonality for rendering BOT_MARKER if messager is bot.
1 parent b1e3ea6 commit 8d7eb2c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

zulipterminal/model.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,15 @@ def get_all_users(self) -> List[Dict[str, Any]]:
975975
"user_id": user["user_id"],
976976
"status": status,
977977
}
978+
979+
if user["is_bot"]:
980+
self.user_dict[user["email"]] = {
981+
"full_name": user["full_name"],
982+
"email": email,
983+
"user_id": user["user_id"],
984+
"status": "bot",
985+
}
986+
978987
self._all_users_by_id[user["user_id"]] = user
979988
self.user_id_email_dict[user["user_id"]] = email
980989

@@ -985,7 +994,7 @@ def get_all_users(self) -> List[Dict[str, Any]]:
985994
"full_name": bot["full_name"],
986995
"email": email,
987996
"user_id": bot["user_id"],
988-
"status": "inactive",
997+
"status": "bot",
989998
}
990999
self._cross_realm_bots_by_id[bot["user_id"]] = bot
9911000
self._all_users_by_id[bot["user_id"]] = bot
@@ -1012,12 +1021,18 @@ def get_all_users(self) -> List[Dict[str, Any]]:
10121021
for properties in self.user_dict.values()
10131022
if properties["status"] == "inactive"
10141023
]
1024+
bot = [
1025+
properties
1026+
for properties in self.user_dict.values()
1027+
if properties["status"] == "bot"
1028+
]
10151029

10161030
# Construct user_list from sorted components of each list
10171031
user_list = sorted(active, key=lambda u: u["full_name"].casefold())
10181032
user_list += sorted(idle, key=lambda u: u["full_name"].casefold())
10191033
user_list += sorted(offline, key=lambda u: u["full_name"].casefold())
10201034
user_list += sorted(inactive, key=lambda u: u["full_name"].casefold())
1035+
user_list += sorted(bot, key=lambda u: u["full_name"].casefold())
10211036
# Add current user to the top of the list
10221037
user_list.insert(0, current_user)
10231038
self.user_dict[current_user["email"]] = current_user

0 commit comments

Comments
 (0)