diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2022-11-07 00:35:10 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2022-11-07 00:35:10 +0300 |
commit | 6b1d3e8d7d2dde2cebdf7e24d4d4fb33b2bf2a8d (patch) | |
tree | 15b651c0ddd22f59601dd517d604f83762621adc /src/home | |
parent | cecd192486a73c0f1c242f63be97047aecabb5bf (diff) |
sound_bot: rewrite using new bot framework (not tested)
Diffstat (limited to 'src/home')
-rw-r--r-- | src/home/telegram/bot.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/home/telegram/bot.py b/src/home/telegram/bot.py index 9f1e8f3..004f795 100644 --- a/src/home/telegram/bot.py +++ b/src/home/telegram/bot.py @@ -25,7 +25,7 @@ from home.api.types import BotType from ._botlang import lang, languages from ._botdb import BotDatabase -from ._botutil import ReportingHelper, exc2text, IgnoreMarkup +from ._botutil import ReportingHelper, exc2text, IgnoreMarkup, user_any_name from ._botcontext import Context @@ -112,7 +112,7 @@ def handler(**kwargs): elif 'command' in kwargs: _updater.dispatcher.add_handler(CommandHandler(kwargs['command'], _handler), group=0) elif 'callback' in kwargs: - _updater.dispatcher.add_handler(CallbackQueryHandler(_handler), group=0) + _updater.dispatcher.add_handler(CallbackQueryHandler(_handler, pattern=kwargs['callback']), group=0) return _handler return inner @@ -124,12 +124,14 @@ def simplehandler(f: callable): return _handler -def callbackhandler(f: callable): - @wraps(f) - def _handler(*args, **kwargs): - return _handler_of_handler(f=f, *args, **kwargs) - _updater.dispatcher.add_handler(CallbackQueryHandler(_handler), group=0) - return _handler +def callbackhandler(**kwargs): + def inner(f): + @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) + return _handler + return inner def exceptionhandler(f: callable): |