From dbf4a477ec5ac2b401e74d6664b6373cc3ac0e56 Mon Sep 17 00:00:00 2001 From: moyamo Date: Thu, 7 Jan 2016 21:12:59 +0200 Subject: [PATCH] Prevent None callback from causing crashes --- yowsupwrapper.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/yowsupwrapper.py b/yowsupwrapper.py index 23b84de..bfdba95 100644 --- a/yowsupwrapper.py +++ b/yowsupwrapper.py @@ -304,10 +304,11 @@ class YowsupApp(object): iq = GetSyncIqProtocolEntity(contacts, mode, context) def onSuccess(response, request): # 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) + if success is not None: + 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) @@ -324,11 +325,12 @@ class YowsupApp(object): """ iq = GetStatusesIqProtocolEntity([c + '@s.whatsapp.net' for c in contacts]) def onSuccess(response, request): - self.logger.debug("Received Statuses %s", response) - s = {} - for k, v in response.statuses.iteritems(): - s[k.split('@')[0]] = v - success(s) + if success is not None: + self.logger.debug("Received Statuses %s", response) + s = {} + for k, v in response.statuses.iteritems(): + s[k.split('@')[0]] = v + success(s) self.sendIq(iq, onSuccess = onSuccess, onError = failure)