2019-11-11 08:56:08 +00:00
|
|
|
|
from royalnet.commands import *
|
|
|
|
|
from royalnet.utils import *
|
|
|
|
|
from ..tables import Diario
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DiarioquoteCommand(Command):
|
|
|
|
|
name: str = "diarioquote"
|
|
|
|
|
|
|
|
|
|
description: str = "Cita una riga del diario."
|
|
|
|
|
|
|
|
|
|
aliases = ["dq", "quote", "dquote"]
|
|
|
|
|
|
|
|
|
|
syntax = "{id}"
|
|
|
|
|
|
|
|
|
|
async def run(self, args: CommandArgs, data: CommandData) -> None:
|
|
|
|
|
try:
|
|
|
|
|
entry_id = int(args[0].lstrip("#"))
|
|
|
|
|
except ValueError:
|
|
|
|
|
raise CommandError("L'id che hai specificato non è valido.")
|
2019-11-28 01:30:40 +00:00
|
|
|
|
entry: Diario = await asyncify(data.session.query(self.alchemy.get(Diario)).get, entry_id)
|
2019-11-11 08:56:08 +00:00
|
|
|
|
if entry is None:
|
|
|
|
|
raise CommandError("Nessuna riga con quell'id trovata.")
|
2019-11-28 01:30:40 +00:00
|
|
|
|
await data.reply(f"ℹ️ {entry}")
|