mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Commands, commands, commands!
This commit is contained in:
parent
f1803f2ffd
commit
97dd36827e
4 changed files with 28 additions and 2 deletions
13
pycharm_templates/command.vm
Normal file
13
pycharm_templates/command.vm
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import royalnet
|
||||||
|
from royalnet.commands import *
|
||||||
|
|
||||||
|
#set($CAPITALIZED_NAME = $NAME.substring(0,1).toUpperCase() + $NAME.substring(1))
|
||||||
|
class ${CAPITALIZED_NAME}Command(Command):
|
||||||
|
name: str = "$NAME"
|
||||||
|
|
||||||
|
description: str = ""
|
||||||
|
|
||||||
|
syntax: str = ""
|
||||||
|
|
||||||
|
async def run(self, args: CommandArgs, data: CommandData) -> None:
|
||||||
|
...
|
10
pycharm_templates/event.vm
Normal file
10
pycharm_templates/event.vm
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from typing import *
|
||||||
|
from royalnet.commands import *
|
||||||
|
|
||||||
|
|
||||||
|
#set($CAPITALIZED_NAME = $NAME.substring(0,1).toUpperCase() + $NAME.substring(1))
|
||||||
|
class ${CAPITALIZED_NAME}Event(Event):
|
||||||
|
name = "$NAME"
|
||||||
|
|
||||||
|
async def run(self, **kwargs) -> dict:
|
||||||
|
...
|
|
@ -27,6 +27,9 @@ class Command:
|
||||||
def __init__(self, interface: CommandInterface):
|
def __init__(self, interface: CommandInterface):
|
||||||
self.interface = interface
|
self.interface = interface
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"[c]{self.interface.prefix}{self.name}[/c]"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def serf(self):
|
def serf(self):
|
||||||
"""A shortcut for :attr:`.interface.serf`."""
|
"""A shortcut for :attr:`.interface.serf`."""
|
||||||
|
|
|
@ -269,8 +269,8 @@ class Constellation:
|
||||||
log.info(f"Running Constellation on https://{self.address}:{self.port}/...")
|
log.info(f"Running Constellation on https://{self.address}:{self.port}/...")
|
||||||
loop: aio.AbstractEventLoop = aio.get_event_loop()
|
loop: aio.AbstractEventLoop = aio.get_event_loop()
|
||||||
self.running = True
|
self.running = True
|
||||||
# FIXME: might not work as expected
|
# TODO: figure out how to run the correct event loop
|
||||||
loop.create_task(self.herald.run())
|
# loop.create_task(self.herald.run())
|
||||||
try:
|
try:
|
||||||
uvicorn.run(self.starlette, host=self.address, port=self.port, log_config=UVICORN_LOGGING_CONFIG)
|
uvicorn.run(self.starlette, host=self.address, port=self.port, log_config=UVICORN_LOGGING_CONFIG)
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Reference in a new issue