mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
More commands done
This commit is contained in:
parent
491301b681
commit
f1803f2ffd
5 changed files with 16 additions and 6 deletions
|
@ -5,6 +5,6 @@ class ExceptionEvent(Event):
|
|||
name = "exception"
|
||||
|
||||
def run(self, **kwargs):
|
||||
if not self.interface.cfg["exc_debug"]:
|
||||
if not self.interface.config["exc_debug"]:
|
||||
raise UserError(f"{self.interface.prefix}{self.name} is not enabled.")
|
||||
raise Exception(f"{self.name} event was called")
|
||||
|
|
|
@ -27,6 +27,11 @@ class Command:
|
|||
def __init__(self, interface: CommandInterface):
|
||||
self.interface = interface
|
||||
|
||||
@property
|
||||
def serf(self):
|
||||
"""A shortcut for :attr:`.interface.serf`."""
|
||||
return self.interface.serf
|
||||
|
||||
@property
|
||||
def alchemy(self):
|
||||
"""A shortcut for :attr:`.interface.alchemy`."""
|
||||
|
@ -37,5 +42,10 @@ class Command:
|
|||
"""A shortcut for :attr:`.interface.loop`."""
|
||||
return self.interface.loop
|
||||
|
||||
@property
|
||||
def config(self):
|
||||
"""A shortcut for :attr:`.interface.config`."""
|
||||
return self.interface.config
|
||||
|
||||
async def run(self, args: CommandArgs, data: CommandData) -> None:
|
||||
raise NotImplementedError()
|
||||
|
|
|
@ -48,8 +48,8 @@ class CommandInterface:
|
|||
# TODO
|
||||
raise Exception("TODO")
|
||||
|
||||
def __init__(self, cfg: Dict[str, Any]):
|
||||
self.cfg: Dict[str, Any] = cfg
|
||||
def __init__(self, config: Dict[str, Any]):
|
||||
self.config: Dict[str, Any] = config
|
||||
"""The config section for the pack of the command."""
|
||||
|
||||
# Will be bound after the command/event has been created
|
||||
|
|
|
@ -225,7 +225,7 @@ class Constellation:
|
|||
def register_events(self, events: List[Type[rc.Event]], pack_cfg: Dict[str, Any]):
|
||||
for SelectedEvent in events:
|
||||
# Create a new interface
|
||||
interface = self.Interface(cfg=pack_cfg)
|
||||
interface = self.Interface(config=pack_cfg)
|
||||
# Initialize the event
|
||||
try:
|
||||
event = SelectedEvent(interface)
|
||||
|
|
|
@ -203,7 +203,7 @@ class Serf:
|
|||
# Instantiate the Commands
|
||||
for SelectedCommand in commands:
|
||||
# Create a new interface
|
||||
interface = self.Interface(cfg=pack_cfg)
|
||||
interface = self.Interface(config=pack_cfg)
|
||||
# Try to instantiate the command
|
||||
try:
|
||||
command = SelectedCommand(interface)
|
||||
|
@ -241,7 +241,7 @@ class Serf:
|
|||
def register_events(self, events: List[Type[Event]], pack_cfg: Dict[str, Any]):
|
||||
for SelectedEvent in events:
|
||||
# Create a new interface
|
||||
interface = self.Interface(cfg=pack_cfg)
|
||||
interface = self.Interface(config=pack_cfg)
|
||||
# Initialize the event
|
||||
try:
|
||||
event = SelectedEvent(interface)
|
||||
|
|
Loading…
Reference in a new issue