Merge remote-tracking branch 'gh/kiv1in/yowsup-2' into develop
This commit is contained in:
commit
86b81b60a8
17
session.py
17
session.py
|
@ -29,7 +29,7 @@ import logging
|
|||
import urllib
|
||||
import time
|
||||
|
||||
from PIL import Image
|
||||
# from PIL import Image
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
@ -281,9 +281,11 @@ class Session(YowsupApp):
|
|||
def onTextMessage(self, _id, _from, to, notify, timestamp, participant,
|
||||
offline, retry, body):
|
||||
|
||||
self.logger.debug('received TextMessage: %s' %
|
||||
[_id, _from, to, notify, timestamp,
|
||||
participant, offline, retry, body]
|
||||
self.logger.debug('received TextMessage' +
|
||||
' '.join(map(str, [
|
||||
_id, _from, to, notify, timestamp,
|
||||
participant, offline, retry, body.encode("utf-8")
|
||||
]))
|
||||
)
|
||||
buddy = _from.split('@')[0]
|
||||
messageContent = utils.softToUni(body)
|
||||
|
@ -311,6 +313,13 @@ class Session(YowsupApp):
|
|||
participant = image.participant
|
||||
if image.caption is None:
|
||||
image.caption = ''
|
||||
|
||||
# Add to message data for descrypt
|
||||
iv, cipherKey = image.getDecryptData();
|
||||
ivHexString = "".join("{:02x}".format(ord(c)) for c in iv)
|
||||
cipherKeyHexString = "".join("{:02x}".format(ord(c)) for c in cipherKey)
|
||||
message = image.url + ';' + ivHexString + ';' + cipherKeyHexString
|
||||
|
||||
if participant is not None: # Group message
|
||||
partname = participant.split('@')[0]
|
||||
if image._from.split('@')[1] == 'broadcast': # Broadcast message
|
||||
|
|
2
utils.py
2
utils.py
|
@ -48,7 +48,7 @@ def ago(secs):
|
|||
return "%d %s ago" % (diff, period)
|
||||
|
||||
def softToUni(message):
|
||||
return e4u.translate(message, reverse=False, **e4u.SOFTBANK_TRANSLATE_PROFILE)
|
||||
return e4u.translate(message.encode("utf-8"), reverse=False, **e4u.SOFTBANK_TRANSLATE_PROFILE)
|
||||
|
||||
def decodePassword(password):
|
||||
return base64.b64decode(bytes(password))
|
||||
|
|
|
@ -4,6 +4,7 @@ from __future__ import unicode_literals
|
|||
import logging
|
||||
|
||||
from yowsup import env
|
||||
from yowsup.env import S40YowsupEnv
|
||||
from yowsup.stacks import YowStack
|
||||
from yowsup.common import YowConstants
|
||||
from yowsup.layers import YowLayerEvent, YowParallelLayer
|
||||
|
@ -56,8 +57,6 @@ from yowsup.registration import WARegRequest
|
|||
|
||||
from functools import partial
|
||||
|
||||
#from session import MsgIDs
|
||||
|
||||
class YowsupApp(object):
|
||||
def __init__(self):
|
||||
env.CURRENT_ENV = env.AndroidYowsupEnv()
|
||||
|
@ -85,8 +84,14 @@ class YowsupApp(object):
|
|||
YowStanzaRegulator,
|
||||
YowNetworkLayer
|
||||
)
|
||||
|
||||
self.logger = logging.getLogger(self.__class__.__name__)
|
||||
self.stack = YowStack(layers)
|
||||
stackBuilder = YowStackBuilder()
|
||||
|
||||
self.stack = stackBuilder \
|
||||
.pushDefaultLayers(True) \
|
||||
.push(YowsupAppLayer) \
|
||||
.build()
|
||||
self.stack.broadcastEvent(
|
||||
YowLayerEvent(YowsupAppLayer.EVENT_START, caller = self)
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue