1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Remove some fixed todos

This commit is contained in:
Steffo 2020-01-31 16:56:38 +01:00
parent d8d338183c
commit de21892174
6 changed files with 24 additions and 22 deletions

View file

@ -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

View file

@ -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`.

View file

@ -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:

View file

@ -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())

View file

@ -102,7 +102,7 @@ class Server:
log.debug(f"Received package: {package}")
# Check if the package destination is the server itself.
if package.destination == "<server>":
# TODO: do stuff
# Do... nothing for now?
pass
# Otherwise, route the package to its destination
# noinspection PyAsyncCall

View file

@ -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":