Merge remote-tracking branch 'nicos/yowsup-2' into yowsup-2
This commit is contained in:
commit
269dbdc12d
|
@ -89,6 +89,7 @@ message Room {
|
||||||
message RoomList {
|
message RoomList {
|
||||||
repeated string room = 1;
|
repeated string room = 1;
|
||||||
repeated string name = 2;
|
repeated string name = 2;
|
||||||
|
optional string user = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ParticipantFlag {
|
enum ParticipantFlag {
|
||||||
|
@ -111,6 +112,7 @@ message Participant {
|
||||||
optional string statusMessage = 6;
|
optional string statusMessage = 6;
|
||||||
optional string newname = 7;
|
optional string newname = 7;
|
||||||
optional string iconHash = 8;
|
optional string iconHash = 8;
|
||||||
|
optional string alias = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
message VCard {
|
message VCard {
|
||||||
|
@ -152,6 +154,10 @@ message BackendConfig {
|
||||||
required string config = 1;
|
required string config = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message APIVersion {
|
||||||
|
required int32 version = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message WrapperMessage {
|
message WrapperMessage {
|
||||||
enum Type {
|
enum Type {
|
||||||
TYPE_CONNECTED = 1;
|
TYPE_CONNECTED = 1;
|
||||||
|
@ -188,8 +194,10 @@ message WrapperMessage {
|
||||||
TYPE_CONV_MESSAGE_ACK = 33;
|
TYPE_CONV_MESSAGE_ACK = 33;
|
||||||
TYPE_RAW_XML = 34;
|
TYPE_RAW_XML = 34;
|
||||||
TYPE_BUDDIES = 35;
|
TYPE_BUDDIES = 35;
|
||||||
|
TYPE_API_VERSION = 36;
|
||||||
}
|
}
|
||||||
required Type type = 1;
|
required Type type = 1;
|
||||||
optional bytes payload = 2;
|
optional bytes payload = 2;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -320,6 +320,7 @@ class Session(YowsupApp):
|
||||||
self.logger.debug('Received %s message: %s' % (type, media))
|
self.logger.debug('Received %s message: %s' % (type, media))
|
||||||
buddy = media._from.split('@')[0]
|
buddy = media._from.split('@')[0]
|
||||||
participant = media.participant
|
participant = media.participant
|
||||||
|
caption = ''
|
||||||
|
|
||||||
if media.isEncrypted():
|
if media.isEncrypted():
|
||||||
self.logger.debug('Received encrypted media message')
|
self.logger.debug('Received encrypted media message')
|
||||||
|
@ -336,18 +337,22 @@ class Session(YowsupApp):
|
||||||
else:
|
else:
|
||||||
url = media.url
|
url = media.url
|
||||||
|
|
||||||
|
if type == 'image':
|
||||||
|
caption = media.caption
|
||||||
|
|
||||||
if participant is not None: # Group message
|
if participant is not None: # Group message
|
||||||
partname = participant.split('@')[0]
|
partname = participant.split('@')[0]
|
||||||
if media._from.split('@')[1] == 'broadcast': # Broadcast message
|
if media._from.split('@')[1] == 'broadcast': # Broadcast message
|
||||||
self.sendMessageToXMPP(partname, self.broadcast_prefix, media.timestamp)
|
self.sendMessageToXMPP(partname, self.broadcast_prefix, media.timestamp)
|
||||||
self.sendMessageToXMPP(partname, url, media.timestamp)
|
self.sendMessageToXMPP(partname, url, media.timestamp)
|
||||||
self.sendMessageToXMPP(partname, media.caption, media.timestamp)
|
self.sendMessageToXMPP(partname, caption, media.timestamp)
|
||||||
else: # Group message
|
else: # Group message
|
||||||
self.sendGroupMessageToXMPP(buddy, partname, url, media.timestamp)
|
self.sendGroupMessageToXMPP(buddy, partname, url, media.timestamp)
|
||||||
self.sendGroupMessageToXMPP(buddy, partname, media.caption, media.timestamp)
|
self.sendGroupMessageToXMPP(buddy, partname, caption, media.timestamp)
|
||||||
else:
|
else:
|
||||||
self.sendMessageToXMPP(buddy, url, media.timestamp)
|
self.sendMessageToXMPP(buddy, url, media.timestamp)
|
||||||
self.sendMessageToXMPP(buddy, media.caption, media.timestamp)
|
self.sendMessageToXMPP(buddy, caption, media.timestamp)
|
||||||
|
|
||||||
self.sendReceipt(media._id, media._from, None, media.participant)
|
self.sendReceipt(media._id, media._from, None, media.participant)
|
||||||
self.recvMsgIDs.append((media._id, media._from, media.participant, media.timestamp))
|
self.recvMsgIDs.append((media._id, media._from, media.participant, media.timestamp))
|
||||||
|
|
||||||
|
|
|
@ -58,36 +58,36 @@ args, unknown = parser.parse_known_args()
|
||||||
YowConstants.PATH_STORAGE='/var/lib/spectrum2/' + args.j
|
YowConstants.PATH_STORAGE='/var/lib/spectrum2/' + args.j
|
||||||
|
|
||||||
if args.log is None:
|
if args.log is None:
|
||||||
args.log = '/var/log/spectrum2/' + args.j + '/backends/backend.log'
|
args.log = '/var/log/spectrum2/' + args.j + '/backends/backend.log'
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
filename = args.log,
|
filename = args.log,
|
||||||
format = "%(asctime)-15s %(levelname)s %(name)s: %(message)s",
|
format = "%(asctime)-15s %(levelname)s %(name)s: %(message)s",
|
||||||
level = logging.DEBUG if args.debug else logging.INFO
|
level = logging.DEBUG if args.debug else logging.INFO
|
||||||
)
|
)
|
||||||
|
|
||||||
if args.config is not None:
|
if args.config is not None:
|
||||||
specConf = SpectrumConfig(args.config)
|
specConf = SpectrumConfig(args.config)
|
||||||
else:
|
else:
|
||||||
specConf = None
|
specConf = None
|
||||||
|
|
||||||
# Handler
|
# Handler
|
||||||
def handleTransportData(data):
|
def handleTransportData(data):
|
||||||
try:
|
try:
|
||||||
plugin.handleDataRead(data)
|
plugin.handleDataRead(data)
|
||||||
except SystemExit as e:
|
except SystemExit as e:
|
||||||
raise e
|
raise e
|
||||||
except:
|
except:
|
||||||
logger = logging.getLogger('transwhat')
|
logger = logging.getLogger('transwhat')
|
||||||
logger.error(traceback.format_exc())
|
logger.error(traceback.format_exc())
|
||||||
|
|
||||||
e4u.load()
|
e4u.load()
|
||||||
|
|
||||||
closed = False
|
closed = False
|
||||||
def connectionClosed():
|
def connectionClosed():
|
||||||
global closed
|
global closed
|
||||||
closed = True
|
closed = True
|
||||||
|
|
||||||
# Main
|
# Main
|
||||||
io = IOChannel(args.host, args.port, handleTransportData, connectionClosed)
|
io = IOChannel(args.host, args.port, handleTransportData, connectionClosed)
|
||||||
|
@ -95,34 +95,34 @@ io = IOChannel(args.host, args.port, handleTransportData, connectionClosed)
|
||||||
plugin = WhatsAppBackend(io, args.j, specConf)
|
plugin = WhatsAppBackend(io, args.j, specConf)
|
||||||
|
|
||||||
plugin.handleBackendConfig({
|
plugin.handleBackendConfig({
|
||||||
'features': [
|
'features': [
|
||||||
('send_buddies_on_login', 1),
|
('send_buddies_on_login', 1),
|
||||||
('muc', 'true'),
|
('muc', 'true'),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def main():
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
asyncore.loop(timeout=1.0, count=10, use_poll = True)
|
asyncore.loop(timeout=1.0, count=10, use_poll = True)
|
||||||
try:
|
try:
|
||||||
callback = YowStack._YowStack__detachedQueue.get(False) #doesn't block
|
callback = YowStack._YowStack__detachedQueue.get(False) #doesn't block
|
||||||
callback()
|
callback()
|
||||||
except Queue.Empty:
|
except Queue.Empty:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
if closed:
|
if closed:
|
||||||
break
|
break
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
callback = threadutils.eventQueue.get_nowait()
|
callback = threadutils.eventQueue.get_nowait()
|
||||||
except Queue.Empty:
|
except Queue.Empty:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
callback()
|
callback()
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
logger = logging.getLogger('transwhat')
|
logger = logging.getLogger('transwhat')
|
||||||
logger.error(traceback.format_exc())
|
logger.error(traceback.format_exc())
|
||||||
|
|
|
@ -54,7 +54,8 @@ from yowsup.layers.protocol_contacts import YowContactsIqProtocolLayer
|
||||||
from yowsup.layers.protocol_chatstate import YowChatstateProtocolLayer
|
from yowsup.layers.protocol_chatstate import YowChatstateProtocolLayer
|
||||||
from yowsup.layers.protocol_privacy import YowPrivacyProtocolLayer
|
from yowsup.layers.protocol_privacy import YowPrivacyProtocolLayer
|
||||||
from yowsup.layers.protocol_profiles import YowProfilesProtocolLayer
|
from yowsup.layers.protocol_profiles import YowProfilesProtocolLayer
|
||||||
from yowsup.layers.protocol_calls import YowCallsProtocolLayer
|
from yowsup.layers.protocol_calls import YowCallsProtocolLayer
|
||||||
|
from yowsup.layers.axolotl.props import PROP_IDENTITY_AUTOTRUST
|
||||||
|
|
||||||
# ProtocolEntities
|
# ProtocolEntities
|
||||||
from yowsup.layers.protocol_acks.protocolentities import *
|
from yowsup.layers.protocol_acks.protocolentities import *
|
||||||
|
@ -130,6 +131,7 @@ class YowsupApp(object):
|
||||||
"""
|
"""
|
||||||
self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS,
|
self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS,
|
||||||
(username, password))
|
(username, password))
|
||||||
|
self.stack.setProp(PROP_IDENTITY_AUTOTRUST, True)
|
||||||
# self.stack.setProp(YowIqProtocolLayer.PROP_PING_INTERVAL, 5)
|
# self.stack.setProp(YowIqProtocolLayer.PROP_PING_INTERVAL, 5)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue