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