From 4a07afe72b74cc1c04f97547b26aad1914ae02aa Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 17 Oct 2019 15:33:23 +0200 Subject: [PATCH] Change an enormous amount of stuff --- docs/html/_static/jquery-3.4.1.js | 2 +- docs_source/apireference.rst | 61 +------------------ royalnet/__init__.py | 3 +- royalnet/__main__.py | 30 +++++---- royalnet/audio/playmodes.py | 2 +- royalnet/bots/__init__.py | 2 +- royalnet/bots/discord.py | 2 +- royalnet/bots/generic.py | 12 ++-- royalnet/bots/telegram.py | 4 +- royalnet/commands/command.py | 2 +- royalnet/commands/commanddata.py | 2 + royalnet/commands/debug/__init__.py | 13 ---- royalnet/commands/debug/debug_error.py | 13 ---- royalnet/commands/debug/debug_invoking.py | 14 ----- royalnet/commands/debug/debug_keyboard.py | 18 ------ royalnet/commands/royalgames/ping.py | 13 ---- royalnet/commands/royalmusic/__init__.py | 30 --------- royalnet/database/__init__.py | 3 +- royalnet/database/tables/__init__.py | 22 ------- royalnet/database/tables/medalawards.py | 39 ------------ royalnet/database/tables/medals.py | 40 ------------ royalnet/packs/__init__.py | 7 +++ royalnet/packs/common/__init__.py | 6 ++ royalnet/packs/common/commands/__init__.py | 10 +++ royalnet/packs/common/commands/ping.py | 10 +++ royalnet/packs/common/tables/__init__.py | 14 +++++ .../common}/tables/discord.py | 0 .../common}/tables/telegram.py | 0 .../common}/tables/users.py | 2 +- royalnet/packs/empty/__init__.py | 7 +++ royalnet/packs/empty/commands/__init__.py | 10 +++ royalnet/packs/empty/tables/__init__.py | 10 +++ royalnet/packs/royal/__init__.py | 6 ++ .../royal/commands}/__init__.py | 32 +++++++--- .../royal/commands}/ciaoruozi.py | 6 +- .../royal/commands}/color.py | 5 +- .../royalgames => packs/royal/commands}/cv.py | 14 ++--- .../royal/commands}/diario.py | 11 ++-- .../royal/commands}/dnditem.py | 7 +-- .../royal/commands}/dndspell.py | 7 +-- .../royalgames => packs/royal/commands}/mm.py | 12 ++-- .../royal/commands}/mp3.py | 8 +-- .../royal/commands}/pause.py | 15 ++--- .../royal/commands}/play.py | 15 ++--- .../royal/commands}/playmode.py | 15 ++--- .../royal/commands}/queue.py | 5 +- .../royal/commands}/rage.py | 4 +- .../royal/commands}/reminder.py | 7 +-- .../royal/commands}/ship.py | 4 +- .../royal/commands}/skip.py | 5 +- .../royal/commands}/smecds.py | 4 +- .../royal/commands}/soundcloud.py | 6 +- .../royal/commands}/summon.py | 5 +- .../royal/commands}/trivia.py | 7 +-- .../royal/commands}/videochannel.py | 5 +- .../royal/commands}/youtube.py | 6 +- .../royal/commands}/zawarudo.py | 6 +- royalnet/packs/royal/tables/__init__.py | 41 +++++++++++++ .../royal}/tables/activekvgroups.py | 4 -- .../royal}/tables/aliases.py | 2 - .../{database => packs/royal}/tables/bios.py | 1 - .../royal}/tables/diario.py | 2 - .../royal}/tables/keygroups.py | 0 .../royal}/tables/keyvalues.py | 2 - .../royal}/tables/mmdecisions.py | 2 - .../royal}/tables/mmevents.py | 6 -- .../royal}/tables/mmresponse.py | 2 - .../royal}/tables/reminders.py | 2 - .../royal}/tables/triviascores.py | 1 - .../royal}/tables/wikipages.py | 0 .../royal}/tables/wikirevisions.py | 4 -- royalnet/web/templates/base.html | 4 +- 72 files changed, 232 insertions(+), 461 deletions(-) delete mode 100644 royalnet/commands/debug/__init__.py delete mode 100644 royalnet/commands/debug/debug_error.py delete mode 100644 royalnet/commands/debug/debug_invoking.py delete mode 100644 royalnet/commands/debug/debug_keyboard.py delete mode 100644 royalnet/commands/royalgames/ping.py delete mode 100644 royalnet/commands/royalmusic/__init__.py delete mode 100644 royalnet/database/tables/__init__.py delete mode 100644 royalnet/database/tables/medalawards.py delete mode 100644 royalnet/database/tables/medals.py create mode 100644 royalnet/packs/__init__.py create mode 100644 royalnet/packs/common/__init__.py create mode 100644 royalnet/packs/common/commands/__init__.py create mode 100644 royalnet/packs/common/commands/ping.py create mode 100644 royalnet/packs/common/tables/__init__.py rename royalnet/{database => packs/common}/tables/discord.py (100%) rename royalnet/{database => packs/common}/tables/telegram.py (100%) rename royalnet/{database => packs/common}/tables/users.py (91%) create mode 100644 royalnet/packs/empty/__init__.py create mode 100644 royalnet/packs/empty/commands/__init__.py create mode 100644 royalnet/packs/empty/tables/__init__.py create mode 100644 royalnet/packs/royal/__init__.py rename royalnet/{commands/royalgames => packs/royal/commands}/__init__.py (51%) rename royalnet/{commands/royalgames => packs/royal/commands}/ciaoruozi.py (79%) rename royalnet/{commands/royalgames => packs/royal/commands}/color.py (75%) rename royalnet/{commands/royalgames => packs/royal/commands}/cv.py (94%) rename royalnet/{commands/royalgames => packs/royal/commands}/diario.py (97%) rename royalnet/{commands/royalgames => packs/royal/commands}/dnditem.py (92%) rename royalnet/{commands/royalgames => packs/royal/commands}/dndspell.py (95%) rename royalnet/{commands/royalgames => packs/royal/commands}/mm.py (98%) rename royalnet/{commands/royalmusic => packs/royal/commands}/mp3.py (89%) rename royalnet/{commands/royalmusic => packs/royal/commands}/pause.py (82%) rename royalnet/{commands/royalmusic => packs/royal/commands}/play.py (89%) rename royalnet/{commands/royalmusic => packs/royal/commands}/playmode.py (84%) rename royalnet/{commands/royalmusic => packs/royal/commands}/queue.py (96%) rename royalnet/{commands/royalgames => packs/royal/commands}/rage.py (83%) rename royalnet/{commands/royalgames => packs/royal/commands}/reminder.py (94%) rename royalnet/{commands/royalgames => packs/royal/commands}/ship.py (92%) rename royalnet/{commands/royalmusic => packs/royal/commands}/skip.py (92%) rename royalnet/{commands/royalgames => packs/royal/commands}/smecds.py (98%) rename royalnet/{commands/royalmusic => packs/royal/commands}/soundcloud.py (94%) rename royalnet/{commands/royalmusic => packs/royal/commands}/summon.py (95%) rename royalnet/{commands/royalgames => packs/royal/commands}/trivia.py (95%) rename royalnet/{commands/royalgames => packs/royal/commands}/videochannel.py (93%) rename royalnet/{commands/royalmusic => packs/royal/commands}/youtube.py (94%) rename royalnet/{commands/royalmusic => packs/royal/commands}/zawarudo.py (93%) create mode 100644 royalnet/packs/royal/tables/__init__.py rename royalnet/{database => packs/royal}/tables/activekvgroups.py (86%) rename royalnet/{database => packs/royal}/tables/aliases.py (91%) rename royalnet/{database => packs/royal}/tables/bios.py (96%) rename royalnet/{database => packs/royal}/tables/diario.py (97%) rename royalnet/{database => packs/royal}/tables/keygroups.py (100%) rename royalnet/{database => packs/royal}/tables/keyvalues.py (92%) rename royalnet/{database => packs/royal}/tables/mmdecisions.py (94%) rename royalnet/{database => packs/royal}/tables/mmevents.py (89%) rename royalnet/{database => packs/royal}/tables/mmresponse.py (94%) rename royalnet/{database => packs/royal}/tables/reminders.py (94%) rename royalnet/{database => packs/royal}/tables/triviascores.py (97%) rename royalnet/{database => packs/royal}/tables/wikipages.py (100%) rename royalnet/{database => packs/royal}/tables/wikirevisions.py (90%) diff --git a/docs/html/_static/jquery-3.4.1.js b/docs/html/_static/jquery-3.4.1.js index 773ad95c..1b8f13f9 100644 --- a/docs/html/_static/jquery-3.4.1.js +++ b/docs/html/_static/jquery-3.4.1.js @@ -5170,7 +5170,7 @@ jQuery.event = { } } - // Remove generic event handler if we removed something and no more handlers exist + // Remove common event handler if we removed something and no more handlers exist // (avoids potential for endless recursion during removal of special event handlers) if ( origCount && !handlers.length ) { if ( !special.teardown || diff --git a/docs_source/apireference.rst b/docs_source/apireference.rst index 78f973f2..a8b13455 100644 --- a/docs_source/apireference.rst +++ b/docs_source/apireference.rst @@ -5,66 +5,7 @@ These pages were automatically generated from docstrings in code. They might be outdated, or incomplete. -Audio ------------------------------------- - -.. automodule:: royalnet.audio - :members: - :undoc-members: - :private-members: - -Bots ------------------------------------- - -.. automodule:: royalnet.bots - :members: - :undoc-members: - :private-members: - -Commands ------------------------------------- - -.. automodule:: royalnet.commands - :members: - :undoc-members: - :private-members: - -Database ------------------------------------- - -.. automodule:: royalnet.database - :members: - :undoc-members: - :private-members: - -Network ------------------------------------- - -.. automodule:: royalnet.network - :members: - :undoc-members: - :private-members: - -Utils ------------------------------------- - -.. automodule:: royalnet.utils - :members: - :undoc-members: - :private-members: - -Web ------------------------------------- - -.. automodule:: royalnet.web - :members: - :undoc-members: - :private-members: - -Error ------------------------------------- - -.. automodule:: royalnet.error +.. automodule:: royalnet :members: :undoc-members: :private-members: diff --git a/royalnet/__init__.py b/royalnet/__init__.py index 76815422..c43072c8 100644 --- a/royalnet/__init__.py +++ b/royalnet/__init__.py @@ -1,4 +1,3 @@ -from . import audio, bots, database, utils, error, web, version -from royalnet import commands +from . import audio, bots, commands, packs, database, utils, error, web, version __all__ = ["audio", "bots", "commands", "database", "utils", "error", "web", "version"] diff --git a/royalnet/__main__.py b/royalnet/__main__.py index cd37a0c4..d4122bc5 100644 --- a/royalnet/__main__.py +++ b/royalnet/__main__.py @@ -2,6 +2,7 @@ import click import typing import importlib import royalnet as r +import royalherald as rh import multiprocessing import keyring @@ -13,8 +14,8 @@ import keyring help="Enable/disable the Discord module.") @click.option("-d", "--database", type=str, default=None, help="The PostgreSQL database path.") -@click.option("-c", "--command-packs", type=str, multiple=True, default=[], - help="The names of the command pack modules that should be imported.") +@click.option("-p", "--packs", type=str, multiple=True, default=[], + help="The names of the Packs that should be used.") @click.option("-n", "--network-address", type=str, default=None, help="The Network server URL to connect to.") @click.option("-l", "--local-network-server", is_flag=True, default=False, @@ -26,7 +27,7 @@ import keyring def run(telegram: typing.Optional[bool], discord: typing.Optional[bool], database: typing.Optional[str], - command_packs: typing.List[str], + packs: typing.List[str], network_address: typing.Optional[str], local_network_server: bool, secrets_name: str, @@ -63,41 +64,38 @@ def run(telegram: typing.Optional[bool], # Start the network server if local_network_server: server_process = multiprocessing.Process(name="Network Server", - target=r.network.NetworkServer("0.0.0.0", - 44444, - network_password).run_blocking, + target=rh.Server("0.0.0.0", 44444, network_password).run_blocking, daemon=True) server_process.start() network_address = "ws://127.0.0.1:44444/" # Create a Royalnet configuration - network_config: typing.Optional[r.network.NetworkConfig] = None + network_config: typing.Optional[rh.Config] = None if network_address is not None: - network_config = r.network.NetworkConfig(network_address, network_password) + network_config = rh.Config(network_address, network_password) # Create a Alchemy configuration telegram_db_config: typing.Optional[r.database.DatabaseConfig] = None discord_db_config: typing.Optional[r.database.DatabaseConfig] = None if database is not None: telegram_db_config = r.database.DatabaseConfig(database, - r.database.tables.User, - r.database.tables.Telegram, + r.packs.common.tables.User, + r.packs.common.tables.Telegram, "tg_id") discord_db_config = r.database.DatabaseConfig(database, - r.database.tables.User, - r.database.tables.Discord, + r.packs.common.tables.User, + r.packs.common.tables.Discord, "discord_id") # Import command packs - if not command_packs: - raise click.ClickException("No command packs were specified.") + packs.append("royalnet.packs.common") # common pack is always imported enabled_commands = [] - for pack in command_packs: + for pack in packs: imported = importlib.import_module(pack) try: imported_commands = imported.commands except AttributeError: - raise click.ClickException(f"{pack} isn't a Royalnet command pack.") + raise click.ClickException(f"{pack} isn't a Royalnet Pack.") enabled_commands = [*enabled_commands, *imported_commands] telegram_process: typing.Optional[multiprocessing.Process] = None diff --git a/royalnet/audio/playmodes.py b/royalnet/audio/playmodes.py index 5028950d..10c08929 100644 --- a/royalnet/audio/playmodes.py +++ b/royalnet/audio/playmodes.py @@ -52,7 +52,7 @@ class PlayMode: def queue_preview(self) -> typing.List[YtdlDiscord]: """Display all the videos in the PlayMode as a list, if possible. - To be used with ``queue`` commands, for example. + To be used with ``queue`` packs, for example. Raises: NotImplementedError: If a preview can't be generated. diff --git a/royalnet/bots/__init__.py b/royalnet/bots/__init__.py index 75bf4e5a..a6aef182 100644 --- a/royalnet/bots/__init__.py +++ b/royalnet/bots/__init__.py @@ -1,4 +1,4 @@ -"""Various bot interfaces, and a generic class to create new ones.""" +"""Various bot interfaces, and a common class to create new ones.""" from .generic import GenericBot from .telegram import TelegramBot diff --git a/royalnet/bots/discord.py b/royalnet/bots/discord.py index b5aa86bc..8130e5bd 100644 --- a/royalnet/bots/discord.py +++ b/royalnet/bots/discord.py @@ -5,7 +5,7 @@ from .generic import GenericBot from ..utils import * from ..error import * from ..audio import * -from ..commands import * +from ..packs import * log = _logging.getLogger(__name__) diff --git a/royalnet/bots/generic.py b/royalnet/bots/generic.py index 9ad032b9..c225fbc0 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 ..commands import * +from ..packs import * from ..error import * @@ -17,14 +17,14 @@ log = logging.getLogger(__name__) class GenericBot: - """A generic bot class, to be used as base for the other more specific classes, such as + """A common bot class, to be used as base for the other more specific classes, such as :py:class:`royalnet.bots.TelegramBot` and :py:class:`royalnet.bots.DiscordBot`. """ interface_name = NotImplemented def _init_commands(self) -> None: - """Generate the ``commands`` dictionary required to handle incoming messages, and the ``network_handlers`` + """Generate the ``packs`` dictionary required to handle incoming messages, and the ``network_handlers`` dictionary required to handle incoming requests. """ - log.info(f"Registering commands...") + log.info(f"Registering packs...") self._Interface = self._interface_factory() self._Data = self._data_factory() self.commands = {} @@ -126,7 +126,7 @@ class GenericBot: }).to_dict() def _init_database(self): - """Create an :py:class:`royalnet.database.Alchemy` with the tables required by the commands. Then, + """Create an :py:class:`royalnet.database.Alchemy` with the tables required by the packs. Then, find the chain that links the ``master_table`` to the ``identity_table``. """ if self.uninitialized_database_config: log.info(f"Database: enabled") @@ -198,7 +198,7 @@ class GenericBot: self.initialized = True def run(self): - """A blocking coroutine that should make the bot start listening to commands and requests.""" + """A blocking coroutine that should make the bot start listening to packs and requests.""" raise NotImplementedError() def run_blocking(self, verbose=False): diff --git a/royalnet/bots/telegram.py b/royalnet/bots/telegram.py index 2c37d45e..4ada1da0 100644 --- a/royalnet/bots/telegram.py +++ b/royalnet/bots/telegram.py @@ -5,10 +5,11 @@ import urllib3 import asyncio import sentry_sdk import logging as _logging +import warnings from .generic import GenericBot from ..utils import * from ..error import * -from ..commands import * +from ..packs import * log = _logging.getLogger(__name__) @@ -84,6 +85,7 @@ class TelegramBot(GenericBot): return result async def keyboard(data, text: str, keyboard: typing.Dict[str, typing.Callable]) -> None: + warnings.warn("keyboard is deprecated, please avoid using it", category=DeprecationWarning) tg_keyboard = [] for key in keyboard: press_id = uuid.uuid4() diff --git a/royalnet/commands/command.py b/royalnet/commands/command.py index c720fc49..7aac2d73 100644 --- a/royalnet/commands/command.py +++ b/royalnet/commands/command.py @@ -20,7 +20,7 @@ class Command: """The syntax of the command, to be displayed when a :py:exc:`royalnet.error.InvalidInputError` is raised, in the format ``(required_arg) [optional_arg]``.""" - require_alchemy_tables: typing.Set = set() + tables: typing.Set = set() """A set of :py:class:`royalnet.database` tables that must exist for this command to work.""" def __init__(self, interface: CommandInterface): diff --git a/royalnet/commands/commanddata.py b/royalnet/commands/commanddata.py index b72daa88..05a7ab6a 100644 --- a/royalnet/commands/commanddata.py +++ b/royalnet/commands/commanddata.py @@ -1,4 +1,5 @@ import typing +import warnings from .commanderrors import UnsupportedError @@ -22,6 +23,7 @@ class CommandData: """Send a keyboard having the keys of the dict as keys and calling the correspondent values on a press. The function should be passed the :py:class:`CommandData` instance as a argument.""" + warnings.warn("keyboard is deprecated, please avoid using it", category=DeprecationWarning) raise UnsupportedError("'keyboard' is not supported on this platform") async def delete_invoking(self, error_if_unavailable=False) -> None: diff --git a/royalnet/commands/debug/__init__.py b/royalnet/commands/debug/__init__.py deleted file mode 100644 index 82735ce5..00000000 --- a/royalnet/commands/debug/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -from .debug_error import DebugErrorCommand -from .debug_keyboard import DebugKeyboardCommand -from .debug_invoking import DebugInvokingCommand - - -commands = [ - DebugErrorCommand, - DebugKeyboardCommand, - DebugInvokingCommand, -] - - -__all__ = [command.__name__ for command in commands] diff --git a/royalnet/commands/debug/debug_error.py b/royalnet/commands/debug/debug_error.py deleted file mode 100644 index 35e79b55..00000000 --- a/royalnet/commands/debug/debug_error.py +++ /dev/null @@ -1,13 +0,0 @@ -import typing -from ..command import Command -from ..commandargs import CommandArgs -from ..commanddata import CommandData - - -class DebugErrorCommand(Command): - name: str = "debug_error" - - description: str = "Causa un'eccezione nel bot." - - async def run(self, args: CommandArgs, data: CommandData) -> None: - raise Exception("debug_error command was called") diff --git a/royalnet/commands/debug/debug_invoking.py b/royalnet/commands/debug/debug_invoking.py deleted file mode 100644 index 23f6fe43..00000000 --- a/royalnet/commands/debug/debug_invoking.py +++ /dev/null @@ -1,14 +0,0 @@ -import typing -from ..command import Command -from ..commandargs import CommandArgs -from ..commanddata import CommandData - - -class DebugInvokingCommand(Command): - name: str = "debug_invoking" - - description: str = "Elimina il messaggio di invocazione." - - async def run(self, args: CommandArgs, data: CommandData) -> None: - await data.delete_invoking(error_if_unavailable=True) - await data.reply("🗑 Messaggio eliminato.") diff --git a/royalnet/commands/debug/debug_keyboard.py b/royalnet/commands/debug/debug_keyboard.py deleted file mode 100644 index 446234fb..00000000 --- a/royalnet/commands/debug/debug_keyboard.py +++ /dev/null @@ -1,18 +0,0 @@ -import typing -from ..command import Command -from ..commandargs import CommandArgs -from ..commanddata import CommandData - - -class DebugKeyboardCommand(Command): - name: str = "debug_keyboard" - - description: str = "Invia una tastiera di prova." - - async def _callback(self, data: CommandData): - await data.reply("OK.") - - async def run(self, args: CommandArgs, data: CommandData) -> None: - await data.keyboard("This is a keyboard.", { - "✅ OK": self._callback - }) diff --git a/royalnet/commands/royalgames/ping.py b/royalnet/commands/royalgames/ping.py deleted file mode 100644 index 5fbefea4..00000000 --- a/royalnet/commands/royalgames/ping.py +++ /dev/null @@ -1,13 +0,0 @@ -import typing -from ..command import Command -from ..commandargs import CommandArgs -from ..commanddata import CommandData - - -class PingCommand(Command): - name: str = "ping" - - description: str = "Gioca a ping-pong con il bot." - - async def run(self, args: CommandArgs, data: CommandData) -> None: - await data.reply("🏓 Pong!") diff --git a/royalnet/commands/royalmusic/__init__.py b/royalnet/commands/royalmusic/__init__.py deleted file mode 100644 index e8d00ec3..00000000 --- a/royalnet/commands/royalmusic/__init__.py +++ /dev/null @@ -1,30 +0,0 @@ -"""Commands that can be used in bots. - -These probably won't suit your needs, as they are tailored for the bots of the User Games gaming community, but they - may be useful to develop new ones.""" - -from .pause import PauseCommand -from .play import PlayCommand -from .playmode import PlaymodeCommand -from .queue import QueueCommand -from .skip import SkipCommand -from .summon import SummonCommand -from .youtube import YoutubeCommand -from .soundcloud import SoundcloudCommand -from .zawarudo import ZawarudoCommand - - -commands = [ - PauseCommand, - PlayCommand, - PlaymodeCommand, - QueueCommand, - SkipCommand, - SummonCommand, - YoutubeCommand, - SoundcloudCommand, - ZawarudoCommand -] - - -__all__ = [command.__name__ for command in commands] diff --git a/royalnet/database/__init__.py b/royalnet/database/__init__.py index 66e22bf6..9434c897 100644 --- a/royalnet/database/__init__.py +++ b/royalnet/database/__init__.py @@ -3,6 +3,5 @@ from .alchemy import Alchemy from .relationshiplinkchain import relationshiplinkchain from .databaseconfig import DatabaseConfig -from . import tables -__all__ = ["Alchemy", "relationshiplinkchain", "DatabaseConfig", "tables"] +__all__ = ["Alchemy", "relationshiplinkchain", "DatabaseConfig"] diff --git a/royalnet/database/tables/__init__.py b/royalnet/database/tables/__init__.py deleted file mode 100644 index 9b6953d2..00000000 --- a/royalnet/database/tables/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -from .users import User -from .telegram import Telegram -from .diario import Diario -from .aliases import Alias -from .activekvgroups import ActiveKvGroup -from .keyvalues import Keyvalue -from .keygroups import Keygroup -from .discord import Discord -from .wikipages import WikiPage -from .wikirevisions import WikiRevision -from .medals import Medal -from .medalawards import MedalAward -from .bios import Bio -from .reminders import Reminder -from .triviascores import TriviaScore -from .mmdecisions import MMDecision -from .mmevents import MMEvent -from .mmresponse import MMResponse - -__all__ = ["User", "Telegram", "Diario", "Alias", "ActiveKvGroup", "Keyvalue", "Keygroup", "Discord", "WikiPage", - "WikiRevision", "Medal", "MedalAward", "Bio", "Reminder", "TriviaScore", "MMDecision", "MMEvent", - "MMResponse"] diff --git a/royalnet/database/tables/medalawards.py b/royalnet/database/tables/medalawards.py deleted file mode 100644 index 6426705d..00000000 --- a/royalnet/database/tables/medalawards.py +++ /dev/null @@ -1,39 +0,0 @@ -from sqlalchemy import Column, \ - Integer, \ - DateTime, \ - ForeignKey -from sqlalchemy.ext.declarative import declared_attr -from sqlalchemy.orm import relationship -from .users import User -from .medals import Medal - - -class MedalAward: - __tablename__ = "MedalAward" - - @declared_attr - def award_id(self): - return Column(Integer, primary_key=True) - - @declared_attr - def date(self): - return Column(DateTime) - - @declared_attr - def medal_id(self): - return Column(Integer, ForeignKey("medals.mid"), nullable=False) - - @declared_attr - def royal_id(self): - return Column(Integer, ForeignKey("users.uid"), nullable=False) - - @declared_attr - def medal(self): - return relationship("Medal", backref="awarded_to") - - @declared_attr - def royal(self): - return relationship("User", backref="medals_received") - - def __repr__(self): - return f"" diff --git a/royalnet/database/tables/medals.py b/royalnet/database/tables/medals.py deleted file mode 100644 index 53a27024..00000000 --- a/royalnet/database/tables/medals.py +++ /dev/null @@ -1,40 +0,0 @@ -from sqlalchemy import Column, \ - Integer, \ - String -from sqlalchemy.ext.declarative import declared_attr -# noinspection PyUnresolvedReferences -from .keygroups import Keygroup - - -class Medal: - __tablename__ = "medals" - - @declared_attr - def mid(self): - return Column(Integer, primary_key=True) - - @declared_attr - def name(self): - return Column(String, nullable=False) - - @declared_attr - def description(self): - return Column(String) - - @declared_attr - def icon(self): - return Column(String) - - @declared_attr - def classes(self): - return Column(String, nullable=False, default="") - - @declared_attr - def score(self): - return Column(Integer, nullable=False) - - def __str__(self): - return self.name - - def __repr__(self): - return f"" diff --git a/royalnet/packs/__init__.py b/royalnet/packs/__init__.py new file mode 100644 index 00000000..54e38ed4 --- /dev/null +++ b/royalnet/packs/__init__.py @@ -0,0 +1,7 @@ +from . import common +from . import royal + +__all__ = [ + "common", + "royal", +] diff --git a/royalnet/packs/common/__init__.py b/royalnet/packs/common/__init__.py new file mode 100644 index 00000000..b3b78faa --- /dev/null +++ b/royalnet/packs/common/__init__.py @@ -0,0 +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 + +__all__ = ["commands", "tables"] diff --git a/royalnet/packs/common/commands/__init__.py b/royalnet/packs/common/commands/__init__.py new file mode 100644 index 00000000..f828294e --- /dev/null +++ b/royalnet/packs/common/commands/__init__.py @@ -0,0 +1,10 @@ +# Imports go here! +from .ping import PingCommand + +# Enter the commands of your Pack here! +commands = [ + PingCommand, +] + +# Don't change this, it should automatically generate __all__ +__all__ = [command.__class__.__qualname__ for command in commands] diff --git a/royalnet/packs/common/commands/ping.py b/royalnet/packs/common/commands/ping.py new file mode 100644 index 00000000..25f2b9bd --- /dev/null +++ b/royalnet/packs/common/commands/ping.py @@ -0,0 +1,10 @@ +from royalnet.commands import * + + +class PingCommand(Command): + name: str = "ping" + + description: str = "Get a pong response." + + async def run(self, args: CommandArgs, data: CommandData) -> None: + await data.reply("🏓 Pong!") diff --git a/royalnet/packs/common/tables/__init__.py b/royalnet/packs/common/tables/__init__.py new file mode 100644 index 00000000..94d6275d --- /dev/null +++ b/royalnet/packs/common/tables/__init__.py @@ -0,0 +1,14 @@ +# Imports go here! +from .users import User +from .telegram import Telegram +from .discord import Discord + +# Enter the tables of your Pack here! +tables = [ + User, + Telegram, + Discord +] + +# Don't change this, it should automatically generate __all__ +__all__ = [table.__class__.__qualname__ for table in tables] diff --git a/royalnet/database/tables/discord.py b/royalnet/packs/common/tables/discord.py similarity index 100% rename from royalnet/database/tables/discord.py rename to royalnet/packs/common/tables/discord.py diff --git a/royalnet/database/tables/telegram.py b/royalnet/packs/common/tables/telegram.py similarity index 100% rename from royalnet/database/tables/telegram.py rename to royalnet/packs/common/tables/telegram.py diff --git a/royalnet/database/tables/users.py b/royalnet/packs/common/tables/users.py similarity index 91% rename from royalnet/database/tables/users.py rename to royalnet/packs/common/tables/users.py index fa2454ed..5f176a78 100644 --- a/royalnet/database/tables/users.py +++ b/royalnet/packs/common/tables/users.py @@ -29,7 +29,7 @@ class User: return Column(LargeBinary) def __repr__(self): - return f"" + return f"<{self.__class__.__qualname__} {self.username}>" def __str__(self): return self.username diff --git a/royalnet/packs/empty/__init__.py b/royalnet/packs/empty/__init__.py new file mode 100644 index 00000000..9631915d --- /dev/null +++ b/royalnet/packs/empty/__init__.py @@ -0,0 +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 + +__all__ = ["commands", "tables"] + diff --git a/royalnet/packs/empty/commands/__init__.py b/royalnet/packs/empty/commands/__init__.py new file mode 100644 index 00000000..59ca6074 --- /dev/null +++ b/royalnet/packs/empty/commands/__init__.py @@ -0,0 +1,10 @@ +# Imports go here! + + +# Enter the commands of your Pack here! +commands = [ + +] + +# Don't change this, it should automatically generate __all__ +__all__ = [command.__class__.__qualname__ for command in commands] diff --git a/royalnet/packs/empty/tables/__init__.py b/royalnet/packs/empty/tables/__init__.py new file mode 100644 index 00000000..195418cd --- /dev/null +++ b/royalnet/packs/empty/tables/__init__.py @@ -0,0 +1,10 @@ +# Imports go here! + + +# Enter the tables of your Pack here! +tables = [ + +] + +# Don't change this, it should automatically generate __all__ +__all__ = [table.__class__.__qualname__ for table in tables] diff --git a/royalnet/packs/royal/__init__.py b/royalnet/packs/royal/__init__.py new file mode 100644 index 00000000..b3b78faa --- /dev/null +++ b/royalnet/packs/royal/__init__.py @@ -0,0 +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 + +__all__ = ["commands", "tables"] diff --git a/royalnet/commands/royalgames/__init__.py b/royalnet/packs/royal/commands/__init__.py similarity index 51% rename from royalnet/commands/royalgames/__init__.py rename to royalnet/packs/royal/commands/__init__.py index c22079da..d36d6e80 100644 --- a/royalnet/commands/royalgames/__init__.py +++ b/royalnet/packs/royal/commands/__init__.py @@ -1,13 +1,8 @@ -"""Commands that can be used in bots. - -These probably won't suit your needs, as they are tailored for the bots of the User Games gaming community, but they - may be useful to develop new ones.""" - +# Imports go here! from .ciaoruozi import CiaoruoziCommand from .color import ColorCommand from .cv import CvCommand from .diario import DiarioCommand -from .ping import PingCommand from .rage import RageCommand from .reminder import ReminderCommand from .ship import ShipCommand @@ -17,14 +12,22 @@ from .dnditem import DnditemCommand from .dndspell import DndspellCommand from .trivia import TriviaCommand from .mm import MmCommand +from .pause import PauseCommand +from .play import PlayCommand +from .playmode import PlaymodeCommand +from .queue import QueueCommand +from .skip import SkipCommand +from .summon import SummonCommand +from .youtube import YoutubeCommand +from .soundcloud import SoundcloudCommand +from .zawarudo import ZawarudoCommand - +# Enter the commands of your Pack here! commands = [ CiaoruoziCommand, ColorCommand, CvCommand, DiarioCommand, - PingCommand, RageCommand, ReminderCommand, ShipCommand, @@ -34,7 +37,16 @@ commands = [ DndspellCommand, TriviaCommand, MmCommand, + PauseCommand, + PlayCommand, + PlaymodeCommand, + QueueCommand, + SkipCommand, + SummonCommand, + YoutubeCommand, + SoundcloudCommand, + ZawarudoCommand ] - -__all__ = [command.__name__ for command in commands] +# Don't change this, it should automatically generate __all__ +__all__ = [command.__class__.__qualname__ for command in commands] diff --git a/royalnet/commands/royalgames/ciaoruozi.py b/royalnet/packs/royal/commands/ciaoruozi.py similarity index 79% rename from royalnet/commands/royalgames/ciaoruozi.py rename to royalnet/packs/royal/commands/ciaoruozi.py index e6d652c5..7deed002 100644 --- a/royalnet/commands/royalgames/ciaoruozi.py +++ b/royalnet/packs/royal/commands/ciaoruozi.py @@ -1,8 +1,6 @@ import typing import telegram -from ..command import Command -from ..commandargs import CommandArgs -from ..commanddata import CommandData +from royalnet.commands import * class CiaoruoziCommand(Command): @@ -12,7 +10,7 @@ class CiaoruoziCommand(Command): syntax: str = "" - require_alchemy_tables: typing.Set = set() + tables: typing.Set = set() async def run(self, args: CommandArgs, data: CommandData) -> None: if self.interface.name == "telegram": diff --git a/royalnet/commands/royalgames/color.py b/royalnet/packs/royal/commands/color.py similarity index 75% rename from royalnet/commands/royalgames/color.py rename to royalnet/packs/royal/commands/color.py index 871a0ee0..a7432f45 100644 --- a/royalnet/commands/royalgames/color.py +++ b/royalnet/packs/royal/commands/color.py @@ -1,7 +1,4 @@ -import typing -from ..command import Command -from ..commandargs import CommandArgs -from ..commanddata import CommandData +from royalnet.commands import * class ColorCommand(Command): diff --git a/royalnet/commands/royalgames/cv.py b/royalnet/packs/royal/commands/cv.py similarity index 94% rename from royalnet/commands/royalgames/cv.py rename to royalnet/packs/royal/commands/cv.py index 585997b7..7a76b0aa 100644 --- a/royalnet/commands/royalgames/cv.py +++ b/royalnet/packs/royal/commands/cv.py @@ -1,20 +1,16 @@ import discord import typing -from ..command import Command -from ..commandinterface import CommandInterface -from ..commandargs import CommandArgs -from ..commanddata import CommandData -from ...network import Request, ResponseSuccess -from ...utils import NetworkHandler, andformat -from ...bots import DiscordBot -from ..commanderrors import CommandError +from royalnet.commands import * +from royalnet.utils import NetworkHandler, andformat +from royalnet.bots import DiscordBot +from royalherald import Request, ResponseSuccess class CvNH(NetworkHandler): message_type = "discord_cv" @classmethod - async def discord(cls, bot: "DiscordBot", data: dict): + async def discord(cls, bot: DiscordBot, data: dict): # Find the matching guild if data["guild_name"]: guilds: typing.List[discord.Guild] = bot.client.find_guild_by_name(data["guild_name"]) diff --git a/royalnet/commands/royalgames/diario.py b/royalnet/packs/royal/commands/diario.py similarity index 97% rename from royalnet/commands/royalgames/diario.py rename to royalnet/packs/royal/commands/diario.py index 0a1ffee6..a9134e55 100644 --- a/royalnet/commands/royalgames/diario.py +++ b/royalnet/packs/royal/commands/diario.py @@ -3,12 +3,9 @@ import re import datetime import telegram import aiohttp -from ..command import Command -from ..commandargs import CommandArgs -from ..commanddata import CommandData -from ...database.tables import User, Diario, Alias -from ...utils import asyncify -from ..commanderrors import CommandError, InvalidInputError +from royalnet.commands import * +from royalnet.utils import asyncify +from ..tables import User, Diario, Alias async def to_imgur(imgur_api_key, photosizes: typing.List[telegram.PhotoSize], caption="") -> str: @@ -38,7 +35,7 @@ class DiarioCommand(Command): syntax = "[!] \"(testo)\" --[autore], [contesto]" - require_alchemy_tables = {User, Diario, Alias} + tables = {User, Diario, Alias} async def run(self, args: CommandArgs, data: CommandData) -> None: if self.interface.name == "telegram": diff --git a/royalnet/commands/royalgames/dnditem.py b/royalnet/packs/royal/commands/dnditem.py similarity index 92% rename from royalnet/commands/royalgames/dnditem.py rename to royalnet/packs/royal/commands/dnditem.py index de3b7050..510996ac 100644 --- a/royalnet/commands/royalgames/dnditem.py +++ b/royalnet/packs/royal/commands/dnditem.py @@ -1,11 +1,8 @@ import typing import aiohttp import sortedcontainers -from ..command import Command -from ..commandargs import CommandArgs -from ..commanddata import CommandData -from ..commandinterface import CommandInterface -from ...utils import parse_5etools_entry +from royalnet.commands import * +from royalnet.utils import parse_5etools_entry class DnditemCommand(Command): diff --git a/royalnet/commands/royalgames/dndspell.py b/royalnet/packs/royal/commands/dndspell.py similarity index 95% rename from royalnet/commands/royalgames/dndspell.py rename to royalnet/packs/royal/commands/dndspell.py index 63c7a992..63fffcff 100644 --- a/royalnet/commands/royalgames/dndspell.py +++ b/royalnet/packs/royal/commands/dndspell.py @@ -1,11 +1,8 @@ import typing import aiohttp import sortedcontainers -from ..command import Command -from ..commandargs import CommandArgs -from ..commanddata import CommandData -from ..commandinterface import CommandInterface -from ...utils import parse_5etools_entry, ordinalformat, andformat +from royalnet.commands import * +from royalnet.utils import parse_5etools_entry, ordinalformat, andformat class DndspellCommand(Command): diff --git a/royalnet/commands/royalgames/mm.py b/royalnet/packs/royal/commands/mm.py similarity index 98% rename from royalnet/commands/royalgames/mm.py rename to royalnet/packs/royal/commands/mm.py index bf124a38..bad5e4af 100644 --- a/royalnet/commands/royalgames/mm.py +++ b/royalnet/packs/royal/commands/mm.py @@ -5,12 +5,10 @@ import asyncio import re import logging import typing -from ..command import Command -from ..commandargs import CommandArgs -from ..commanddata import CommandData -from ...database.tables import MMEvent, MMDecision, MMResponse -from ..commanderrors import InvalidInputError, UnsupportedError -from ...utils import asyncify, telegram_escape, sleep_until +from royalnet.commands import * +from royalnet.utils import asyncify, telegram_escape, sleep_until +from ..tables import MMEvent, MMDecision, MMResponse + log = logging.getLogger(__name__) @@ -27,7 +25,7 @@ class MmCommand(Command): syntax: str = "[ (data) ] (nomegioco)\n[descrizione]" - require_alchemy_tables = {MMEvent, MMDecision, MMResponse} + tables = {MMEvent, MMDecision, MMResponse} _cycle_duration = 10 diff --git a/royalnet/commands/royalmusic/mp3.py b/royalnet/packs/royal/commands/mp3.py similarity index 89% rename from royalnet/commands/royalmusic/mp3.py rename to royalnet/packs/royal/commands/mp3.py index 8532aa98..48e6fdba 100644 --- a/royalnet/commands/royalmusic/mp3.py +++ b/royalnet/packs/royal/commands/mp3.py @@ -1,11 +1,9 @@ import typing import urllib.parse import asyncio -from ..command import Command -from ..commandargs import CommandArgs -from ..commanddata import CommandData -from ...utils import asyncify -from ...audio import YtdlMp3 +from royalnet.commands import * +from royalnet.utils import asyncify +from royalnet.audio import YtdlMp3 class Mp3Command(Command): diff --git a/royalnet/commands/royalmusic/pause.py b/royalnet/packs/royal/commands/pause.py similarity index 82% rename from royalnet/commands/royalmusic/pause.py rename to royalnet/packs/royal/commands/pause.py index 57c16510..f02b4404 100644 --- a/royalnet/commands/royalmusic/pause.py +++ b/royalnet/packs/royal/commands/pause.py @@ -1,14 +1,9 @@ import typing import discord -from ..command import Command -from ..commandinterface import CommandInterface -from ..commandargs import CommandArgs -from ..commanddata import CommandData -from ...utils import NetworkHandler -from ...network import Request, ResponseSuccess -from ..commanderrors import CommandError -if typing.TYPE_CHECKING: - from ...bots import DiscordBot +from royalnet.commands import * +from royalnet.utils import NetworkHandler +from royalnet.bots import DiscordBot +from royalherald import Request, ResponseSuccess class PauseNH(NetworkHandler): @@ -16,7 +11,7 @@ class PauseNH(NetworkHandler): # noinspection PyProtectedMember @classmethod - async def discord(cls, bot: "DiscordBot", data: dict): + async def discord(cls, bot: DiscordBot, data: dict): # Find the matching guild if data["guild_name"]: guilds: typing.List[discord.Guild] = bot.client.find_guild_by_name(data["guild_name"]) diff --git a/royalnet/commands/royalmusic/play.py b/royalnet/packs/royal/commands/play.py similarity index 89% rename from royalnet/commands/royalmusic/play.py rename to royalnet/packs/royal/commands/play.py index c833020a..ce4b00c5 100644 --- a/royalnet/commands/royalmusic/play.py +++ b/royalnet/packs/royal/commands/play.py @@ -2,16 +2,11 @@ import typing import pickle import datetime import discord -from ..command import Command -from ..commandinterface import CommandInterface -from ..commandargs import CommandArgs -from ..commanddata import CommandData -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.commands import * +from royalnet.utils import NetworkHandler, asyncify +from royalnet.audio import YtdlDiscord +from royalnet.bots import DiscordBot +from royalherald import Request, ResponseSuccess class PlayNH(NetworkHandler): diff --git a/royalnet/commands/royalmusic/playmode.py b/royalnet/packs/royal/commands/playmode.py similarity index 84% rename from royalnet/commands/royalmusic/playmode.py rename to royalnet/packs/royal/commands/playmode.py index 975c5bf3..edaf6c03 100644 --- a/royalnet/commands/royalmusic/playmode.py +++ b/royalnet/packs/royal/commands/playmode.py @@ -1,16 +1,11 @@ import typing import pickle import discord -from ..command import Command -from ..commandinterface import CommandInterface -from ..commandargs import CommandArgs -from ..commanddata import CommandData -from ...utils import NetworkHandler -from ...network import Request, ResponseSuccess -from ..commanderrors import CommandError -from ...audio.playmodes import Playlist, Pool, Layers -if typing.TYPE_CHECKING: - from ...bots import DiscordBot +from royalnet.commands import * +from royalnet.utils import NetworkHandler +from royalnet.audio.playmodes import Playlist, Pool, Layers +from royalnet.bots import DiscordBot +from royalherald import Request, ResponseSuccess class PlaymodeNH(NetworkHandler): diff --git a/royalnet/commands/royalmusic/queue.py b/royalnet/packs/royal/commands/queue.py similarity index 96% rename from royalnet/commands/royalmusic/queue.py rename to royalnet/packs/royal/commands/queue.py index f7e0b0e6..a14c3662 100644 --- a/royalnet/commands/royalmusic/queue.py +++ b/royalnet/packs/royal/commands/queue.py @@ -1,10 +1,7 @@ import typing import pickle import discord -from ..command import Command -from ..commandinterface import CommandInterface -from ..commandargs import CommandArgs -from ..commanddata import CommandData +from royalnet.commands import * from ...utils import NetworkHandler, numberemojiformat from ...network import Request, ResponseSuccess from ..commanderrors import CommandError diff --git a/royalnet/commands/royalgames/rage.py b/royalnet/packs/royal/commands/rage.py similarity index 83% rename from royalnet/commands/royalgames/rage.py rename to royalnet/packs/royal/commands/rage.py index 9a8c85cd..91435811 100644 --- a/royalnet/commands/royalgames/rage.py +++ b/royalnet/packs/royal/commands/rage.py @@ -1,8 +1,6 @@ import typing import random -from ..command import Command -from ..commandargs import CommandArgs -from ..commanddata import CommandData +from royalnet.commands import * class RageCommand(Command): diff --git a/royalnet/commands/royalgames/reminder.py b/royalnet/packs/royal/commands/reminder.py similarity index 94% rename from royalnet/commands/royalgames/reminder.py rename to royalnet/packs/royal/commands/reminder.py index 0fb7cf61..9b938efe 100644 --- a/royalnet/commands/royalgames/reminder.py +++ b/royalnet/packs/royal/commands/reminder.py @@ -5,10 +5,7 @@ import pickle import telegram import discord from sqlalchemy import and_ -from ..command import Command -from ..commandargs import CommandArgs -from ..commandinterface import CommandInterface -from ..commanddata import CommandData +from royalnet.commands import * from ...utils import sleep_until, asyncify, telegram_escape, discord_escape from ...database.tables import Reminder from ..commanderrors import InvalidInputError, UnsupportedError @@ -22,7 +19,7 @@ class ReminderCommand(Command): syntax: str = "[ (data) ] (messaggio)" - require_alchemy_tables = {Reminder} + tables = {Reminder} def __init__(self, interface: CommandInterface): super().__init__(interface) diff --git a/royalnet/commands/royalgames/ship.py b/royalnet/packs/royal/commands/ship.py similarity index 92% rename from royalnet/commands/royalgames/ship.py rename to royalnet/packs/royal/commands/ship.py index 5111ae5d..a10d22dd 100644 --- a/royalnet/commands/royalgames/ship.py +++ b/royalnet/packs/royal/commands/ship.py @@ -1,8 +1,6 @@ import typing import re -from ..command import Command -from ..commandargs import CommandArgs -from ..commanddata import CommandData +from royalnet.commands import * from ...utils import safeformat diff --git a/royalnet/commands/royalmusic/skip.py b/royalnet/packs/royal/commands/skip.py similarity index 92% rename from royalnet/commands/royalmusic/skip.py rename to royalnet/packs/royal/commands/skip.py index 2f270efc..d5455d2d 100644 --- a/royalnet/commands/royalmusic/skip.py +++ b/royalnet/packs/royal/commands/skip.py @@ -1,10 +1,7 @@ import typing import pickle import discord -from ..command import Command -from ..commandinterface import CommandInterface -from ..commandargs import CommandArgs -from ..commanddata import CommandData +from royalnet.commands import * from ...utils import NetworkHandler, asyncify from ...network import Request, ResponseSuccess from ..commanderrors import CommandError diff --git a/royalnet/commands/royalgames/smecds.py b/royalnet/packs/royal/commands/smecds.py similarity index 98% rename from royalnet/commands/royalgames/smecds.py rename to royalnet/packs/royal/commands/smecds.py index b52f6341..2e6f15bc 100644 --- a/royalnet/commands/royalgames/smecds.py +++ b/royalnet/packs/royal/commands/smecds.py @@ -1,8 +1,6 @@ import typing import random -from ..command import Command -from ..commandargs import CommandArgs -from ..commanddata import CommandData +from royalnet.commands import * from ...utils import safeformat diff --git a/royalnet/commands/royalmusic/soundcloud.py b/royalnet/packs/royal/commands/soundcloud.py similarity index 94% rename from royalnet/commands/royalmusic/soundcloud.py rename to royalnet/packs/royal/commands/soundcloud.py index 3940134c..7091acc4 100644 --- a/royalnet/commands/royalmusic/soundcloud.py +++ b/royalnet/packs/royal/commands/soundcloud.py @@ -2,13 +2,9 @@ import typing import pickle import datetime import discord -from ..command import Command -from ..commandinterface import CommandInterface -from ..commandargs import CommandArgs -from ..commanddata import CommandData +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: diff --git a/royalnet/commands/royalmusic/summon.py b/royalnet/packs/royal/commands/summon.py similarity index 95% rename from royalnet/commands/royalmusic/summon.py rename to royalnet/packs/royal/commands/summon.py index 7ea5c1bb..52ea18fc 100644 --- a/royalnet/commands/royalmusic/summon.py +++ b/royalnet/packs/royal/commands/summon.py @@ -1,9 +1,6 @@ import typing import discord -from ..command import Command -from ..commandinterface import CommandInterface -from ..commandargs import CommandArgs -from ..commanddata import CommandData +from royalnet.commands import * from ...utils import NetworkHandler from ...network import Request, ResponseSuccess from ..commanderrors import CommandError diff --git a/royalnet/commands/royalgames/trivia.py b/royalnet/packs/royal/commands/trivia.py similarity index 95% rename from royalnet/commands/royalgames/trivia.py rename to royalnet/packs/royal/commands/trivia.py index 4c129684..26d18636 100644 --- a/royalnet/commands/royalgames/trivia.py +++ b/royalnet/packs/royal/commands/trivia.py @@ -4,10 +4,7 @@ import aiohttp import random import uuid import html -from ..command import Command -from ..commandargs import CommandArgs -from ..commanddata import CommandData -from ..commandinterface import CommandInterface +from royalnet.commands import * from ...utils import asyncify from ..commanderrors import CommandError, KeyboardExpiredError from ...database.tables import TriviaScore @@ -20,7 +17,7 @@ class TriviaCommand(Command): description: str = "Manda una domanda dell'OpenTDB in chat." - require_alchemy_tables = {TriviaScore} + tables = {TriviaScore} _letter_emojis = ["🇦", "🇧", "🇨", "🇩"] diff --git a/royalnet/commands/royalgames/videochannel.py b/royalnet/packs/royal/commands/videochannel.py similarity index 93% rename from royalnet/commands/royalgames/videochannel.py rename to royalnet/packs/royal/commands/videochannel.py index d1a7845f..9ea1be2b 100644 --- a/royalnet/commands/royalgames/videochannel.py +++ b/royalnet/packs/royal/commands/videochannel.py @@ -1,9 +1,6 @@ import typing import discord -from ..command import Command -from ..commandargs import CommandArgs -from ..commanddata import CommandData -from ..commanderrors import CommandError, UnsupportedError +from royalnet.commands import * class VideochannelCommand(Command): diff --git a/royalnet/commands/royalmusic/youtube.py b/royalnet/packs/royal/commands/youtube.py similarity index 94% rename from royalnet/commands/royalmusic/youtube.py rename to royalnet/packs/royal/commands/youtube.py index a181af9f..9cd9f480 100644 --- a/royalnet/commands/royalmusic/youtube.py +++ b/royalnet/packs/royal/commands/youtube.py @@ -2,13 +2,9 @@ import typing import pickle import datetime import discord -from ..command import Command -from ..commandinterface import CommandInterface -from ..commandargs import CommandArgs -from ..commanddata import CommandData +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 diff --git a/royalnet/commands/royalmusic/zawarudo.py b/royalnet/packs/royal/commands/zawarudo.py similarity index 93% rename from royalnet/commands/royalmusic/zawarudo.py rename to royalnet/packs/royal/commands/zawarudo.py index 0d9f2986..e42d68ed 100644 --- a/royalnet/commands/royalmusic/zawarudo.py +++ b/royalnet/packs/royal/commands/zawarudo.py @@ -2,13 +2,9 @@ import typing import discord import asyncio import datetime -from ..command import Command -from ..commandinterface import CommandInterface -from ..commandargs import CommandArgs -from ..commanddata import CommandData +from royalnet.commands import * from ...utils import NetworkHandler, asyncify from ...network import Request, ResponseSuccess -from ..commanderrors import CommandError, InvalidInputError, UnsupportedError, KeyboardExpiredError from ...audio import YtdlDiscord from ...audio.playmodes import Playlist if typing.TYPE_CHECKING: diff --git a/royalnet/packs/royal/tables/__init__.py b/royalnet/packs/royal/tables/__init__.py new file mode 100644 index 00000000..c95ec139 --- /dev/null +++ b/royalnet/packs/royal/tables/__init__.py @@ -0,0 +1,41 @@ +# Imports go here! +from royalnet.packs.common.tables import User +from royalnet.packs.common.tables import Telegram +from royalnet.packs.common.tables import Discord + +from .diario import Diario +from .aliases import Alias +from .activekvgroups import ActiveKvGroup +from .keyvalues import Keyvalue +from .keygroups import Keygroup +from .wikipages import WikiPage +from .wikirevisions import WikiRevision +from .bios import Bio +from .reminders import Reminder +from .triviascores import TriviaScore +from .mmdecisions import MMDecision +from .mmevents import MMEvent +from .mmresponse import MMResponse + +# Enter the tables of your Pack here! +tables = [ + User, + Telegram, + Discord, + Diario, + Alias, + ActiveKvGroup, + Keyvalue, + Keygroup, + WikiPage, + WikiRevision, + Bio, + Reminder, + TriviaScore, + MMDecision, + MMEvent, + MMResponse, +] + +# Don't change this, it should automatically generate __all__ +__all__ = [table.__class__.__qualname__ for table in tables] diff --git a/royalnet/database/tables/activekvgroups.py b/royalnet/packs/royal/tables/activekvgroups.py similarity index 86% rename from royalnet/database/tables/activekvgroups.py rename to royalnet/packs/royal/tables/activekvgroups.py index 168d8284..a4f72cff 100644 --- a/royalnet/database/tables/activekvgroups.py +++ b/royalnet/packs/royal/tables/activekvgroups.py @@ -4,10 +4,6 @@ from sqlalchemy import Column, \ ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declared_attr -# noinspection PyUnresolvedReferences -from .users import User -# noinspection PyUnresolvedReferences -from .keygroups import Keygroup class ActiveKvGroup: diff --git a/royalnet/database/tables/aliases.py b/royalnet/packs/royal/tables/aliases.py similarity index 91% rename from royalnet/database/tables/aliases.py rename to royalnet/packs/royal/tables/aliases.py index 77815149..2a1c99ec 100644 --- a/royalnet/database/tables/aliases.py +++ b/royalnet/packs/royal/tables/aliases.py @@ -4,8 +4,6 @@ from sqlalchemy import Column, \ ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declared_attr -# noinspection PyUnresolvedReferences -from .users import User class Alias: diff --git a/royalnet/database/tables/bios.py b/royalnet/packs/royal/tables/bios.py similarity index 96% rename from royalnet/database/tables/bios.py rename to royalnet/packs/royal/tables/bios.py index 2703095b..25a3a630 100644 --- a/royalnet/database/tables/bios.py +++ b/royalnet/packs/royal/tables/bios.py @@ -4,7 +4,6 @@ from sqlalchemy import Column, \ ForeignKey from sqlalchemy.orm import relationship, backref from sqlalchemy.ext.declarative import declared_attr -from .users import User class Bio: diff --git a/royalnet/database/tables/diario.py b/royalnet/packs/royal/tables/diario.py similarity index 97% rename from royalnet/database/tables/diario.py rename to royalnet/packs/royal/tables/diario.py index dc10fd83..1f133ef4 100644 --- a/royalnet/database/tables/diario.py +++ b/royalnet/packs/royal/tables/diario.py @@ -8,8 +8,6 @@ from sqlalchemy import Column, \ String from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declared_attr -# noinspection PyUnresolvedReferences -from .users import User class Diario: diff --git a/royalnet/database/tables/keygroups.py b/royalnet/packs/royal/tables/keygroups.py similarity index 100% rename from royalnet/database/tables/keygroups.py rename to royalnet/packs/royal/tables/keygroups.py diff --git a/royalnet/database/tables/keyvalues.py b/royalnet/packs/royal/tables/keyvalues.py similarity index 92% rename from royalnet/database/tables/keyvalues.py rename to royalnet/packs/royal/tables/keyvalues.py index 3dff850f..6d3565d8 100644 --- a/royalnet/database/tables/keyvalues.py +++ b/royalnet/packs/royal/tables/keyvalues.py @@ -3,8 +3,6 @@ from sqlalchemy import Column, \ ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declared_attr -# noinspection PyUnresolvedReferences -from .keygroups import Keygroup class Keyvalue: diff --git a/royalnet/database/tables/mmdecisions.py b/royalnet/packs/royal/tables/mmdecisions.py similarity index 94% rename from royalnet/database/tables/mmdecisions.py rename to royalnet/packs/royal/tables/mmdecisions.py index b67f32b7..08fd7cda 100644 --- a/royalnet/database/tables/mmdecisions.py +++ b/royalnet/packs/royal/tables/mmdecisions.py @@ -4,8 +4,6 @@ from sqlalchemy import Column, \ ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declared_attr -from .users import User -from .mmevents import MMEvent class MMDecision: diff --git a/royalnet/database/tables/mmevents.py b/royalnet/packs/royal/tables/mmevents.py similarity index 89% rename from royalnet/database/tables/mmevents.py rename to royalnet/packs/royal/tables/mmevents.py index 7d414a3b..a3ce00d5 100644 --- a/royalnet/database/tables/mmevents.py +++ b/royalnet/packs/royal/tables/mmevents.py @@ -1,5 +1,3 @@ -import telegram -import typing from sqlalchemy import Column, \ Integer, \ DateTime, \ @@ -9,10 +7,6 @@ from sqlalchemy import Column, \ BigInteger from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declared_attr -from .users import User -if typing.TYPE_CHECKING: - from .mmdecisions import MMDecision - from .mmresponse import MMResponse class MMEvent: diff --git a/royalnet/database/tables/mmresponse.py b/royalnet/packs/royal/tables/mmresponse.py similarity index 94% rename from royalnet/database/tables/mmresponse.py rename to royalnet/packs/royal/tables/mmresponse.py index dc119be8..afcf71af 100644 --- a/royalnet/database/tables/mmresponse.py +++ b/royalnet/packs/royal/tables/mmresponse.py @@ -4,8 +4,6 @@ from sqlalchemy import Column, \ ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declared_attr -from .users import User -from .mmevents import MMEvent class MMResponse: diff --git a/royalnet/database/tables/reminders.py b/royalnet/packs/royal/tables/reminders.py similarity index 94% rename from royalnet/database/tables/reminders.py rename to royalnet/packs/royal/tables/reminders.py index 4a983776..17f94302 100644 --- a/royalnet/database/tables/reminders.py +++ b/royalnet/packs/royal/tables/reminders.py @@ -6,8 +6,6 @@ from sqlalchemy import Column, \ ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declared_attr -# noinspection PyUnresolvedReferences -from .users import User class Reminder: diff --git a/royalnet/database/tables/triviascores.py b/royalnet/packs/royal/tables/triviascores.py similarity index 97% rename from royalnet/database/tables/triviascores.py rename to royalnet/packs/royal/tables/triviascores.py index f9a761b5..cbc9527b 100644 --- a/royalnet/database/tables/triviascores.py +++ b/royalnet/packs/royal/tables/triviascores.py @@ -3,7 +3,6 @@ from sqlalchemy import Column, \ ForeignKey from sqlalchemy.orm import relationship, backref from sqlalchemy.ext.declarative import declared_attr -from .users import User class TriviaScore: diff --git a/royalnet/database/tables/wikipages.py b/royalnet/packs/royal/tables/wikipages.py similarity index 100% rename from royalnet/database/tables/wikipages.py rename to royalnet/packs/royal/tables/wikipages.py diff --git a/royalnet/database/tables/wikirevisions.py b/royalnet/packs/royal/tables/wikirevisions.py similarity index 90% rename from royalnet/database/tables/wikirevisions.py rename to royalnet/packs/royal/tables/wikirevisions.py index fd21b55c..456376d7 100644 --- a/royalnet/database/tables/wikirevisions.py +++ b/royalnet/packs/royal/tables/wikirevisions.py @@ -6,10 +6,6 @@ from sqlalchemy import Column, \ from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declared_attr -# noinspection PyUnresolvedReferences -from .wikipages import WikiPage -# noinspection PyUnresolvedReferences -from .users import User class WikiRevision: diff --git a/royalnet/web/templates/base.html b/royalnet/web/templates/base.html index 400e1a12..a0cb9577 100644 --- a/royalnet/web/templates/base.html +++ b/royalnet/web/templates/base.html @@ -41,14 +41,14 @@ {% if session["royal"]["avatar"] %} {% else %} - + {% endif %} {% else %} {% endif %}