Prevent no caption in an image from crashing transwhat

This commit is contained in:
moyamo 2015-11-05 17:57:16 +02:00
parent 1c0ae79ec2
commit dbb66e0381
2 changed files with 3 additions and 1 deletions

View file

@ -7,7 +7,7 @@ import logging
import google.protobuf import google.protobuf
def WRAP(MESSAGE, TYPE): def WRAP(MESSAGE, TYPE):
wrap = protocol_pb2.WrapperMessage() wrap = protocol_pb2.WrapperMessage()
wrap.type = TYPE wrap.type = TYPE
wrap.payload = MESSAGE wrap.payload = MESSAGE
return wrap.SerializeToString() return wrap.SerializeToString()

View file

@ -318,6 +318,8 @@ class Session(YowsupApp):
def onImage(self, image): def onImage(self, image):
self.logger.debug('Received image message %s', str(image)) self.logger.debug('Received image message %s', str(image))
buddy = image._from.split('@')[0] buddy = image._from.split('@')[0]
if image.caption is None:
image.caption = ''
message = image.url + ' ' + image.caption message = image.url + ' ' + image.caption
self.sendMessageToXMPP(buddy, message, image.timestamp) self.sendMessageToXMPP(buddy, message, image.timestamp)
self.sendReceipt(image._id, image._from, None, image.participant) self.sendReceipt(image._id, image._from, None, image.participant)