Mercurial > libervia-backend
diff frontends/src/quick_frontend/quick_chat.py @ 1973:a9908e751c42
quick_frontend, primitivus (chat): mention detection in group chat + notification (mention and messages)
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 27 Jun 2016 22:37:51 +0200 |
parents | 02d21a589be2 |
children | 981e2abbb56c |
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_chat.py Mon Jun 27 22:36:22 2016 +0200 +++ b/frontends/src/quick_frontend/quick_chat.py Mon Jun 27 22:37:51 2016 +0200 @@ -57,6 +57,12 @@ self.nick = self.getNick(from_jid) # own_mess is True if message was sent by profile's jid self.own_mess = (from_jid.resource == self.parent.nick) if self.parent.type == C.CHAT_GROUP else (from_jid.bare == self.host.profiles[profile].whoami.bare) + # is user mentioned here ? + if self.parent.type == C.CHAT_GROUP and not self.own_mess: + for m in msg.itervalues(): + if self.parent.nick.lower() in m.lower(): + self._mention = True + break self.widgets = set() # widgets linked to this message @property @@ -67,6 +73,13 @@ def info_type(self): return self.extra.get('info_type') + @property + def mention(self): + try: + return self._mention + except AttributeError: + return False + def getNick(self, entity): """Return nick of an entity when possible""" contact_list = self.host.contact_lists[self.profile]