Handle error messages for real
This commit is contained in:
parent
83113d42fc
commit
1c9257b4a2
2 changed files with 10 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
||||
|
|
Loading…
Reference in a new issue