diff options
author | mrDoctorWho <mrdoctorwho@gmail.com> | 2015-03-02 12:16:38 +0300 |
---|---|---|
committer | mrDoctorWho <mrdoctorwho@gmail.com> | 2015-03-02 12:16:38 +0300 |
commit | a80ae5448da369022481fe15e65b7fcd7ad64979 (patch) | |
tree | f6c53e03345fb0503e656c89aab63dd58323750c | |
parent | acb99b29f5602319b589ded4977e5cf151d498c5 (diff) |
Fixed typo in "keep_online" setting
Fixed user settings loading
Fixed turning off groupchats handling
-rw-r--r-- | extensions/groupchats.py | 6 | ||||
-rw-r--r-- | gateway.py | 19 |
2 files changed, 15 insertions, 10 deletions
diff --git a/extensions/groupchats.py b/extensions/groupchats.py index 9f88895..eedd5ec 100644 --- a/extensions/groupchats.py +++ b/extensions/groupchats.py @@ -72,9 +72,9 @@ def outgoingChatMessageHandler(self, vkChat): """ Handles outging messages (VK) and sends them to XMPP """ - if not self.settings.groupchats: - return None if vkChat.has_key("chat_id"): + if not self.settings.groupchats: + return None owner = vkChat.get("admin_id", "1") fromID = vkChat["uid"] chatID = vkChat["chat_id"] @@ -381,7 +381,7 @@ def exterminateChats(user): for chat in chats: jid = "%s_chat#%s@%s" % (user.vk.userID, chat["chat_id"], ConferenceServer) Chat.setConfig(jid, TransportID, True) - if jid in user.chats: + if jid in getattr(user, "chats", {}): del user.chats[jid] @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # coding: utf-8 -# vk4xmpp gateway, v2.56 +# vk4xmpp gateway, v2.59 # © simpleApps, 2013 — 2015. # Program published under MIT license. @@ -140,7 +140,7 @@ setVars(DefLang, root) # Settings -GLOBAL_USER_SETTINGS = {"keep_onlne": {"label": "Keep my status online", "value": 1}, +GLOBAL_USER_SETTINGS = {"keep_online": {"label": "Keep my status online", "value": 1}, "i_am_ghost": {"label": "I am a ghost", "value": 0}} TRANSPORT_SETTINGS = {"send_unavailable": {"label": "Send unavailable from "\ @@ -262,7 +262,7 @@ def getGatewayRev(): """ Gets gateway revision using git or custom revision number """ - revNumber, rev = 256, 0 + revNumber, rev = 259, 0 shell = os.popen("git describe --always && git log --pretty=format:''").readlines() if shell: revNumber, rev = len(shell), shell[0] @@ -311,6 +311,8 @@ class Settings(object): for key, values in userSettings.iteritems(): if key in self.settings: self.settings[key]["value"] = values["value"] + else: + self.settings[key] = values self.keys = self.settings.keys self.items = self.settings.items @@ -327,9 +329,12 @@ class Settings(object): def __getattr__(self, attr): if attr in self.settings: return self.settings[attr]["value"] - if not hasattr(self, attr): + elif not hasattr(self, attr): + return False + elif not self.settings.has_key(attr): return False - return object.__getattribute__(self, attr) + else: + return object.__getattribute__(self, attr) def exterminate(self): """ @@ -785,7 +790,7 @@ class User(object): try: result = func(self, message) except Exception: - result = None + result = "" crashLog("handle.%s" % func.__name__) if result is None: for func in iter: @@ -876,7 +881,7 @@ class User(object): """ if cTime - self.last_udate > 360 and not self.vk.engine.captcha: if not self.settings.i_am_ghost: - if self.settings.keep_onlne: + if self.settings.keep_online: self.vk.method("account.setOnline") self.last_udate = cTime friends = self.vk.getFriends() |