Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
1972:02d21a589be2 | 1973:a9908e751c42 |
---|---|
55 self.type = type_ | 55 self.type = type_ |
56 self.extra = extra | 56 self.extra = extra |
57 self.nick = self.getNick(from_jid) | 57 self.nick = self.getNick(from_jid) |
58 # own_mess is True if message was sent by profile's jid | 58 # own_mess is True if message was sent by profile's jid |
59 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) | 59 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) |
60 # is user mentioned here ? | |
61 if self.parent.type == C.CHAT_GROUP and not self.own_mess: | |
62 for m in msg.itervalues(): | |
63 if self.parent.nick.lower() in m.lower(): | |
64 self._mention = True | |
65 break | |
60 self.widgets = set() # widgets linked to this message | 66 self.widgets = set() # widgets linked to this message |
61 | 67 |
62 @property | 68 @property |
63 def host(self): | 69 def host(self): |
64 return self.parent.host | 70 return self.parent.host |
65 | 71 |
66 @property | 72 @property |
67 def info_type(self): | 73 def info_type(self): |
68 return self.extra.get('info_type') | 74 return self.extra.get('info_type') |
75 | |
76 @property | |
77 def mention(self): | |
78 try: | |
79 return self._mention | |
80 except AttributeError: | |
81 return False | |
69 | 82 |
70 def getNick(self, entity): | 83 def getNick(self, entity): |
71 """Return nick of an entity when possible""" | 84 """Return nick of an entity when possible""" |
72 contact_list = self.host.contact_lists[self.profile] | 85 contact_list = self.host.contact_lists[self.profile] |
73 if self.type == C.MESS_TYPE_INFO and self.info_type in ROOM_USER_MOVED: | 86 if self.type == C.MESS_TYPE_INFO and self.info_type in ROOM_USER_MOVED: |