2017-02-27 22:16:42 +00:00
|
|
|
import asyncio
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
import telegram
|
|
|
|
|
2017-02-27 22:52:47 +00:00
|
|
|
b = telegram.Bot("hidden")
|
2017-02-27 22:16:42 +00:00
|
|
|
|
2017-02-27 22:52:47 +00:00
|
|
|
async def diario(bot, update, arguments):
|
|
|
|
# Sì, ho copiato la funzione dal bot vecchio
|
|
|
|
if len(arguments) > 0:
|
|
|
|
entry = " ".join(arguments)
|
|
|
|
if entry.isprintable():
|
|
|
|
entry = entry.replace("\n", " ")
|
|
|
|
time = update.message.date.timestamp()
|
|
|
|
# TODO: add better file handling
|
|
|
|
fdiario = open("diario.txt", "a")
|
|
|
|
fdiario.write(f"{int(time)}|{entry}\n")
|
|
|
|
fdiario.close()
|
|
|
|
del fdiario
|
|
|
|
await update.message.chat.send_message(bot, "Aggiunto al diario!")
|
2017-02-27 22:16:42 +00:00
|
|
|
|
2017-02-27 22:52:47 +00:00
|
|
|
b.commands["diario"] = diario
|
2017-02-27 22:16:42 +00:00
|
|
|
b.run()
|