summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2015-04-13 15:24:12 +0200
committermathieui <mathieui@mathieui.net>2015-04-13 15:24:12 +0200
commit1c9257b4a28e88c7f575e70939367fc9175ad53c (patch)
tree3bbba19f8cec0ffd01deb7b0d5d357d82ee2b833
parent83113d42fce13e46ccc4783dc8ddc6cc97b1fd94 (diff)
downloadpoezio-1c9257b4a28e88c7f575e70939367fc9175ad53c.tar.gz
poezio-1c9257b4a28e88c7f575e70939367fc9175ad53c.tar.bz2
poezio-1c9257b4a28e88c7f575e70939367fc9175ad53c.tar.xz
poezio-1c9257b4a28e88c7f575e70939367fc9175ad53c.zip
Handle error messages for real
-rw-r--r--src/core/core.py2
-rw-r--r--src/core/handlers.py10
2 files changed, 10 insertions, 2 deletions
diff --git a/src/core/core.py b/src/core/core.py
index a16f4cde..dc4439fd 100644
--- a/src/core/core.py
+++ b/src/core/core.py
@@ -224,6 +224,7 @@ class Core(object):
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("message_error", self.on_error_message)
self.xmpp.add_event_handler("receipt_received", self.on_receipt)
self.xmpp.add_event_handler("got_online", self.on_got_online)
self.xmpp.add_event_handler("got_offline", self.on_got_offline)
@@ -1947,6 +1948,7 @@ class Core(object):
on_groupchat_direct_invitation = handlers.on_groupchat_direct_invitation
on_groupchat_decline = handlers.on_groupchat_decline
on_message = handlers.on_message
+ on_error_message = handlers.on_error_message
on_normal_message = handlers.on_normal_message
on_nick_received = handlers.on_nick_received
on_gaming_event = handlers.on_gaming_event
diff --git a/src/core/handlers.py b/src/core/handlers.py
index 0bca6cd8..a28e7410 100644
--- a/src/core/handlers.py
+++ b/src/core/handlers.py
@@ -224,6 +224,12 @@ def on_message(self, message):
if message['type'] == 'groupchat':
return
# Differentiate both type of messages, and call the appropriate handler.
+ return self.on_normal_message(message)
+
+def on_error_message(self, message):
+ """
+ When receiving any message with type="error"
+ """
jid_from = message['from']
for tab in self.get_tabs(tabs.MucTab):
if tab.name == jid_from.bare:
@@ -231,7 +237,7 @@ def on_message(self, message):
return self.room_error(message, jid_from)
else:
return self.on_groupchat_private_message(message)
- return self.on_normal_message(message)
+ return self.information(self.get_error_message(message, deprecated=True), 'Error')
def on_normal_message(self, message):
"""
@@ -239,7 +245,7 @@ def on_normal_message(self, message):
muc participant)
"""
if message['type'] == 'error':
- return self.information(self.get_error_message(message, deprecated=True), 'Error')
+ return
elif message['type'] == 'headline' and message['body']:
return self.information('%s says: %s' % (message['from'], message['body']), 'Headline')