1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-12-17 23:24:20 +00:00

Non far crashare il bot se /diario è vuoto.

This commit is contained in:
Steffo 2016-02-05 18:57:21 +01:00
parent f825dff121
commit f21cf65eae

14
bot.py
View file

@ -562,11 +562,15 @@ while True:
elif text.startswith('/diario'): elif text.startswith('/diario'):
print("@" + username + ": /diario ") print("@" + username + ": /diario ")
cmd = text.split(" ", 1) cmd = text.split(" ", 1)
cmd[1] = cmd[1].replace("\n", " ") if len(cmd) > 1:
d = filemanager.readfile("diario.txt") cmd[1] = cmd[1].replace("\n", " ")
d += str(int(time.time())) + "|" + cmd[1] + "\n" d = filemanager.readfile("diario.txt")
filemanager.writefile("diario.txt", d) d += str(int(time.time())) + "|" + cmd[1] + "\n"
telegram.sendmessage("Aggiunto al diario RYG.", sentin, source) 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'): elif text.startswith('/leggi'):
print("@" + username + ": /leggi") print("@" + username + ": /leggi")
cmd = text.split(" ", 1) cmd = text.split(" ", 1)