From c5a6b886d6dc96b74fb4057b92da6c8b10f195c65421e056056b2c62aed93925 Mon Sep 17 00:00:00 2001 From: andrea Date: Sat, 26 Jul 2025 12:38:06 +0200 Subject: [PATCH] allow multiple players insertion --- bot.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 6b5b92f..ba689dd 100644 --- a/bot.py +++ b/bot.py @@ -52,7 +52,7 @@ async def bot_start(update, context): context.application.bot_data['arena'] = Arena async def start_loop_game(update, context, seconds): - await update.message.reply_text(f'Ok capo!! giochero\' per te ogni {seconds}secondi') + await update.message.reply_text(f'Ok capo!! giochero\' per te ogni {seconds}s') chat_id = update.effective_chat.id if 'arena' not in context.application.bot_data: print(f'{chat_id}: Arena non trovata') @@ -81,7 +81,7 @@ async def bot_commands(update, context): context.application.bot_data['ask_name'] = 1 if 'ask_seconds' in context.application.bot_data: del(context.application.bot_data['ask_seconds']) - return await update.message.reply_text('Inserisci il Nome del giocatore') + return await update.message.reply_text('Inserisci il Nome del giocatore (o piu\' nomi separati da virgola)') if text == 'Get Players': print(f'bot_command: {chat_id} Get Players') return await _bot_player.get_players(update, context) @@ -109,11 +109,15 @@ async def bot_commands(update, context): except: return seconds= max(1, text) return await start_loop_game(update, context, seconds) + waiting_for_name= context.application.bot_data.get('ask_name') if waiting_for_name: print(f'bot_command: {chat_id} Collected Player Name {text}') del(context.application.bot_data['ask_name']) - return await _bot_player.add_player(update, context, text) + players= text.split(',') + for player in players: + await _bot_player.add_player(update, context, player.strip()) + return print(f'{chat_id} ha inviato questo testo: {text}') await update.message.reply_text(_botsyms.WIP_MSG)