ADD: Quote info command

pull/3/head
Kamal Curi 2 years ago
parent 068411ce1e
commit 9ebb44a261

@ -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!

@ -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 <quote id>"
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:
"""

@ -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)

Loading…
Cancel
Save