some more encoding fixes

This commit is contained in:
Daniel Hiepler 2016-04-12 14:53:15 +02:00
parent c8d6d95d9e
commit 47dd2a0bdf
4 changed files with 6 additions and 6 deletions

View file

@ -388,7 +388,7 @@ class SpectrumBackend:
def handleDataRead(self, data): def handleDataRead(self, data):
self.m_data += bytes(data) self.m_data += data
while len(self.m_data) != 0: while len(self.m_data) != 0:
expected_size = 0 expected_size = 0
if (len(self.m_data) >= 4): if (len(self.m_data) >= 4):

View file

@ -39,7 +39,7 @@ class Buddy():
def __init__(self, owner, number, nick, statusMsg, groups, image_hash): def __init__(self, owner, number, nick, statusMsg, groups, image_hash):
self.nick = nick self.nick = nick
self.owner = owner self.owner = owner
self.number = number self.number = "%s" % number
self.groups = groups self.groups = groups
self.image_hash = image_hash if image_hash is not None else "" self.image_hash = image_hash if image_hash is not None else ""
self.statusMsg = u"" self.statusMsg = u""

View file

@ -36,7 +36,7 @@ class RegisterSession(YowsupApp):
self.backend.handleMessage(self.user, 'bot', self.backend.handleMessage(self.user, 'bot',
'Country code must be a number') 'Country code must be a number')
else: # Succeded in decoding country code else: # Succeded in decoding country code
country_code = str(country_code) country_code = "%s" % country_code
if country_code != self.number[:len(country_code)]: if country_code != self.number[:len(country_code)]:
self.backend.handleMessage(self.user, self.backend.handleMessage(self.user,
'bot', 'Number does not start with provided country code') 'bot', 'Number does not start with provided country code')

View file

@ -181,7 +181,7 @@ class YowsupApp(object):
- to: (xxxxxxxxxx@s.whatsapp.net) who to send the message to - to: (xxxxxxxxxx@s.whatsapp.net) who to send the message to
- message: (str) the body of the message - message: (str) the body of the message
""" """
messageEntity = TextMessageProtocolEntity(message, to = to) messageEntity = TextMessageProtocolEntity(message.encode('utf-8'), to = to)
self.sendEntity(messageEntity) self.sendEntity(messageEntity)
return messageEntity.getId() return messageEntity.getId()
@ -566,7 +566,7 @@ class YowsupApp(object):
""" """
pass pass
def onTextMessage(self, _id, _from, to, notify, timestamp, participant, offline, retry, body): def onTextMessage(self, _id, _from, to, notify, timestamp, participant, offline, retry, body):
""" """
Called when text message is received Called when text message is received
@ -709,7 +709,7 @@ class YowsupApp(object):
def sendEntity(self, entity): def sendEntity(self, entity):
"""Sends an entity down the stack (as if YowsupAppLayer called toLower)""" """Sends an entity down the stack (as if YowsupAppLayer called toLower)"""
self.stack.broadcastEvent(YowLayerEvent(YowsupAppLayer.TO_LOWER_EVENT, self.stack.broadcastEvent(YowLayerEvent(YowsupAppLayer.TO_LOWER_EVENT,
entity = bytearray(entity) entity = entity
)) ))
def sendIq(self, iq, onSuccess = None, onError = None): def sendIq(self, iq, onSuccess = None, onError = None):