diff --git a/motd b/motd index d0b9e0e..9ba7fce 100644 --- a/motd +++ b/motd @@ -5,7 +5,7 @@ █ ▄ █ ▄▄▄█ ▄▄▄█ ▄ ██ █▄▄▄█ ▄▄▄█ █ █ █ █ █▄▄▄█ █▄▄▄█ █▄█ █ █ █▄▄▄ █▄█ █▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█ -Neeble version: 2023.04.03 +Neeble version: 2023.04.04 Bot source can be found by users with -the "Neeble Dev" role. +the @Neeble Dev role. Thank you! diff --git a/utils/commands.py b/utils/commands.py index b9592cd..d9a7886 100644 --- a/utils/commands.py +++ b/utils/commands.py @@ -5,6 +5,7 @@ import logging import os import json +from datetime import datetime from random import choice @@ -44,7 +45,8 @@ async def quote(bot: object, *quote: str) -> str: try: user = bot.author.name - qtid = set_quote(user, quote) + date = datetime.now().replace(microsecond=0) + qtid = set_quote(user, quote, date) except Exception as ex: if ex.args[0].find("Duplicate") != -1: return await bot.send("There's already a quote from that same person, with that "\ @@ -116,6 +118,28 @@ async def by_id(bot: object, _id: int=None) -> str: return await bot.send(ex) +@client.command(aliases=['qinfo']) +async def quote_info(bot: object, _id: int=None) -> str: + """ + Prints out information about a quote + """ + syntax = "--qinfo " + + if not _id: + return await bot.send("_If you don't tell me the ID, how the fuck do you expect me to "\ + f"get its info for you!?_\n(The correct syntax is {syntax})") + + quote = get_by_id(_id) + + if not quote: + return await bot.send(f"_Wrong ID, sucker!_\n(There's no such quote with id {_id})") + + user = quote.user + date = quote.date if quote.date else "Before datetimes were stored" + data = f"```\n ID: {_id}\n Quoted by: {user}\n Quoted datetime: {date}\n```" + return await bot.send(data) + + @client.command(aliases=['dq']) async def delete_quote(bot, _id: int=None) -> str: """ diff --git a/utils/database.py b/utils/database.py index ebb1a24..9a9fc1a 100644 --- a/utils/database.py +++ b/utils/database.py @@ -49,6 +49,7 @@ def migrate() -> None: id int auto_increment primary key, user varchar(200) not null, quote varchar(500) not null unique, + date datetime not null, index quote_idx (quote) ) character set utf8mb4 collate utf8mb4_general_ci; @@ -67,11 +68,11 @@ def migrate() -> None: logger.error(ex.args) -def set_quote(user: str, quote: str) -> int: +def set_quote(user: str, quote: str, date: str) -> int: """ Set a quote into database. """ - qt = Quotes(quote=quote, user=user,) + qt = Quotes(quote=quote, user=user, date=date) qtid = 0 with Session(SQLACHEMY) as session: session.add(qt)