From 67376d5362e68d92ba4fe06d1508008410e3c95e Mon Sep 17 00:00:00 2001 From: xJavii8 Date: Sun, 31 Oct 2021 10:12:49 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Ahora=20el=20"en=20camino"=20de=20/dafi=20l?= =?UTF-8?q?o=20env=C3=ADa=20a=20los=20interesados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot/handlers/rooms.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/bot/handlers/rooms.py b/bot/handlers/rooms.py index d39986b..07749c0 100644 --- a/bot/handlers/rooms.py +++ b/bot/handlers/rooms.py @@ -109,7 +109,7 @@ def cmd_dafi(update: Update, context: CallbackContext[dict, dict, dict]) -> None context.bot_data['room_queue'] = queue if action == RoomActions.ON: - if user.telegram_id in members: + if user in members: update.effective_message.reply_text( 'Ya tenía constancia de que estás en DAFI ⚠️' ) @@ -201,15 +201,13 @@ def callback_dafi(update: Update, context: CallbackContext[dict, dict, dict]) -> ) return - group_id = Config.get(Config.MAIN_GROUP_ID) - try: - assert group_id is not None + for member_id in members_ids: + context.bot.send_message( + member_id, + f'¡{update.effective_user.name} está de camino a DAFI!', + ) - context.bot.send_message( - group_id, - f'¡{update.effective_user.name} está de camino a DAFI!', - ) except (TelegramError, AssertionError): update.effective_message.reply_text( 'No he podido avisarles 😓' From 6f4a3f77c40424a0c1d7c80236f0bf52be4304d2 Mon Sep 17 00:00:00 2001 From: xJavii8 Date: Mon, 1 Nov 2021 18:29:39 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Usamos=20members=5Fids=20+=20comprobaci?= =?UTF-8?q?=C3=B3n=20de=20errores=20dentro=20del=20bucle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot/handlers/rooms.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/bot/handlers/rooms.py b/bot/handlers/rooms.py index 07749c0..3cc92d0 100644 --- a/bot/handlers/rooms.py +++ b/bot/handlers/rooms.py @@ -109,7 +109,7 @@ def cmd_dafi(update: Update, context: CallbackContext[dict, dict, dict]) -> None context.bot_data['room_queue'] = queue if action == RoomActions.ON: - if user in members: + if user.telegram_id in members_ids: update.effective_message.reply_text( 'Ya tenía constancia de que estás en DAFI ⚠️' ) @@ -195,24 +195,28 @@ def callback_dafi(update: Update, context: CallbackContext[dict, dict, dict]) -> members = list(User.objects.filter(telegram_id__in=members_ids)) if action == 'omw': + failed_messages = 0 if not members: query.edit_message_text( 'Ahora mismo no hay nadie en DAFI 😓' ) return - try: - for member_id in members_ids: + for member_id in members_ids: + try: context.bot.send_message( member_id, f'¡{update.effective_user.name} está de camino a DAFI!', ) - except (TelegramError, AssertionError): + except: + failed_messages += 1 + return + + if failed_messages > 0: update.effective_message.reply_text( - 'No he podido avisarles 😓' - ) - return + 'No he podido avisarles 😓' + ) query.edit_message_reply_markup() # To remove the button