mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
TODO
This commit is contained in:
parent
c84ecfa674
commit
404bda88f4
1 changed files with 8 additions and 4 deletions
12
grandbot.py
12
grandbot.py
|
@ -135,11 +135,13 @@ Sintassi: `/leggi <random | numerofrase>`"""
|
||||||
entry_number = random.randrange(len(entries))
|
entry_number = random.randrange(len(entries))
|
||||||
else:
|
else:
|
||||||
# ...or a specific one
|
# ...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
|
# Split the timestamp from the text
|
||||||
entry = entries[entry_number].split("|", 1)
|
entry = entries[entry_number].split("|", 1)
|
||||||
# Parse the timestamp
|
# Parse the timestamp
|
||||||
date = datetime.datetime.fromtimestamp(entry[0]).isoformat()
|
date = datetime.datetime.fromtimestamp(int(entry[0])).isoformat()
|
||||||
# Get the text
|
# Get the text
|
||||||
text = entry[1]
|
text = entry[1]
|
||||||
# Sanitize the text to prevent TelegramErrors
|
# Sanitize the text to prevent TelegramErrors
|
||||||
|
@ -167,11 +169,13 @@ async def leggi_discord(bot, message, arguments):
|
||||||
entry_number = random.randrange(len(entries))
|
entry_number = random.randrange(len(entries))
|
||||||
else:
|
else:
|
||||||
# ...or a specific one
|
# ...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
|
# Split the timestamp from the text
|
||||||
entry = entries[entry_number].split("|", 1)
|
entry = entries[entry_number].split("|", 1)
|
||||||
# Parse the timestamp
|
# Parse the timestamp
|
||||||
date = datetime.datetime.fromtimestamp(entry[0]).isoformat()
|
date = datetime.datetime.fromtimestamp(int(entry[0])).isoformat()
|
||||||
# Get the text
|
# Get the text
|
||||||
text = entry[1]
|
text = entry[1]
|
||||||
# Sanitize the text to prevent TelegramErrors
|
# Sanitize the text to prevent TelegramErrors
|
||||||
|
|
Loading…
Reference in a new issue