diff options
author | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-11-09 22:41:31 +0000 |
---|---|---|
committer | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-11-09 22:41:31 +0000 |
commit | 0f39961a5d12ecad0e8311c1f6eb6d54de3423ee (patch) | |
tree | be72b82d86a514c284609ab32108f17fd2894e03 | |
parent | 7fd6153720746edff4af900dc9c3579d3cde6e32 (diff) | |
download | poezio-0f39961a5d12ecad0e8311c1f6eb6d54de3423ee.tar.gz poezio-0f39961a5d12ecad0e8311c1f6eb6d54de3423ee.tar.bz2 poezio-0f39961a5d12ecad0e8311c1f6eb6d54de3423ee.tar.xz poezio-0f39961a5d12ecad0e8311c1f6eb6d54de3423ee.zip |
correctly receive the subjects from the MUCs
-rw-r--r-- | src/core.py | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/src/core.py b/src/core.py index 23bc3ed4..9dd72861 100644 --- a/src/core.py +++ b/src/core.py @@ -32,6 +32,9 @@ from datetime import datetime import common import theme +import logging + +log = logging.getLogger(__name__) import multiuserchat as muc from connection import connection @@ -145,6 +148,7 @@ class Core(object): self.xmpp.add_event_handler("session_start", self.on_connected) self.xmpp.add_event_handler("groupchat_presence", self.on_groupchat_presence) self.xmpp.add_event_handler("groupchat_message", self.on_groupchat_message) + self.xmpp.add_event_handler("groupchat_subject", self.on_groupchat_subject) self.xmpp.add_event_handler("message", self.on_message) self.xmpp.add_event_handler("got_online" , self.on_got_online) self.xmpp.add_event_handler("got_offline" , self.on_got_offline) @@ -782,6 +786,23 @@ class Core(object): self.refresh_window() return r + def on_groupchat_subject(self, message): + """ + triggered when the topic is changed + """ + nick_from = message['mucnick'] + room_from = message.getMucroom() + room = self.get_room_by_name(room_from) + subject = message['subject'] + if not subject: + return + if nick_from: + self.add_message_to_text_buffer(room, _("%(nick)s changed the subject to: %(subject)s") % {'nick':nick_from, 'subject':subject}, time=None) + else: + self.add_message_to_text_buffer(room, _("The subject is: %(subject)s") % {'subject':subject}, time=None) + room.topic = subject.replace('\n', '|') + self.refresh_window() + def on_groupchat_message(self, message): """ Triggered whenever a message is received from a multi-user chat room. @@ -809,23 +830,15 @@ class Core(object): room = self.get_room_by_name(room_from) if (room_from in self.ignores) and (nick_from in self.ignores[room_from]): return - room = self.get_room_by_name(room_from) if not room: self.information(_("message received for a non-existing room: %s") % (room_from)) return body = message['body'] - subject = message['subject'] - if subject: - if nick_from: - self.add_message_to_text_buffer(room, _("%(nick)s changed the subject to: %(subject)s") % {'nick':nick_from, 'subject':subject}, time=date) - else: - self.add_message_to_text_buffer(room, _("The subject is: %(subject)s") % {'subject':subject}, time=date) - room.topic = subject.replace('\n', '|') - elif body: + if body: date = date if delayed == True else None self.add_message_to_text_buffer(room, body, date, nick_from) - self.refresh_window() - self.doupdate() + self.refresh_window() + self.doupdate() def add_message_to_text_buffer(self, room, txt, time=None, nickname=None, colorized=False): """ |