Merge branch 'yowsup-2' into develop

This commit is contained in:
Steffen Vogel 2016-04-06 14:41:41 +02:00
commit 22e5419cda
3 changed files with 32 additions and 2 deletions

2
bot.py
View File

@ -45,7 +45,7 @@ class Bot():
args = message.strip().split(" ")
cmd = args.pop(0)
if cmd[0] == '\\':
if len(cmd) > 0 and cmd[0] == '\\':
try:
self.call(cmd[1:], args)
except KeyError:

11
contrib/spectrum@.service Normal file
View File

@ -0,0 +1,11 @@
[Unit]
description=spectrum2 whatsapp
After=network.target
[Service]
ExecStart=/usr/bin/spectrum2 --no-daemonize -j whatsapp.example.com --config /etc/spectrum2/transports/whatsapp.cfg
Restart=always
User=spectrum2
[Install]
WantedBy=multi-user.target

View File

@ -55,6 +55,25 @@ from functools import partial
#from session import MsgIDs
# Temporarily work around yowsup padding bugs with new protocol
class UpdatedYowAxolotlLayer(YowAxolotlLayer):
def decodeInt7bit(self, string):
idx = 0
while ord(string[idx]) >= 128:
idx += 1
consumedBytes = idx + 1
value = 0
while idx >= 0:
value <<= 7
value += ord(string[idx]) % 128
idx -= 1
return value, consumedBytes
def unpadV2Plaintext(self, v2plaintext):
end = -ord(v2plaintext[-1]) # length of the left padding
length,consumed = self.decodeInt7bit(v2plaintext[1:])
return v2plaintext[1+consumed:end]
# Temporary env until yowsup updates
class UpdatedS40YowsupEnv(env.S40YowsupEnv):
_VERSION = "2.13.39"
@ -85,7 +104,7 @@ class YowsupApp(object):
YowProfilesProtocolLayer,
YowGroupsProtocolLayer,
YowPresenceProtocolLayer)),
YowAxolotlLayer,
UpdatedYowAxolotlLayer,
YowCoderLayer,
YowCryptLayer,
YowStanzaRegulator,