diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2022-08-30 15:57:58 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2022-08-30 21:10:51 +0300 |
commit | 765bb8d8c416e6ceaedad0aa261dd05617335d29 (patch) | |
tree | 5d3280f12f6c75efe221f5cd7b472d412c2bfc16 /src/home/bot | |
parent | 4ed7e6859a6764fec09720d6b51a69a017ccd03f (diff) |
inverter: a/c input mode switching
Diffstat (limited to 'src/home/bot')
-rw-r--r-- | src/home/bot/__init__.py | 4 | ||||
-rw-r--r-- | src/home/bot/wrapper.py | 15 |
2 files changed, 10 insertions, 9 deletions
diff --git a/src/home/bot/__init__.py b/src/home/bot/__init__.py index 0d93af3..41ad78e 100644 --- a/src/home/bot/__init__.py +++ b/src/home/bot/__init__.py @@ -1,6 +1,6 @@ from .reporting import ReportingHelper from .lang import LangPack -from .wrapper import Wrapper, Context, text_filter, handlermethod +from .wrapper import Wrapper, Context, text_filter, handlermethod, IgnoreMarkup from .store import Store from .errors import * -from .util import command_usage, user_any_name
\ No newline at end of file +from .util import command_usage, user_any_name diff --git a/src/home/bot/wrapper.py b/src/home/bot/wrapper.py index df7175e..98946ed 100644 --- a/src/home/bot/wrapper.py +++ b/src/home/bot/wrapper.py @@ -35,7 +35,7 @@ languages = { 'en': 'English', 'ru': 'Русский' } -LANG_STARTED = range(1) +LANG_STARTED, = range(1) user_filter: Optional[BaseFilter] = None @@ -47,7 +47,7 @@ def default_langpack() -> LangPack: cancel="Cancel", select_language="Select language on the keyboard.", invalid_language="Invalid language. Please try again.", - language_saved='Saved.', + saved='Saved.', ) lang.ru( start_message="Выберите команду на клавиатуре.", @@ -55,7 +55,7 @@ def default_langpack() -> LangPack: cancel="Отмена", select_language="Выберите язык на клавиатуре.", invalid_language="Неверный язык. Пожалуйста, попробуйте снова", - language_saved="Настройки сохранены." + saved="Настройки сохранены." ) return lang @@ -183,11 +183,12 @@ class Wrapper: lang: LangPack reporting: Optional[ReportingHelper] - def __init__(self): + def __init__(self, + store: Optional[Store] = None): self.updater = Updater(config['bot']['token'], request_kwargs={'read_timeout': 6, 'connect_timeout': 7}) self.lang = default_langpack() - self.store = Store() + self.store = store if store else Store() self.reporting = None init_user_filter() @@ -346,11 +347,11 @@ class Wrapper: break if lang is None: - ValueError('could not find the language') + raise ValueError('could not find the language') self.store.set_user_lang(ctx.user_id, lang) - ctx.reply(ctx.lang('language_saved'), markup=IgnoreMarkup()) + ctx.reply(ctx.lang('saved'), markup=IgnoreMarkup()) self.start(ctx) return ConversationHandler.END |