1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-24 03:54:20 +00:00
royalnet/royalpack/commands/diarioquote.py

27 lines
841 B
Python
Raw Normal View History

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