mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 11:34:18 +00:00
Fix a few bugs encountered while developing royalpack
This commit is contained in:
parent
c4bc181182
commit
fe73d3d897
6 changed files with 19 additions and 17 deletions
|
@ -9,7 +9,7 @@
|
|||
<excludeFolder url="file://$MODULE_DIR$/docs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/royalnet.egg-info" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.8" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="TestRunnerService">
|
||||
|
|
|
@ -3,12 +3,8 @@ from .exception import ExceptionEvent
|
|||
|
||||
# Enter the commands of your Pack here!
|
||||
available_events = [
|
||||
|
||||
ExceptionEvent,
|
||||
]
|
||||
|
||||
# noinspection PyUnreachableCode
|
||||
if __debug__:
|
||||
available_events.append(ExceptionEvent)
|
||||
|
||||
# Don't change this, it should automatically generate __all__
|
||||
__all__ = [command.__name__ for command in available_events]
|
||||
|
|
|
@ -34,7 +34,6 @@ class CommandInterface:
|
|||
Example:
|
||||
A reference to a :class:`~royalnet.constellation.Constellation`."""
|
||||
|
||||
|
||||
@property
|
||||
def alchemy(self) -> "Alchemy":
|
||||
"""A shortcut for :attr:`.serf.alchemy`."""
|
||||
|
@ -43,7 +42,11 @@ class CommandInterface:
|
|||
@property
|
||||
def loop(self) -> AbstractEventLoop:
|
||||
"""A shortcut for :attr:`.serf.loop`."""
|
||||
return self.serf.loop
|
||||
if self.serf:
|
||||
return self.serf.loop
|
||||
else:
|
||||
# TODO
|
||||
raise Exception("TODO")
|
||||
|
||||
def __init__(self, cfg: Dict[str, Any]):
|
||||
self.cfg: Dict[str, Any] = cfg
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import asyncio
|
||||
import asyncio as aio
|
||||
import logging
|
||||
import warnings
|
||||
from typing import *
|
||||
|
@ -36,6 +36,7 @@ class DiscordSerf(Serf):
|
|||
_identity_column = "discord_id"
|
||||
|
||||
def __init__(self,
|
||||
loop: aio.AbstractEventLoop,
|
||||
alchemy_cfg: Dict[str, Any],
|
||||
herald_cfg: Dict[str, Any],
|
||||
sentry_cfg: Dict[str, Any],
|
||||
|
@ -45,7 +46,8 @@ class DiscordSerf(Serf):
|
|||
if discord is None:
|
||||
raise ImportError("'discord' extra is not installed")
|
||||
|
||||
super().__init__(alchemy_cfg=alchemy_cfg,
|
||||
super().__init__(loop=loop,
|
||||
alchemy_cfg=alchemy_cfg,
|
||||
herald_cfg=herald_cfg,
|
||||
sentry_cfg=sentry_cfg,
|
||||
packs_cfg=packs_cfg,
|
||||
|
@ -80,7 +82,7 @@ class DiscordSerf(Serf):
|
|||
def __init__(data,
|
||||
interface: CommandInterface,
|
||||
session,
|
||||
loop: asyncio.AbstractEventLoop,
|
||||
loop: aio.AbstractEventLoop,
|
||||
message: "discord.Message"):
|
||||
super().__init__(interface=interface, session=session, loop=loop)
|
||||
data.message = message
|
||||
|
|
|
@ -40,10 +40,13 @@ class Serf:
|
|||
_identity_column: str = NotImplemented
|
||||
|
||||
def __init__(self,
|
||||
loop: aio.AbstractEventLoop,
|
||||
alchemy_cfg: Dict[str, Any],
|
||||
herald_cfg: Dict[str, Any],
|
||||
packs_cfg: Dict[str, Any],
|
||||
**_):
|
||||
self.loop: Optional[aio.AbstractEventLoop] = loop
|
||||
"""The event loop this Serf is running on."""
|
||||
|
||||
# Import packs
|
||||
pack_names = packs_cfg["active"]
|
||||
|
@ -131,9 +134,6 @@ class Serf:
|
|||
self.init_herald(herald_cfg)
|
||||
log.info(f"Herald: enabled")
|
||||
|
||||
self.loop: Optional[aio.AbstractEventLoop] = None
|
||||
"""The event loop this Serf is running on."""
|
||||
|
||||
def init_alchemy(self, alchemy_cfg: Dict[str, Any], tables: Set[type]) -> None:
|
||||
"""Create and initialize the :class:`Alchemy` with the required tables, and find the link between the master
|
||||
table and the identity table."""
|
||||
|
@ -320,9 +320,8 @@ class Serf:
|
|||
except ImportError:
|
||||
log.info("Sentry: not installed")
|
||||
|
||||
serf = cls(**kwargs)
|
||||
serf = cls(loop=aio.get_event_loop(), **kwargs)
|
||||
|
||||
serf.loop = aio.get_event_loop()
|
||||
try:
|
||||
serf.loop.run_until_complete(serf.run())
|
||||
except Exception as e:
|
||||
|
|
|
@ -32,6 +32,7 @@ class TelegramSerf(Serf):
|
|||
_identity_column = "tg_id"
|
||||
|
||||
def __init__(self,
|
||||
loop: aio.AbstractEventLoop,
|
||||
alchemy_cfg: Dict[str, Any],
|
||||
herald_cfg: Dict[str, Any],
|
||||
sentry_cfg: Dict[str, Any],
|
||||
|
@ -41,7 +42,8 @@ class TelegramSerf(Serf):
|
|||
if telegram is None:
|
||||
raise ImportError("'telegram' extra is not installed")
|
||||
|
||||
super().__init__(alchemy_cfg=alchemy_cfg,
|
||||
super().__init__(loop=loop,
|
||||
alchemy_cfg=alchemy_cfg,
|
||||
herald_cfg=herald_cfg,
|
||||
sentry_cfg=sentry_cfg,
|
||||
packs_cfg=packs_cfg,
|
||||
|
|
Loading…
Reference in a new issue