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 urllib
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from PIL import Image
|
# from PIL import Image
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -281,9 +281,11 @@ class Session(YowsupApp):
|
||||||
def onTextMessage(self, _id, _from, to, notify, timestamp, participant,
|
def onTextMessage(self, _id, _from, to, notify, timestamp, participant,
|
||||||
offline, retry, body):
|
offline, retry, body):
|
||||||
|
|
||||||
self.logger.debug('received TextMessage: %s' %
|
self.logger.debug('received TextMessage' +
|
||||||
[_id, _from, to, notify, timestamp,
|
' '.join(map(str, [
|
||||||
participant, offline, retry, body]
|
_id, _from, to, notify, timestamp,
|
||||||
|
participant, offline, retry, body.encode("utf-8")
|
||||||
|
]))
|
||||||
)
|
)
|
||||||
buddy = _from.split('@')[0]
|
buddy = _from.split('@')[0]
|
||||||
messageContent = utils.softToUni(body)
|
messageContent = utils.softToUni(body)
|
||||||
|
@ -311,6 +313,13 @@ class Session(YowsupApp):
|
||||||
participant = image.participant
|
participant = image.participant
|
||||||
if image.caption is None:
|
if image.caption is None:
|
||||||
image.caption = ''
|
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
|
if participant is not None: # Group message
|
||||||
partname = participant.split('@')[0]
|
partname = participant.split('@')[0]
|
||||||
if image._from.split('@')[1] == 'broadcast': # Broadcast message
|
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)
|
return "%d %s ago" % (diff, period)
|
||||||
|
|
||||||
def softToUni(message):
|
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):
|
def decodePassword(password):
|
||||||
return base64.b64decode(bytes(password))
|
return base64.b64decode(bytes(password))
|
||||||
|
|
|
@ -4,6 +4,7 @@ from __future__ import unicode_literals
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from yowsup import env
|
from yowsup import env
|
||||||
|
from yowsup.env import S40YowsupEnv
|
||||||
from yowsup.stacks import YowStack
|
from yowsup.stacks import YowStack
|
||||||
from yowsup.common import YowConstants
|
from yowsup.common import YowConstants
|
||||||
from yowsup.layers import YowLayerEvent, YowParallelLayer
|
from yowsup.layers import YowLayerEvent, YowParallelLayer
|
||||||
|
@ -56,8 +57,6 @@ from yowsup.registration import WARegRequest
|
||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
#from session import MsgIDs
|
|
||||||
|
|
||||||
class YowsupApp(object):
|
class YowsupApp(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
env.CURRENT_ENV = env.AndroidYowsupEnv()
|
env.CURRENT_ENV = env.AndroidYowsupEnv()
|
||||||
|
@ -85,8 +84,14 @@ class YowsupApp(object):
|
||||||
YowStanzaRegulator,
|
YowStanzaRegulator,
|
||||||
YowNetworkLayer
|
YowNetworkLayer
|
||||||
)
|
)
|
||||||
|
|
||||||
self.logger = logging.getLogger(self.__class__.__name__)
|
self.logger = logging.getLogger(self.__class__.__name__)
|
||||||
self.stack = YowStack(layers)
|
stackBuilder = YowStackBuilder()
|
||||||
|
|
||||||
|
self.stack = stackBuilder \
|
||||||
|
.pushDefaultLayers(True) \
|
||||||
|
.push(YowsupAppLayer) \
|
||||||
|
.build()
|
||||||
self.stack.broadcastEvent(
|
self.stack.broadcastEvent(
|
||||||
YowLayerEvent(YowsupAppLayer.EVENT_START, caller = self)
|
YowLayerEvent(YowsupAppLayer.EVENT_START, caller = self)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue