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

@ -133,7 +133,10 @@ class MessageWidget(urwid.WidgetWrap):
markup.append(("msg_lang", u"[{}] ".format(self.selected_lang)))
# message body
markup.append(msg)
if d.mention:
markup.append(("msg_mention", msg))
else:
markup.append(msg)
return markup
@ -391,9 +394,23 @@ class Chat(PrimitivusWidget, quick_chat.QuickChat):
if not message.message:
log.error(u"Received an empty message for uid {}".format(message.uid))
else:
self.mess_walker.append(MessageWidget(message))
wid = MessageWidget(message)
self.mess_walker.append(wid)
self.mess_widgets.focus_position = len(self.mess_walker) - 1 # scroll down
self.host.redraw() # FIXME: should not be necessary
if wid.mess_data.mention:
from_jid = wid.mess_data.from_jid
msg = _(u'You have been mentioned by {nick} in {room}'.format(
nick=wid.mess_data.nick,
room=self.target,
))
self.host.notify(C.NOTIFY_MENTION, from_jid, msg, widget=self, profile=self.profile)
elif self.type == C.CHAT_ONE2ONE:
from_jid = wid.mess_data.from_jid
msg = _(u'{entity} is talking to you'.format(
entity=from_jid,
))
self.host.notify(C.NOTIFY_MESSAGE, from_jid, msg, widget=self, profile=self.profile)
def addUser(self, nick):
occupant = super(Chat, self).addUser(nick)