diff --git a/royalnet/backpack/tables/matrix.py b/royalnet/backpack/tables/matrix.py index b1c11d61..34baeea5 100644 --- a/royalnet/backpack/tables/matrix.py +++ b/royalnet/backpack/tables/matrix.py @@ -23,7 +23,6 @@ class Matrix: @property def username(self): - # TODO: check this regex match = re.match("^@(.+):.+$", self.matrix_id) result = match.group(1) assert result is not None @@ -31,7 +30,6 @@ class Matrix: @property def homeserver(self): - # TODO: check this regex match = re.match("^@.+:(.+)$", self.matrix_id) result = match.group(1) assert result is not None diff --git a/royalnet/commands/commandinterface.py b/royalnet/commands/commandinterface.py index 175b440b..a0692d52 100644 --- a/royalnet/commands/commandinterface.py +++ b/royalnet/commands/commandinterface.py @@ -1,6 +1,6 @@ from typing import * import asyncio as aio -from .errors import UnsupportedError +from .errors import * if TYPE_CHECKING: from .event import Event from .command import Command @@ -34,20 +34,6 @@ class CommandInterface: Example: A reference to a :class:`~royalnet.constellation.Constellation`.""" - @property - def alchemy(self) -> "Alchemy": - """A shortcut for :attr:`.serf.alchemy`.""" - return self.serf.alchemy - - @property - def loop(self) -> aio.AbstractEventLoop: - """A shortcut for :attr:`.serf.loop`.""" - if self.serf: - return self.serf.loop - else: - # TODO - raise Exception("TODO") - def __init__(self, config: Dict[str, Any]): self.config: Dict[str, Any] = config """The config section for the pack of the command.""" @@ -56,6 +42,28 @@ class CommandInterface: self.command: Optional[Command] = None self.event: Optional[Event] = None + @property + def alchemy(self) -> "Alchemy": + """A shortcut for :attr:`.serf.alchemy`.""" + return self.serf.alchemy + + @property + def table(self) -> "Callable": + """A shortcut for :func:`.serf.alchemy.get`. + + Raises: + UnsupportedError: if :attr:`.alchemy` is :const:`None`.""" + if self.alchemy is None: + raise UnsupportedError("'alchemy' is not enabled on this Royalnet instance") + return self.alchemy.get + + @property + def loop(self) -> aio.AbstractEventLoop: + """A shortcut for :attr:`.serf.loop`.""" + if self.serf: + return self.serf.loop + raise UnsupportedError("This command is not being run in a serf.") + async def call_herald_event(self, destination: str, event_name: str, **kwargs) -> dict: """Call an event function on a different :class:`~royalnet.serf.Serf`. diff --git a/royalnet/constellation/constellation.py b/royalnet/constellation/constellation.py index 7d6f89af..1c46342d 100644 --- a/royalnet/constellation/constellation.py +++ b/royalnet/constellation/constellation.py @@ -316,8 +316,6 @@ class Constellation: log.info(f"Running Constellation on https://{self.address}:{self.port}/...") loop: aio.AbstractEventLoop = aio.get_event_loop() self.running = True - # TODO: figure out how to run the correct event loop - # loop.create_task(self.herald.run()) try: uvicorn.run(self.starlette, host=self.address, port=self.port, log_config=UVICORN_LOGGING_CONFIG) finally: diff --git a/royalnet/herald/package.py b/royalnet/herald/package.py index 77ca97a2..0034051e 100644 --- a/royalnet/herald/package.py +++ b/royalnet/herald/package.py @@ -26,7 +26,6 @@ class Package: source_conv_id: The conversation id of the node that created this package. Akin to the sequence number on IP packets. destination_conv_id: The conversation id of the node that this Package is a reply to.""" - # TODO: something is not right in these type hints. Check them. self.data: dict = data self.source: str = source self.source_conv_id: str = source_conv_id or str(uuid.uuid4()) diff --git a/royalnet/herald/server.py b/royalnet/herald/server.py index 6c672a2f..58d64487 100644 --- a/royalnet/herald/server.py +++ b/royalnet/herald/server.py @@ -102,7 +102,7 @@ class Server: log.debug(f"Received package: {package}") # Check if the package destination is the server itself. if package.destination == "": - # TODO: do stuff + # Do... nothing for now? pass # Otherwise, route the package to its destination # noinspection PyAsyncCall diff --git a/royalnet/serf/discord/voiceplayer.py b/royalnet/serf/discord/voiceplayer.py index 6d424ca8..e850a227 100644 --- a/royalnet/serf/discord/voiceplayer.py +++ b/royalnet/serf/discord/voiceplayer.py @@ -20,7 +20,6 @@ class VoicePlayer: self.loop: asyncio.AbstractEventLoop = asyncio.get_event_loop() else: self.loop = loop - # FIXME: this looks like spaghetti self._playback_ended_event: threading.Event = threading.Event() async def connect(self, channel: "discord.VoiceChannel") -> "discord.VoiceClient":