diff --git a/davtelepot/admin_tools.py b/davtelepot/admin_tools.py index 29ead8c..1014e70 100644 --- a/davtelepot/admin_tools.py +++ b/davtelepot/admin_tools.py @@ -144,7 +144,7 @@ async def _forward_to(update, bot, sender, addressee, is_admin=False): admin_record=admin_record ) else: - bot.set_custom_parser( + bot.set_individual_text_message_handler( await async_wrapper( _forward_to, bot=bot, @@ -358,7 +358,7 @@ async def start_session(bot, user_record, admin_record): ] ) ) - bot.set_custom_parser( + bot.set_individual_text_message_handler( await async_wrapper( _forward_to, bot=bot, @@ -368,7 +368,7 @@ async def start_session(bot, user_record, admin_record): ), user_record['telegram_id'] ) - bot.set_custom_parser( + bot.set_individual_text_message_handler( await async_wrapper( _forward_to, bot=bot, @@ -413,9 +413,7 @@ async def end_session(bot, user_record, admin_record): ), ) for record in (admin_record, user_record, ): - telegram_id = record['telegram_id'] - if telegram_id in bot.custom_parsers: - del bot.custom_parsers[telegram_id] + bot.remove_individual_text_message_handler(record['telegram_id']) return @@ -424,7 +422,7 @@ async def _talk_button(update, bot): command, *arguments = extract(update['data'], '///').split('|') result, text, reply_markup = '', '', None if command == 'search': - bot.set_custom_parser( + bot.set_individual_text_message_handler( await async_wrapper( _talk_command, bot=bot diff --git a/davtelepot/administration_tools.py b/davtelepot/administration_tools.py index 3d22aab..6edf296 100644 --- a/davtelepot/administration_tools.py +++ b/davtelepot/administration_tools.py @@ -139,10 +139,9 @@ async def _forward_to(update, bot, sender, addressee, is_admin=False): admin_record=admin_record ) else: - bot.set_custom_parser( + bot.set_individual_text_message_handler( await async_wrapper( _forward_to, - bot=bot, sender=sender, addressee=addressee, is_admin=is_admin @@ -353,20 +352,18 @@ async def start_session(bot, user_record, admin_record): ] ) ) - bot.set_custom_parser( + bot.set_individual_text_message_handler( await async_wrapper( _forward_to, - bot=bot, sender=user_record['telegram_id'], addressee=admin_record['telegram_id'], is_admin=False ), user_record['telegram_id'] ) - bot.set_custom_parser( + bot.set_individual_text_message_handler( await async_wrapper( _forward_to, - bot=bot, sender=admin_record['telegram_id'], addressee=user_record['telegram_id'], is_admin=True @@ -408,9 +405,7 @@ async def end_session(bot, user_record, admin_record): ), ) for record in (admin_record, user_record, ): - telegram_id = record['telegram_id'] - if telegram_id in bot.custom_parsers: - del bot.custom_parsers[telegram_id] + bot.remove_individual_text_message_handler(record['telegram_id']) return @@ -419,10 +414,9 @@ async def _talk_button(update, bot): command, *arguments = extract(update['data'], '///').split('|') result, text, reply_markup = '', '', None if command == 'search': - bot.set_custom_parser( + bot.set_individual_text_message_handler( await async_wrapper( _talk_command, - bot=bot ), update )