From 14f885f1a7f0697f3b9311c36e2ad805cf3e3f5c Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Sat, 24 Dec 2022 19:09:33 +0300 Subject: relay_mqtt_bot, pump_mqtt_bot --- src/home/telegram/bot.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/home/telegram/bot.py') diff --git a/src/home/telegram/bot.py b/src/home/telegram/bot.py index bd09f42..9e60b70 100644 --- a/src/home/telegram/bot.py +++ b/src/home/telegram/bot.py @@ -123,15 +123,25 @@ def handler(**kwargs): return _handler_of_handler(f=f, *args, **inner_kwargs) messages = [] + texts = [] + if 'messages' in kwargs: messages += kwargs['messages'] if 'message' in kwargs: messages.append(kwargs['message']) + + if 'text' in kwargs: + texts.append(kwargs['text']) + if 'texts' in kwargs: + texts.append(kwargs['texts']) + if messages: - _updater.dispatcher.add_handler( - MessageHandler(text_filter(*list(itertools.chain.from_iterable([lang.all(m) for m in messages]))), _handler), - group=0 - ) + texts = list(itertools.chain.from_iterable([lang.all(m) for m in messages])) + + _updater.dispatcher.add_handler( + MessageHandler(text_filter(*texts), _handler), + group=0 + ) if 'command' in kwargs: _updater.dispatcher.add_handler(CommandHandler(kwargs['command'], _handler), group=0) -- cgit v1.2.3