mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Aggiungi nuovi comandi
This commit is contained in:
parent
2378cbb662
commit
d05c2cd988
6 changed files with 80 additions and 5 deletions
|
@ -54,6 +54,8 @@ from .matchmaking import MatchmakingCommand
|
|||
from .cvstats import CvstatsCommand
|
||||
from .elevatormusic import ElevatormusicCommand
|
||||
from .royalpack import RoyalpackCommand
|
||||
from .givefiorygi import GivefiorygiCommand
|
||||
from .help import HelpCommand
|
||||
|
||||
# Enter the commands of your Pack here!
|
||||
available_commands = [
|
||||
|
@ -112,6 +114,8 @@ available_commands = [
|
|||
CvstatsCommand,
|
||||
ElevatormusicCommand,
|
||||
RoyalpackCommand,
|
||||
GivefiorygiCommand,
|
||||
HelpCommand,
|
||||
]
|
||||
|
||||
# Don't change this, it should automatically generate __all__
|
||||
|
|
|
@ -6,7 +6,7 @@ from royalnet.commands import *
|
|||
class CiaoruoziCommand(Command):
|
||||
name: str = "ciaoruozi"
|
||||
|
||||
description: str = "Saluta Ruozi, un leggendario essere che una volta era in User Games."
|
||||
description: str = "Saluta Ruozi, un leggendario essere che è tornato in Royal Games."
|
||||
|
||||
async def run(self, args: CommandArgs, data: CommandData) -> None:
|
||||
if self.interface.name == "telegram":
|
||||
|
|
44
royalpack/commands/givefiorygi.py
Normal file
44
royalpack/commands/givefiorygi.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
from typing import *
|
||||
import royalnet.commands as rc
|
||||
import royalnet.backpack.tables as rbt
|
||||
|
||||
from ..tables import FiorygiTransaction
|
||||
|
||||
|
||||
class GivefiorygiCommand(rc.Command):
|
||||
name: str = "givefiorygi"
|
||||
|
||||
description: str = "Cedi fiorygi a un altro utente."
|
||||
|
||||
syntax: str = "{destinatario} {quantità} {motivo}"
|
||||
|
||||
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
|
||||
author = await data.get_author(error_if_none=True)
|
||||
|
||||
user_arg = args[0]
|
||||
qty_arg = args[1]
|
||||
reason_arg = " ".join(args[2:])
|
||||
|
||||
if user_arg is None:
|
||||
raise rc.InvalidInputError("Non hai specificato un destinatario!")
|
||||
user = await rbt.User.find(self.alchemy, data.session, user_arg)
|
||||
if user is None:
|
||||
raise rc.InvalidInputError("L'utente specificato non esiste!")
|
||||
|
||||
if qty_arg is None:
|
||||
raise rc.InvalidInputError("Non hai specificato una quantità!")
|
||||
try:
|
||||
qty = int(qty_arg)
|
||||
except ValueError:
|
||||
raise rc.InvalidInputError("La quantità specificata non è un numero!")
|
||||
if qty <= 0:
|
||||
raise rc.InvalidInputError("La quantità specificata deve essere almeno 1!")
|
||||
|
||||
if reason_arg == "":
|
||||
raise rc.InvalidInputError("Non hai specificato un motivo!")
|
||||
|
||||
if author.fiorygi.fiorygi < qty:
|
||||
raise rc.InvalidInputError("Non hai abbastanza fiorygi per effettuare la transazione!")
|
||||
|
||||
await FiorygiTransaction.spawn_fiorygi(data, author, -qty, reason_arg)
|
||||
await FiorygiTransaction.spawn_fiorygi(data, user, qty, reason_arg)
|
27
royalpack/commands/help.py
Normal file
27
royalpack/commands/help.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from typing import *
|
||||
import royalnet
|
||||
import royalnet.commands as rc
|
||||
|
||||
|
||||
class HelpCommand(rc.Command):
|
||||
name: str = "help"
|
||||
|
||||
description: str = "Visualizza informazioni su un comando."
|
||||
|
||||
syntax: str = "{comando}"
|
||||
|
||||
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
|
||||
name: str = args[0].lstrip(self.interface.prefix)
|
||||
|
||||
try:
|
||||
command: rc.Command = self.serf.commands[f"{self.interface.prefix}{name}"]
|
||||
except KeyError:
|
||||
raise rc.InvalidInputError("Il comando richiesto non esiste.")
|
||||
|
||||
message = [
|
||||
f"[c]{self.interface.prefix}{command.name} {command.syntax}[/c]",
|
||||
"",
|
||||
f"{command.description}"
|
||||
]
|
||||
|
||||
await data.reply("\n".join(message))
|
|
@ -14,7 +14,7 @@ class MagickfiorygiCommand(rc.Command):
|
|||
|
||||
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
|
||||
author = await data.get_author(error_if_none=True)
|
||||
if author.role != "Admin":
|
||||
if "banker" not in author.roles:
|
||||
raise rc.UserError("Non hai permessi sufficienti per eseguire questo comando.")
|
||||
|
||||
user_arg = args[0]
|
||||
|
@ -23,7 +23,7 @@ class MagickfiorygiCommand(rc.Command):
|
|||
|
||||
if user_arg is None:
|
||||
raise rc.InvalidInputError("Non hai specificato un destinatario!")
|
||||
user = await rbt.Alias.find_user(self.alchemy, data.session, user_arg)
|
||||
user = await rbt.User.find(self.alchemy, data.session, user_arg)
|
||||
if user is None:
|
||||
raise rc.InvalidInputError("L'utente specificato non esiste!")
|
||||
|
||||
|
|
|
@ -110,10 +110,10 @@ class MatchmakingCommand(rc.Command):
|
|||
if response.choice == MMChoice.LATE_SHORT:
|
||||
td = mmevent.datetime + datetime.timedelta(minutes=10)
|
||||
time_text = f" [{td.strftime('%H:%M')}]"
|
||||
elif response.choice == MMChoice.LATE_SHORT:
|
||||
elif response.choice == MMChoice.LATE_MEDIUM:
|
||||
td = mmevent.datetime + datetime.timedelta(minutes=30)
|
||||
time_text = f" [{td.strftime('%H:%M')}]"
|
||||
elif response.choice == MMChoice.LATE_SHORT:
|
||||
elif response.choice == MMChoice.LATE_LONG:
|
||||
td = mmevent.datetime + datetime.timedelta(minutes=60)
|
||||
time_text = f" [{td.strftime('%H:%M')}+]"
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue