catch exception if message was not delivered to XMPP

This commit is contained in:
Nicolas 2017-09-09 16:28:53 +02:00
parent 02b45a233e
commit 0c199a8231

View file

@ -285,18 +285,21 @@ class Session(YowsupApp):
self.logger.info("Message received from %s to %s: %s (at ts=%s)" % self.logger.info("Message received from %s to %s: %s (at ts=%s)" %
(buddy, self.legacyName, messageContent, timestamp)) (buddy, self.legacyName, messageContent, timestamp))
if participant is not None: # Group message or broadcast try:
partname = participant.split('@')[0] if participant is not None: # Group message or broadcast
if _from.split('@')[1] == 'broadcast': # Broadcast message partname = participant.split('@')[0]
message = self.broadcast_prefix + messageContent if _from.split('@')[1] == 'broadcast': # Broadcast message
self.sendMessageToXMPP(partname, message, timestamp) message = self.broadcast_prefix + messageContent
else: # Group message self.sendMessageToXMPP(partname, message, timestamp)
if notify is None: else: # Group message
notify = "" if notify is None:
self.sendGroupMessageToXMPP(buddy, partname, messageContent, notify = ""
timestamp, notify) self.sendGroupMessageToXMPP(buddy, partname, messageContent,
else: timestamp, notify)
self.sendMessageToXMPP(buddy, messageContent, timestamp) else:
self.sendMessageToXMPP(buddy, messageContent, timestamp)
except Exception as ex:
self.logger.error("textMessage not delivered to XMPP: %s" % ex)
# Called by superclass # Called by superclass
def onImage(self, image): def onImage(self, image):