From 8e1be863191e12caf40cacb8f3b968190eabbb27 Mon Sep 17 00:00:00 2001 From: moyamo Date: Wed, 6 Jan 2016 17:38:52 +0200 Subject: [PATCH] Correct the format of the contacts numbers when syncing --- yowsupwrapper.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/yowsupwrapper.py b/yowsupwrapper.py index 14e2256..8271400 100644 --- a/yowsupwrapper.py +++ b/yowsupwrapper.py @@ -291,9 +291,16 @@ class YowsupApp(object): # TODO: Implement callbacks mode = GetSyncIqProtocolEntity.MODE_DELTA if delta else GetSyncIqProtocolEntity.MODE_FULL context = GetSyncIqProtocolEntity.CONTEXT_INTERACTIVE if interactive else GetSyncIqProtocolEntity.CONTEXT_REGISTRATION + # International contacts must be preceded by a plus. Other numbers are + # considered local. + contacts = ['+' + c for c in contacts] iq = GetSyncIqProtocolEntity(contacts, mode, context) def onSuccess(response, request): - success(response.inNumbers.keys(), response.outNumbers.keys(), response.invalidNumbers) + # Remove leading plus + existing = [s[1:] for s in response.inNumbers.keys()] + nonexisting = [s[1:] for s in response.outNumbers.keys()] + invalid = [s[1:] for s in response.invalidNumbers] + success(existing, nonexisting, invalid) self.sendIq(iq, onSuccess = onSuccess, onError = failure)