diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2022-11-07 01:13:26 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2022-11-07 01:13:26 +0300 |
commit | 2addba8bcd5555946ac509c10b5b6f1c9a1fb40a (patch) | |
tree | 2627c56e3a67e21f1a4c72f6fe8536852315f050 /src/sensors_bot.py | |
parent | 91aff8bc85df529206124452d8bca93b2a23478d (diff) |
sensors_bot: experimental fix
Diffstat (limited to 'src/sensors_bot.py')
-rwxr-xr-x | src/sensors_bot.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/sensors_bot.py b/src/sensors_bot.py index dc33a57..c7fe19a 100755 --- a/src/sensors_bot.py +++ b/src/sensors_bot.py @@ -26,12 +26,6 @@ from home.api.types import ( config.load('sensors_bot') bot.initialize() -_sensor_names = [] -for k, v in config['sensors'].items(): - _sensor_names.append(k) - bot.lang.set({k: v['label_ru']}, 'ru') - bot.lang.set({k: v['label_en']}, 'en') - bot.lang.ru( start_message="Выберите датчик на клавиатуре", unknown_command="Неизвестная команда", @@ -45,7 +39,6 @@ bot.lang.ru( loading="Загрузка...", n_hrs="график за %d ч." ) - bot.lang.en( start_message="Select the sensor on the keyboard", unknown_command="Unknown command", @@ -65,7 +58,14 @@ logger = logging.getLogger(__name__) plot_hours = [3, 6, 12, 24] -@bot.handler(messages=_sensor_names) +_sensor_names = [] +for k, v in config['sensors'].items(): + _sensor_names.append(k) + bot.lang.set({k: v['label_ru']}, 'ru') + bot.lang.set({k: v['label_en']}, 'en') + + +@bot.handler(messages=_sensor_names, argument='message_key') def read_sensor(sensor: str, ctx: bot.Context) -> None: host = config['sensors'][sensor]['ip'] port = config['sensors'][sensor]['port'] @@ -177,4 +177,5 @@ def markup(ctx: Optional[bot.Context]) -> Optional[ReplyKeyboardMarkup]: if __name__ == '__main__': if 'api' in config: bot.enable_logging(BotType.SENSORS) + bot.run() |