From e4ec4c79259cda052faa9248c44fa13a090a646f Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 9 Apr 2016 23:58:25 +0200 Subject: [PATCH] =?UTF-8?q?Il=20bot=20non=20crasha=20pi=C3=B9=20se=20non?= =?UTF-8?q?=20scrivi=20l'audio=20da=20inviare?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bot.py b/bot.py index f4418baa..6909be98 100644 --- a/bot.py +++ b/bot.py @@ -173,11 +173,17 @@ while True: elif text.startswith('/audio'): print("@" + username + ": /audio") cmd = text.split(" ", 1) - if cmd[1] in audiolist: - sendme = audiolist[cmd[1]] - telegram.senddocument(sendme, sentin, source) + if len(cmd) > 1: + if cmd[1] in audiolist: + sendme = audiolist[cmd[1]] + telegram.senddocument(sendme, sentin, source) + else: + sendme = chr(9888) + " L'audio richiesto non esiste!\n*Audio disponibili*:\n" + for audio in audiolist: + sendme += audio + "\n" + telegram.sendmessage(sendme, sentin, source) else: - sendme = chr(9888) + " L'audio richiesto non esiste!\n*Audio disponibili*:\n" + sendme = chr(9888) + " Per mandare un audio, scrivi `/audio nomeaudio`\n*Audio disponibili*:\n" for audio in audiolist: sendme += audio + "\n" telegram.sendmessage(sendme, sentin, source)