From f21cf65eae858808e2c3a0e2364cf1e4e99b65b6 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 5 Feb 2016 18:57:21 +0100 Subject: [PATCH] =?UTF-8?q?Non=20far=20crashare=20il=20bot=20se=20/diario?= =?UTF-8?q?=20=C3=A8=20vuoto.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bot.py b/bot.py index c2a66469..d31eff87 100644 --- a/bot.py +++ b/bot.py @@ -562,11 +562,15 @@ while True: elif text.startswith('/diario'): print("@" + username + ": /diario ") cmd = text.split(" ", 1) - cmd[1] = cmd[1].replace("\n", " ") - d = filemanager.readfile("diario.txt") - d += str(int(time.time())) + "|" + cmd[1] + "\n" - filemanager.writefile("diario.txt", d) - telegram.sendmessage("Aggiunto al diario RYG.", sentin, source) + if len(cmd) > 1: + cmd[1] = cmd[1].replace("\n", " ") + d = filemanager.readfile("diario.txt") + d += str(int(time.time())) + "|" + cmd[1] + "\n" + filemanager.writefile("diario.txt", d) + telegram.sendmessage("Aggiunto al diario RYG.", sentin, source) + else: + telegram.sendmessage(chr(9888) + " Non hai scritto niente sul diario!\n" + "Sintassi corretta: /diario _quello che vuoi scrivere_", sentin, source) elif text.startswith('/leggi'): print("@" + username + ": /leggi") cmd = text.split(" ", 1)