1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00
This commit is contained in:
Steffo 2017-03-24 12:56:05 +01:00
parent c84ecfa674
commit 404bda88f4

View file

@ -135,11 +135,13 @@ Sintassi: `/leggi <random | numerofrase>`"""
entry_number = random.randrange(len(entries))
else:
# ...or a specific one
entry_number = arguments[0]
# TODO: check if the entry actually exists
# TODO: check if the first argument is a number
entry_number = int(arguments[0])
# Split the timestamp from the text
entry = entries[entry_number].split("|", 1)
# Parse the timestamp
date = datetime.datetime.fromtimestamp(entry[0]).isoformat()
date = datetime.datetime.fromtimestamp(int(entry[0])).isoformat()
# Get the text
text = entry[1]
# Sanitize the text to prevent TelegramErrors
@ -167,11 +169,13 @@ async def leggi_discord(bot, message, arguments):
entry_number = random.randrange(len(entries))
else:
# ...or a specific one
entry_number = arguments[0]
# TODO: check if the entry actually exists
# TODO: check if the first argument is a number
entry_number = int(arguments[0])
# Split the timestamp from the text
entry = entries[entry_number].split("|", 1)
# Parse the timestamp
date = datetime.datetime.fromtimestamp(entry[0]).isoformat()
date = datetime.datetime.fromtimestamp(int(entry[0])).isoformat()
# Get the text
text = entry[1]
# Sanitize the text to prevent TelegramErrors