diff options
author | mrDoctorWho <mrdoctorwho@gmail.com> | 2015-05-05 20:35:15 +0300 |
---|---|---|
committer | mrDoctorWho <mrdoctorwho@gmail.com> | 2015-05-05 20:35:15 +0300 |
commit | d0621638d83da032aae7fe0abd98feaa57b10a68 (patch) | |
tree | 8bd4e888ea58c809345ff417adc5ded1a55e066c | |
parent | a803d44b2a2138aa928b4ebe951ea2674a772511 (diff) |
Fix disconnect() call
-rw-r--r-- | gateway.py | 8 | ||||
-rw-r--r-- | modules/mod_prs_main.py | 15 |
2 files changed, 11 insertions, 12 deletions
@@ -236,7 +236,7 @@ class VK(object): logger.debug("VK going to authenticate (jid: %s)", self.source) self.engine = api.APIBinding(self.token, debug=DEBUG_API) if not self.checkToken(): - raise api.TokenError("The token is invalid (jid: %s)" % self.source) + raise api.TokenError("The token is invalid (jid: %s, token: %s)" % (self.source, self.token)) self.online = True return True @@ -291,15 +291,15 @@ class VK(object): if not self.engine.captcha and (self.online or force): try: result = self.engine.method(method, args) - except (api.InternalServerError, api.AccessDenied): + except (api.InternalServerError, api.AccessDenied) as e: if force: raise - except api.CaptchaNeeded: + except api.CaptchaNeeded as e: executeHandlers("evt04", (self, self.engine.captcha["img"])) self.online = False - except api.NetworkNotFound: + except api.NetworkNotFound as e: self.online = False except api.NotAllowed as e: diff --git a/modules/mod_prs_main.py b/modules/mod_prs_main.py index 8c6ac46..15c3314 100644 --- a/modules/mod_prs_main.py +++ b/modules/mod_prs_main.py @@ -42,21 +42,20 @@ def initializeUser(source, resource, prs): def presence_handler(cl, prs): pType = prs.getType() jidFrom = prs.getFrom() - jidTo = prs.getTo() source = jidFrom.getStripped() - destination = jidTo.getStripped() resource = jidFrom.getResource() + destination = prs.getTo().getStripped() if source in Transport: user = Transport[source] if pType in ("available", "probe", None): - if jidTo == TransportID: + if destination == TransportID: if resource not in user.resources and user not in USERS_ON_INIT: logger.debug("Received presence %s from user. Calling sendInitPresence() (jid: %s)" % (pType, source)) user.resources.add(resource) - utils.runThread(user.sendInitPresence, ()) + utils.runThread(user.sendInitPresence) elif pType == "unavailable": - if jidTo == TransportID and resource in user.resources: + if destination == TransportID and resource in user.resources: user.resources.remove(resource) if user.resources: user.sendOutPresence(source) @@ -64,10 +63,10 @@ def presence_handler(cl, prs): sendPresence(source, TransportID, "unavailable") if transportSettings.send_unavailable: user.sendOutPresence(source) - user.vk.disconnect() try: + user.vk.disconnect() del Transport[source] - except KeyError: + except (AttributeError, KeyError): pass elif pType == "error": @@ -75,7 +74,7 @@ def presence_handler(cl, prs): user.vk.disconnect() elif pType == "subscribe": - sendPresence(source, jidTo, "subscribed") + sendPresence(source, destination, "subscribed") if user.friends: id = vk2xmpp(destination) if id in user.friends: |