1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00
royalnet/basicbot.py

22 lines
687 B
Python
Raw Normal View History

2017-02-27 22:16:42 +00:00
import asyncio
loop = asyncio.get_event_loop()
import telegram
b = telegram.Bot("hidden")
2017-02-27 22:16:42 +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
b.commands["diario"] = diario
2017-02-27 22:16:42 +00:00
b.run()