quick_frontend, primitivus (chat): mention detection in group chat + notification (mention and messages)

This commit is contained in:
Goffi 2016-06-27 22:37:51 +02:00
commit aace5a2520

View file

@ -57,6 +57,12 @@ class Message(object):
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 @@ class Message(object):
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]