From 2e8c93bd812cd6faffc55a8f6e55156f351bd081 Mon Sep 17 00:00:00 2001 From: mrDoctorWho Date: Mon, 2 Dec 2013 19:16:37 +0700 Subject: add options for change storage files pidFile.txt and Config.txt. Removed unused argument "force" for method() removed "User not allowed to perform this action" --- gateway.py | 18 ++++++++++++------ handlers/IQ.py | 2 +- handlers/Presence.py | 5 +++++ locales/locale.pl | 2 +- locales/locale.ru | 2 +- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/gateway.py b/gateway.py index 924c5b0..5b9a2c0 100644 --- a/gateway.py +++ b/gateway.py @@ -69,8 +69,13 @@ DEBUG_XMPPPY = False THREAD_STACK_SIZE = 0 MAXIMUM_FORWARD_DEPTH = 5 -pidFile = "pidFile.txt" -Config = "Config.txt" +from optparse import OptionParser +oParser = OptionParser(usage = "%prog [options]") +oParser.add_option("-p", "--pid", dest = "pidFile", help = "address used for pid file storage", metavar = "pidFile", default = "pidFile.txt") +oParser.add_option("-c", "--config", dest = "Config", help = "same as -p (--pid) but for config file", metavar = "Config", default = "Config.txt") +(options, args) = oParser.parse_args() +pidFile, Config = options.pidFile, options.Config + PhotoSize = "photo_100" DefLang = "ru" evalJID = "" @@ -201,16 +206,17 @@ class VKLogin(object): return False return True - def method(self, method, args = {}, force = False): + def method(self, method, args = {}): result = {} - if not self.engine.captcha and self.Online or force: + if not self.engine.captcha and self.Online: try: result = self.engine.method(method, args) except api.CaptchaNeeded: logger.error("VKLogin: running captcha challenge for %s" % self.jidFrom) self.captchaChallenge() except api.NotAllowed: - msgSend(Component, self.jidFrom, _("You're not allowed to perform this action."), vk2xmpp(args.get("user_id", TransportID))) + if self.engine.lastMethod[0] == "messages.send": + msgSend(Component, self.jidFrom, _("You're not allowed to perform this action."), vk2xmpp(args.get("user_id", TransportID))) except api.VkApiError as e: if e.message == "User authorization failed: user revoke access for this token.": try: @@ -662,7 +668,7 @@ def main(): Print("\n#-# Finished.") def exit(signal = None, frame = None): # LETS BURN CPU AT LAST TIME! - status = "Shutting down by %s" % ("SIGTERM" if signal else "KeyboardInterrupt") + status = "Shutting down by %s" % ("SIGTERM" if signal == 15 else "SIGINT") Print("#! %s" % status, False) for Class in TransportsList: Class.sendOutPresence(Class.jidFrom, status) diff --git a/handlers/IQ.py b/handlers/IQ.py index f0353f6..4fac364 100644 --- a/handlers/IQ.py +++ b/handlers/IQ.py @@ -158,7 +158,7 @@ def iqRegisterHandler(cl, iq): Class = Transport[jidFromStr] Class.deleteUser(True) result.setPayload([], add = 0) - WatcherMsg(_("User remove registration: %s") % jidFromStr) + WatcherMsg(_("User removed registration: %s") % jidFromStr) else: result = iqBuildError(iq, 0, _("Feature not implemented.")) Sender(cl, result) diff --git a/handlers/Presence.py b/handlers/Presence.py index 9cdf13b..bbd552e 100644 --- a/handlers/Presence.py +++ b/handlers/Presence.py @@ -46,6 +46,11 @@ def prsHandler(cl, prs): if id in Class.friends: if Class.friends[id]["online"]: Sender(cl, xmpp.Presence(jidFrom, frm = jidTo)) + elif pType == "unsubscribe": + if jidFromStr in Transport: + Class.deleteUser(True) + WatcherMsg(_("User removed registration: %s") % jidFromStr) + if jidToStr == TransportID: Class.lastStatus = pType diff --git a/locales/locale.pl b/locales/locale.pl index e5c3640..a28eb4d 100644 --- a/locales/locale.pl +++ b/locales/locale.pl @@ -18,7 +18,7 @@ Auth failed! If this error repeated, please register again. This incident will b \LAttachments:=\LZałączniki: Enter shown text=Wprowadź wyświetlany tekst New user registered: %s=Zarejestrowany nowy użytkownik: %s -User remove registration: %s=Użytkownik usunął rejestrację: %s +User removed registration: %s=Użytkownik usunął rejestrację: %s Type data in fields=Wprowadź dane w pola Autorization page=Strona autoryzacji If you won't get access-token automatically, please, follow authorization link and authorize app,\Land then paste url to password field.=Jeśli jednak nie chcesz otrzymać access-token automatycznie, to kliknij w link z pola, autoryzuj aplikację,\Lа następnie wprowadź otryzmany URL z paska adresu pryeglądarki w ostatnie pole zamiast hasła. diff --git a/locales/locale.ru b/locales/locale.ru index fea712b..caa4f80 100644 --- a/locales/locale.ru +++ b/locales/locale.ru @@ -18,7 +18,7 @@ Auth failed! If this error repeated, please register again. This incident will b \LAttachments:=\LВложения: Enter shown text=Введите показанный текст New user registered: %s=Зарегистрирован новый пользователь: %s -User remove registration: %s=Пользователь удалил регистрацию: %s +User removed registration: %s=Пользователь удалил регистрацию: %s Type data in fields=Введите данные в поля Autorization page=Страница авторизации If you won't get access-token automatically, please, follow authorization link and authorize app,\Land then paste url to password field.=Если же вы не хотите получить access-token автоматически, то пройдите по ссылке из поля, авторизируйте приложение,\Lа затем введите полученный URL из адресной строки браузера в последнее поле вместо пароля. -- cgit v1.2.3