diff --git a/royalnet/__main__.py b/royalnet/__main__.py index d4122bc5..cc479f19 100644 --- a/royalnet/__main__.py +++ b/royalnet/__main__.py @@ -27,7 +27,7 @@ import keyring def run(telegram: typing.Optional[bool], discord: typing.Optional[bool], database: typing.Optional[str], - packs: typing.List[str], + packs: typing.Tuple[str], network_address: typing.Optional[str], local_network_server: bool, secrets_name: str, @@ -88,12 +88,13 @@ def run(telegram: typing.Optional[bool], "discord_id") # Import command packs + packs: typing.List[str] = list(packs) packs.append("royalnet.packs.common") # common pack is always imported enabled_commands = [] for pack in packs: imported = importlib.import_module(pack) try: - imported_commands = imported.commands + imported_commands = imported.available_commands except AttributeError: raise click.ClickException(f"{pack} isn't a Royalnet Pack.") enabled_commands = [*enabled_commands, *imported_commands] diff --git a/royalnet/bots/generic.py b/royalnet/bots/generic.py index c225fbc0..91bd3c0c 100644 --- a/royalnet/bots/generic.py +++ b/royalnet/bots/generic.py @@ -9,7 +9,7 @@ from sentry_sdk.integrations.aiohttp import AioHttpIntegration from sentry_sdk.integrations.logging import LoggingIntegration from ..utils import * from ..database import * -from ..packs import * +from ..commands import * from ..error import * @@ -132,7 +132,7 @@ class GenericBot: log.info(f"Database: enabled") required_tables = {self.uninitialized_database_config.master_table, self.uninitialized_database_config.identity_table} for command in self.uninitialized_commands: - required_tables = required_tables.union(command.require_alchemy_tables) + required_tables = required_tables.union(command.tables) log.debug(f"Required tables: {', '.join([item.__qualname__ for item in required_tables])}") self.alchemy = Alchemy(self.uninitialized_database_config.database_uri, required_tables) self.master_table = self.alchemy.__getattribute__(self.uninitialized_database_config.master_table.__name__) diff --git a/royalnet/bots/telegram.py b/royalnet/bots/telegram.py index 4ada1da0..1e918341 100644 --- a/royalnet/bots/telegram.py +++ b/royalnet/bots/telegram.py @@ -9,7 +9,7 @@ import warnings from .generic import GenericBot from ..utils import * from ..error import * -from ..packs import * +from ..commands import * log = _logging.getLogger(__name__) diff --git a/royalnet/packs/common/__init__.py b/royalnet/packs/common/__init__.py index b3b78faa..4b96ad2c 100644 --- a/royalnet/packs/common/__init__.py +++ b/royalnet/packs/common/__init__.py @@ -1,6 +1,7 @@ # This is a template Pack __init__. You can use this without changing anything in other packages too! -from .commands import commands -from .tables import tables +from . import commands, tables +from .commands import available_commands +from .tables import available_tables -__all__ = ["commands", "tables"] +__all__ = ["commands", "tables", "available_commands", "available_tables"] diff --git a/royalnet/packs/common/commands/__init__.py b/royalnet/packs/common/commands/__init__.py index f828294e..89c4f4a1 100644 --- a/royalnet/packs/common/commands/__init__.py +++ b/royalnet/packs/common/commands/__init__.py @@ -2,9 +2,9 @@ from .ping import PingCommand # Enter the commands of your Pack here! -commands = [ +available_commands = [ PingCommand, ] # Don't change this, it should automatically generate __all__ -__all__ = [command.__class__.__qualname__ for command in commands] +__all__ = [command.__class__.__qualname__ for command in available_commands] diff --git a/royalnet/packs/common/tables/__init__.py b/royalnet/packs/common/tables/__init__.py index 94d6275d..bde51ac0 100644 --- a/royalnet/packs/common/tables/__init__.py +++ b/royalnet/packs/common/tables/__init__.py @@ -4,11 +4,11 @@ from .telegram import Telegram from .discord import Discord # Enter the tables of your Pack here! -tables = [ +available_tables = [ User, Telegram, Discord ] # Don't change this, it should automatically generate __all__ -__all__ = [table.__class__.__qualname__ for table in tables] +__all__ = [table.__class__.__qualname__ for table in available_tables] diff --git a/royalnet/packs/empty/__init__.py b/royalnet/packs/empty/__init__.py index 9631915d..4d839b28 100644 --- a/royalnet/packs/empty/__init__.py +++ b/royalnet/packs/empty/__init__.py @@ -1,7 +1,7 @@ # This is a template Pack __init__. You can use this without changing anything in other packages too! -from .commands import commands -from .tables import tables +from .commands import available_commands +from .tables import available_tables -__all__ = ["commands", "tables"] +__all__ = ["commands", "tables", "available_commands", "available_tables"] diff --git a/royalnet/packs/empty/commands/__init__.py b/royalnet/packs/empty/commands/__init__.py index 59ca6074..3e6d10ca 100644 --- a/royalnet/packs/empty/commands/__init__.py +++ b/royalnet/packs/empty/commands/__init__.py @@ -2,9 +2,9 @@ # Enter the commands of your Pack here! -commands = [ +available_commands = [ ] # Don't change this, it should automatically generate __all__ -__all__ = [command.__class__.__qualname__ for command in commands] +__all__ = [command.__class__.__qualname__ for command in available_commands] diff --git a/royalnet/packs/empty/tables/__init__.py b/royalnet/packs/empty/tables/__init__.py index 195418cd..23bc7c24 100644 --- a/royalnet/packs/empty/tables/__init__.py +++ b/royalnet/packs/empty/tables/__init__.py @@ -2,9 +2,9 @@ # Enter the tables of your Pack here! -tables = [ +available_tables = [ ] # Don't change this, it should automatically generate __all__ -__all__ = [table.__class__.__qualname__ for table in tables] +__all__ = [table.__class__.__qualname__ for table in available_tables] diff --git a/royalnet/packs/royal/__init__.py b/royalnet/packs/royal/__init__.py index b3b78faa..8cb183d1 100644 --- a/royalnet/packs/royal/__init__.py +++ b/royalnet/packs/royal/__init__.py @@ -1,6 +1,6 @@ # This is a template Pack __init__. You can use this without changing anything in other packages too! -from .commands import commands -from .tables import tables +from .commands import available_commands +from .tables import available_tables -__all__ = ["commands", "tables"] +__all__ = ["commands", "tables", "available_commands", "available_tables"] diff --git a/royalnet/packs/royal/commands/__init__.py b/royalnet/packs/royal/commands/__init__.py index d36d6e80..33d908ab 100644 --- a/royalnet/packs/royal/commands/__init__.py +++ b/royalnet/packs/royal/commands/__init__.py @@ -23,7 +23,7 @@ from .soundcloud import SoundcloudCommand from .zawarudo import ZawarudoCommand # Enter the commands of your Pack here! -commands = [ +available_commands = [ CiaoruoziCommand, ColorCommand, CvCommand, @@ -49,4 +49,4 @@ commands = [ ] # Don't change this, it should automatically generate __all__ -__all__ = [command.__class__.__qualname__ for command in commands] +__all__ = [command.__class__.__qualname__ for command in available_commands] diff --git a/royalnet/packs/royal/commands/queue.py b/royalnet/packs/royal/commands/queue.py index a14c3662..a501b3f1 100644 --- a/royalnet/packs/royal/commands/queue.py +++ b/royalnet/packs/royal/commands/queue.py @@ -2,11 +2,9 @@ import typing import pickle import discord from royalnet.commands import * -from ...utils import NetworkHandler, numberemojiformat -from ...network import Request, ResponseSuccess -from ..commanderrors import CommandError -if typing.TYPE_CHECKING: - from ...bots import DiscordBot +from royalnet.utils import NetworkHandler, numberemojiformat +from royalnet.bots import DiscordBot +from royalherald import Request, ResponseSuccess class QueueNH(NetworkHandler): diff --git a/royalnet/packs/royal/commands/reminder.py b/royalnet/packs/royal/commands/reminder.py index 9b938efe..10991c6d 100644 --- a/royalnet/packs/royal/commands/reminder.py +++ b/royalnet/packs/royal/commands/reminder.py @@ -6,9 +6,9 @@ import telegram import discord from sqlalchemy import and_ from royalnet.commands import * -from ...utils import sleep_until, asyncify, telegram_escape, discord_escape -from ...database.tables import Reminder -from ..commanderrors import InvalidInputError, UnsupportedError +from royalnet.utils import sleep_until, asyncify, telegram_escape, discord_escape +from ..tables import Reminder + class ReminderCommand(Command): name: str = "reminder" diff --git a/royalnet/packs/royal/commands/ship.py b/royalnet/packs/royal/commands/ship.py index a10d22dd..98d38047 100644 --- a/royalnet/packs/royal/commands/ship.py +++ b/royalnet/packs/royal/commands/ship.py @@ -1,7 +1,7 @@ import typing import re from royalnet.commands import * -from ...utils import safeformat +from royalnet.utils import safeformat class ShipCommand(Command): diff --git a/royalnet/packs/royal/commands/skip.py b/royalnet/packs/royal/commands/skip.py index d5455d2d..008b3275 100644 --- a/royalnet/packs/royal/commands/skip.py +++ b/royalnet/packs/royal/commands/skip.py @@ -1,13 +1,9 @@ import typing -import pickle import discord from royalnet.commands import * -from ...utils import NetworkHandler, asyncify -from ...network import Request, ResponseSuccess -from ..commanderrors import CommandError -from ...audio import YtdlDiscord -if typing.TYPE_CHECKING: - from ...bots import DiscordBot +from royalnet.utils import NetworkHandler +from royalnet.bots import DiscordBot +from royalherald import Request, ResponseSuccess class SkipNH(NetworkHandler): diff --git a/royalnet/packs/royal/commands/smecds.py b/royalnet/packs/royal/commands/smecds.py index 2e6f15bc..9f4d6568 100644 --- a/royalnet/packs/royal/commands/smecds.py +++ b/royalnet/packs/royal/commands/smecds.py @@ -1,7 +1,7 @@ import typing import random from royalnet.commands import * -from ...utils import safeformat +from royalnet.utils import safeformat class SmecdsCommand(Command): diff --git a/royalnet/packs/royal/commands/soundcloud.py b/royalnet/packs/royal/commands/soundcloud.py index 7091acc4..acc24ae1 100644 --- a/royalnet/packs/royal/commands/soundcloud.py +++ b/royalnet/packs/royal/commands/soundcloud.py @@ -3,12 +3,10 @@ import pickle import datetime import discord from royalnet.commands import * -from ...utils import NetworkHandler, asyncify -from ...network import Request, ResponseSuccess -from ...audio import YtdlDiscord - -if typing.TYPE_CHECKING: - from ...bots import DiscordBot +from royalnet.utils import NetworkHandler, asyncify +from royalnet.audio import YtdlDiscord +from royalnet.bots import DiscordBot +from royalherald import Request, ResponseSuccess class SoundcloudNH(NetworkHandler): diff --git a/royalnet/packs/royal/commands/summon.py b/royalnet/packs/royal/commands/summon.py index 52ea18fc..3a2d632f 100644 --- a/royalnet/packs/royal/commands/summon.py +++ b/royalnet/packs/royal/commands/summon.py @@ -1,11 +1,9 @@ import typing import discord from royalnet.commands import * -from ...utils import NetworkHandler -from ...network import Request, ResponseSuccess -from ..commanderrors import CommandError -if typing.TYPE_CHECKING: - from ...bots import DiscordBot +from royalnet.utils import NetworkHandler +from royalnet.bots import DiscordBot +from royalherald import Request, ResponseSuccess class SummonNH(NetworkHandler): diff --git a/royalnet/packs/royal/commands/trivia.py b/royalnet/packs/royal/commands/trivia.py index 26d18636..a3d4c54f 100644 --- a/royalnet/packs/royal/commands/trivia.py +++ b/royalnet/packs/royal/commands/trivia.py @@ -5,9 +5,8 @@ import random import uuid import html from royalnet.commands import * -from ...utils import asyncify -from ..commanderrors import CommandError, KeyboardExpiredError -from ...database.tables import TriviaScore +from royalnet.utils import asyncify +from ..tables import TriviaScore class TriviaCommand(Command): diff --git a/royalnet/packs/royal/commands/youtube.py b/royalnet/packs/royal/commands/youtube.py index 9cd9f480..98861024 100644 --- a/royalnet/packs/royal/commands/youtube.py +++ b/royalnet/packs/royal/commands/youtube.py @@ -3,11 +3,10 @@ import pickle import datetime import discord from royalnet.commands import * -from ...utils import NetworkHandler, asyncify -from ...network import Request, ResponseSuccess -from ...audio import YtdlDiscord -if typing.TYPE_CHECKING: - from ...bots import DiscordBot +from royalnet.utils import NetworkHandler, asyncify +from royalnet.audio import YtdlDiscord +from royalnet.bots import DiscordBot +from royalherald import Request, ResponseSuccess class YoutubeNH(NetworkHandler): diff --git a/royalnet/packs/royal/commands/zawarudo.py b/royalnet/packs/royal/commands/zawarudo.py index e42d68ed..65aa8df2 100644 --- a/royalnet/packs/royal/commands/zawarudo.py +++ b/royalnet/packs/royal/commands/zawarudo.py @@ -3,12 +3,11 @@ import discord import asyncio import datetime from royalnet.commands import * -from ...utils import NetworkHandler, asyncify -from ...network import Request, ResponseSuccess -from ...audio import YtdlDiscord -from ...audio.playmodes import Playlist -if typing.TYPE_CHECKING: - from ...bots import DiscordBot +from royalnet.utils import NetworkHandler, asyncify +from royalnet.audio import YtdlDiscord +from royalnet.audio.playmodes import Playlist +from royalnet.bots import DiscordBot +from royalherald import Request, ResponseSuccess class ZawarudoNH(NetworkHandler): diff --git a/royalnet/packs/royal/tables/__init__.py b/royalnet/packs/royal/tables/__init__.py index c95ec139..f20c16fe 100644 --- a/royalnet/packs/royal/tables/__init__.py +++ b/royalnet/packs/royal/tables/__init__.py @@ -18,7 +18,7 @@ from .mmevents import MMEvent from .mmresponse import MMResponse # Enter the tables of your Pack here! -tables = [ +available_tables = [ User, Telegram, Discord, @@ -38,4 +38,4 @@ tables = [ ] # Don't change this, it should automatically generate __all__ -__all__ = [table.__class__.__qualname__ for table in tables] +__all__ = [table.__class__.__qualname__ for table in available_tables]