mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
this works? somehow?
This commit is contained in:
parent
457926e351
commit
9d1b81d214
22 changed files with 57 additions and 68 deletions
|
@ -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]
|
||||
|
|
|
@ -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__)
|
||||
|
|
|
@ -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__)
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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"]
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import typing
|
||||
import re
|
||||
from royalnet.commands import *
|
||||
from ...utils import safeformat
|
||||
from royalnet.utils import safeformat
|
||||
|
||||
|
||||
class ShipCommand(Command):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import typing
|
||||
import random
|
||||
from royalnet.commands import *
|
||||
from ...utils import safeformat
|
||||
from royalnet.utils import safeformat
|
||||
|
||||
|
||||
class SmecdsCommand(Command):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue