Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions bot/handlers/rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Comment thread
semperedev marked this conversation as resolved.
if user.telegram_id in members_ids:
update.effective_message.reply_text(
'Ya tenía constancia de que estás en DAFI ⚠️'
)
Expand Down Expand Up @@ -195,26 +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

group_id = Config.get(Config.MAIN_GROUP_ID)

try:
assert group_id is not None

context.bot.send_message(
group_id,
f'¡{update.effective_user.name} está de camino a DAFI!',
)
except (TelegramError, AssertionError):
for member_id in members_ids:
try:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cuidado con los espacios en blanco al final de una línea. Para ir rápido: https://stackoverflow.com/a/30884298

context.bot.send_message(
member_id,
f'¡{update.effective_user.name} está de camino a DAFI!',
)

except:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No olvides utilizar las excepciones correctas en el try-except: TelegramError en este caso.

failed_messages += 1
return

if failed_messages > 0:
update.effective_message.reply_text(
'No he podido avisarles 😓'
)
return
'No he podido avisarles 😓'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cuidado con la indentación, recuerda que tenemos que seguir PEP 8. Para ir rápido: https://flake8.pycqa.org/en/latest/

)

query.edit_message_reply_markup() # To remove the button

Expand Down