feat: Add timestamp for reminder list
All checks were successful
Build Docker / Build Docker (push) Successful in 18s

This commit is contained in:
Nathan Woodburn 2023-11-14 14:18:01 +11:00
parent 85ef94176c
commit 80460d2203
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
2 changed files with 6 additions and 12 deletions

1
bot.py
View File

@ -487,6 +487,7 @@ async def reminders(ctx):
message = "Reminders:\n" message = "Reminders:\n"
for reminder in user_reminders: for reminder in user_reminders:
time = datetime.datetime.strptime(reminder['time'], "%Y-%m-%d %H:%M:%S") time = datetime.datetime.strptime(reminder['time'], "%Y-%m-%d %H:%M:%S")
time = tools.timestamp_relative(time)
message += f"{time}: {reminder['text']}\n" message += f"{time}: {reminder['text']}\n"
await ctx.response.send_message(message,ephemeral=True) await ctx.response.send_message(message,ephemeral=True)

View File

@ -64,18 +64,11 @@ def embed(title, description):
embed.set_footer(text='Powered by Nathan.Woodburn/') embed.set_footer(text='Powered by Nathan.Woodburn/')
return embed return embed
def timestamp_relative(date_time):
return "<t:"+str(int(date_time.timestamp()))+":R>"
if __name__ == '__main__': if __name__ == '__main__':
print(parse_time('1d 2h 3m 4s'))
print(parse_time('1d2h3m4s'))
print(parse_time('1d 2h 3m'))
print(parse_time('1d 2h'))
print(parse_time('1d')) print(parse_time('1d'))
print(parse_time('1h 2m 3s')) print(timestamp_relative(datetime.datetime.now()+parse_time('1d')))
print(parse_time('1h 2m')) print(parse_time('1s'))
print(parse_time('1h')) print(timestamp_relative(datetime.datetime.now()+parse_time('1s')))
print(parse_time('1m 2s'))
print(parse_time('1m'))
print(read_reminders())
store_reminder(123, datetime.datetime.now(), 'test')
print(read_reminders())