diff options
author | nicoco <nicoco@nicoco.fr> | 2023-10-04 00:20:53 +0300 |
---|---|---|
committer | nicoco <nicoco@nicoco.fr> | 2023-10-12 10:27:06 +0300 |
commit | 0efdbac7fa5994700ba316bf397bfce7b2d1ef58 (patch) | |
tree | e9269b2b3af1b9af823b192315bf313bbf22bf93 /gajim/common | |
parent | b1c5209d091bae96782394fb9f8b264fe8dde843 (diff) |
feat: Hint that a contact is a bot in the chat banner
Diffstat (limited to 'gajim/common')
-rw-r--r-- | gajim/common/modules/contacts.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gajim/common/modules/contacts.py b/gajim/common/modules/contacts.py index 89b5c618e..9e3b9212f 100644 --- a/gajim/common/modules/contacts.py +++ b/gajim/common/modules/contacts.py @@ -637,6 +637,15 @@ class BareContact(CommonContact): def type_string(self) -> str: return 'chat' + @property + def is_bot(self) -> bool: + disco_info = app.storage.cache.get_last_disco_info(self._jid) + + if disco_info is not None and disco_info.has_identity('client', 'bot'): + return True + + return any(r.is_bot for r in self.iter_resources()) + class ResourceContact(CommonContact): def __init__(self, logger: LogAdapter, jid: JID, account: str) -> None: @@ -676,6 +685,12 @@ class ResourceContact(CommonContact): identity in disco_info.identities) @property + def is_bot(self): + disco_info = app.storage.cache.get_last_disco_info(self._jid) + return (disco_info is not None + and disco_info.has_identity('client', 'bot')) + + @property def is_available(self) -> bool: return self._presence.available |