diff options
-rw-r--r-- | src/home/telegram/bot.py | 5 | ||||
-rwxr-xr-x | src/sensors_bot.py | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/home/telegram/bot.py b/src/home/telegram/bot.py index 1a58412..9044b07 100644 --- a/src/home/telegram/bot.py +++ b/src/home/telegram/bot.py @@ -129,7 +129,10 @@ def callbackhandler(**kwargs): @wraps(f) def _handler(*args, **kwargs): return _handler_of_handler(f=f, *args, **kwargs) - _updater.dispatcher.add_handler(CallbackQueryHandler(_handler, pattern=kwargs['callback']), group=0) + pattern_kwargs = {} + if kwargs['callback'] != '*': + pattern_kwargs['pattern'] = kwargs['callback'] + _updater.dispatcher.add_handler(CallbackQueryHandler(_handler, **pattern_kwargs), group=0) return _handler return inner diff --git a/src/sensors_bot.py b/src/sensors_bot.py index 9cf9c5d..dc33a57 100755 --- a/src/sensors_bot.py +++ b/src/sensors_bot.py @@ -90,7 +90,7 @@ def read_sensor(sensor: str, ctx: bot.Context) -> None: ctx.reply(text, markup=InlineKeyboardMarkup(chunks(buttons, 2))) -@bot.callbackhandler +@bot.callbackhandler(callback='*') def callback_handler(ctx: bot.Context) -> None: query = ctx.callback_query @@ -166,7 +166,7 @@ def draw_plot(data, @bot.defaultreplymarkup -def markup(self, ctx: Optional[bot.Context]) -> Optional[ReplyKeyboardMarkup]: +def markup(ctx: Optional[bot.Context]) -> Optional[ReplyKeyboardMarkup]: buttons = [] for k in config['sensors'].keys(): buttons.append(ctx.lang(k)) |