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],
|
def run(telegram: typing.Optional[bool],
|
||||||
discord: typing.Optional[bool],
|
discord: typing.Optional[bool],
|
||||||
database: typing.Optional[str],
|
database: typing.Optional[str],
|
||||||
packs: typing.List[str],
|
packs: typing.Tuple[str],
|
||||||
network_address: typing.Optional[str],
|
network_address: typing.Optional[str],
|
||||||
local_network_server: bool,
|
local_network_server: bool,
|
||||||
secrets_name: str,
|
secrets_name: str,
|
||||||
|
@ -88,12 +88,13 @@ def run(telegram: typing.Optional[bool],
|
||||||
"discord_id")
|
"discord_id")
|
||||||
|
|
||||||
# Import command packs
|
# Import command packs
|
||||||
|
packs: typing.List[str] = list(packs)
|
||||||
packs.append("royalnet.packs.common") # common pack is always imported
|
packs.append("royalnet.packs.common") # common pack is always imported
|
||||||
enabled_commands = []
|
enabled_commands = []
|
||||||
for pack in packs:
|
for pack in packs:
|
||||||
imported = importlib.import_module(pack)
|
imported = importlib.import_module(pack)
|
||||||
try:
|
try:
|
||||||
imported_commands = imported.commands
|
imported_commands = imported.available_commands
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise click.ClickException(f"{pack} isn't a Royalnet Pack.")
|
raise click.ClickException(f"{pack} isn't a Royalnet Pack.")
|
||||||
enabled_commands = [*enabled_commands, *imported_commands]
|
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 sentry_sdk.integrations.logging import LoggingIntegration
|
||||||
from ..utils import *
|
from ..utils import *
|
||||||
from ..database import *
|
from ..database import *
|
||||||
from ..packs import *
|
from ..commands import *
|
||||||
from ..error import *
|
from ..error import *
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ class GenericBot:
|
||||||
log.info(f"Database: enabled")
|
log.info(f"Database: enabled")
|
||||||
required_tables = {self.uninitialized_database_config.master_table, self.uninitialized_database_config.identity_table}
|
required_tables = {self.uninitialized_database_config.master_table, self.uninitialized_database_config.identity_table}
|
||||||
for command in self.uninitialized_commands:
|
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])}")
|
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.alchemy = Alchemy(self.uninitialized_database_config.database_uri, required_tables)
|
||||||
self.master_table = self.alchemy.__getattribute__(self.uninitialized_database_config.master_table.__name__)
|
self.master_table = self.alchemy.__getattribute__(self.uninitialized_database_config.master_table.__name__)
|
||||||
|
|
|
@ -9,7 +9,7 @@ import warnings
|
||||||
from .generic import GenericBot
|
from .generic import GenericBot
|
||||||
from ..utils import *
|
from ..utils import *
|
||||||
from ..error import *
|
from ..error import *
|
||||||
from ..packs import *
|
from ..commands import *
|
||||||
|
|
||||||
|
|
||||||
log = _logging.getLogger(__name__)
|
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!
|
# This is a template Pack __init__. You can use this without changing anything in other packages too!
|
||||||
|
|
||||||
from .commands import commands
|
from . import commands, tables
|
||||||
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 @@
|
||||||
from .ping import PingCommand
|
from .ping import PingCommand
|
||||||
|
|
||||||
# Enter the commands of your Pack here!
|
# Enter the commands of your Pack here!
|
||||||
commands = [
|
available_commands = [
|
||||||
PingCommand,
|
PingCommand,
|
||||||
]
|
]
|
||||||
|
|
||||||
# Don't change this, it should automatically generate __all__
|
# 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
|
from .discord import Discord
|
||||||
|
|
||||||
# Enter the tables of your Pack here!
|
# Enter the tables of your Pack here!
|
||||||
tables = [
|
available_tables = [
|
||||||
User,
|
User,
|
||||||
Telegram,
|
Telegram,
|
||||||
Discord
|
Discord
|
||||||
]
|
]
|
||||||
|
|
||||||
# Don't change this, it should automatically generate __all__
|
# 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!
|
# This is a template Pack __init__. You can use this without changing anything in other packages too!
|
||||||
|
|
||||||
from .commands import commands
|
from .commands import available_commands
|
||||||
from .tables import tables
|
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!
|
# Enter the commands of your Pack here!
|
||||||
commands = [
|
available_commands = [
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Don't change this, it should automatically generate __all__
|
# 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!
|
# Enter the tables of your Pack here!
|
||||||
tables = [
|
available_tables = [
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Don't change this, it should automatically generate __all__
|
# 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!
|
# This is a template Pack __init__. You can use this without changing anything in other packages too!
|
||||||
|
|
||||||
from .commands import commands
|
from .commands import available_commands
|
||||||
from .tables import tables
|
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
|
from .zawarudo import ZawarudoCommand
|
||||||
|
|
||||||
# Enter the commands of your Pack here!
|
# Enter the commands of your Pack here!
|
||||||
commands = [
|
available_commands = [
|
||||||
CiaoruoziCommand,
|
CiaoruoziCommand,
|
||||||
ColorCommand,
|
ColorCommand,
|
||||||
CvCommand,
|
CvCommand,
|
||||||
|
@ -49,4 +49,4 @@ commands = [
|
||||||
]
|
]
|
||||||
|
|
||||||
# Don't change this, it should automatically generate __all__
|
# 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 pickle
|
||||||
import discord
|
import discord
|
||||||
from royalnet.commands import *
|
from royalnet.commands import *
|
||||||
from ...utils import NetworkHandler, numberemojiformat
|
from royalnet.utils import NetworkHandler, numberemojiformat
|
||||||
from ...network import Request, ResponseSuccess
|
from royalnet.bots import DiscordBot
|
||||||
from ..commanderrors import CommandError
|
from royalherald import Request, ResponseSuccess
|
||||||
if typing.TYPE_CHECKING:
|
|
||||||
from ...bots import DiscordBot
|
|
||||||
|
|
||||||
|
|
||||||
class QueueNH(NetworkHandler):
|
class QueueNH(NetworkHandler):
|
||||||
|
|
|
@ -6,9 +6,9 @@ import telegram
|
||||||
import discord
|
import discord
|
||||||
from sqlalchemy import and_
|
from sqlalchemy import and_
|
||||||
from royalnet.commands import *
|
from royalnet.commands import *
|
||||||
from ...utils import sleep_until, asyncify, telegram_escape, discord_escape
|
from royalnet.utils import sleep_until, asyncify, telegram_escape, discord_escape
|
||||||
from ...database.tables import Reminder
|
from ..tables import Reminder
|
||||||
from ..commanderrors import InvalidInputError, UnsupportedError
|
|
||||||
|
|
||||||
class ReminderCommand(Command):
|
class ReminderCommand(Command):
|
||||||
name: str = "reminder"
|
name: str = "reminder"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import typing
|
import typing
|
||||||
import re
|
import re
|
||||||
from royalnet.commands import *
|
from royalnet.commands import *
|
||||||
from ...utils import safeformat
|
from royalnet.utils import safeformat
|
||||||
|
|
||||||
|
|
||||||
class ShipCommand(Command):
|
class ShipCommand(Command):
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
import typing
|
import typing
|
||||||
import pickle
|
|
||||||
import discord
|
import discord
|
||||||
from royalnet.commands import *
|
from royalnet.commands import *
|
||||||
from ...utils import NetworkHandler, asyncify
|
from royalnet.utils import NetworkHandler
|
||||||
from ...network import Request, ResponseSuccess
|
from royalnet.bots import DiscordBot
|
||||||
from ..commanderrors import CommandError
|
from royalherald import Request, ResponseSuccess
|
||||||
from ...audio import YtdlDiscord
|
|
||||||
if typing.TYPE_CHECKING:
|
|
||||||
from ...bots import DiscordBot
|
|
||||||
|
|
||||||
|
|
||||||
class SkipNH(NetworkHandler):
|
class SkipNH(NetworkHandler):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import typing
|
import typing
|
||||||
import random
|
import random
|
||||||
from royalnet.commands import *
|
from royalnet.commands import *
|
||||||
from ...utils import safeformat
|
from royalnet.utils import safeformat
|
||||||
|
|
||||||
|
|
||||||
class SmecdsCommand(Command):
|
class SmecdsCommand(Command):
|
||||||
|
|
|
@ -3,12 +3,10 @@ import pickle
|
||||||
import datetime
|
import datetime
|
||||||
import discord
|
import discord
|
||||||
from royalnet.commands import *
|
from royalnet.commands import *
|
||||||
from ...utils import NetworkHandler, asyncify
|
from royalnet.utils import NetworkHandler, asyncify
|
||||||
from ...network import Request, ResponseSuccess
|
from royalnet.audio import YtdlDiscord
|
||||||
from ...audio import YtdlDiscord
|
from royalnet.bots import DiscordBot
|
||||||
|
from royalherald import Request, ResponseSuccess
|
||||||
if typing.TYPE_CHECKING:
|
|
||||||
from ...bots import DiscordBot
|
|
||||||
|
|
||||||
|
|
||||||
class SoundcloudNH(NetworkHandler):
|
class SoundcloudNH(NetworkHandler):
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import typing
|
import typing
|
||||||
import discord
|
import discord
|
||||||
from royalnet.commands import *
|
from royalnet.commands import *
|
||||||
from ...utils import NetworkHandler
|
from royalnet.utils import NetworkHandler
|
||||||
from ...network import Request, ResponseSuccess
|
from royalnet.bots import DiscordBot
|
||||||
from ..commanderrors import CommandError
|
from royalherald import Request, ResponseSuccess
|
||||||
if typing.TYPE_CHECKING:
|
|
||||||
from ...bots import DiscordBot
|
|
||||||
|
|
||||||
|
|
||||||
class SummonNH(NetworkHandler):
|
class SummonNH(NetworkHandler):
|
||||||
|
|
|
@ -5,9 +5,8 @@ import random
|
||||||
import uuid
|
import uuid
|
||||||
import html
|
import html
|
||||||
from royalnet.commands import *
|
from royalnet.commands import *
|
||||||
from ...utils import asyncify
|
from royalnet.utils import asyncify
|
||||||
from ..commanderrors import CommandError, KeyboardExpiredError
|
from ..tables import TriviaScore
|
||||||
from ...database.tables import TriviaScore
|
|
||||||
|
|
||||||
|
|
||||||
class TriviaCommand(Command):
|
class TriviaCommand(Command):
|
||||||
|
|
|
@ -3,11 +3,10 @@ import pickle
|
||||||
import datetime
|
import datetime
|
||||||
import discord
|
import discord
|
||||||
from royalnet.commands import *
|
from royalnet.commands import *
|
||||||
from ...utils import NetworkHandler, asyncify
|
from royalnet.utils import NetworkHandler, asyncify
|
||||||
from ...network import Request, ResponseSuccess
|
from royalnet.audio import YtdlDiscord
|
||||||
from ...audio import YtdlDiscord
|
from royalnet.bots import DiscordBot
|
||||||
if typing.TYPE_CHECKING:
|
from royalherald import Request, ResponseSuccess
|
||||||
from ...bots import DiscordBot
|
|
||||||
|
|
||||||
|
|
||||||
class YoutubeNH(NetworkHandler):
|
class YoutubeNH(NetworkHandler):
|
||||||
|
|
|
@ -3,12 +3,11 @@ import discord
|
||||||
import asyncio
|
import asyncio
|
||||||
import datetime
|
import datetime
|
||||||
from royalnet.commands import *
|
from royalnet.commands import *
|
||||||
from ...utils import NetworkHandler, asyncify
|
from royalnet.utils import NetworkHandler, asyncify
|
||||||
from ...network import Request, ResponseSuccess
|
from royalnet.audio import YtdlDiscord
|
||||||
from ...audio import YtdlDiscord
|
from royalnet.audio.playmodes import Playlist
|
||||||
from ...audio.playmodes import Playlist
|
from royalnet.bots import DiscordBot
|
||||||
if typing.TYPE_CHECKING:
|
from royalherald import Request, ResponseSuccess
|
||||||
from ...bots import DiscordBot
|
|
||||||
|
|
||||||
|
|
||||||
class ZawarudoNH(NetworkHandler):
|
class ZawarudoNH(NetworkHandler):
|
||||||
|
|
|
@ -18,7 +18,7 @@ from .mmevents import MMEvent
|
||||||
from .mmresponse import MMResponse
|
from .mmresponse import MMResponse
|
||||||
|
|
||||||
# Enter the tables of your Pack here!
|
# Enter the tables of your Pack here!
|
||||||
tables = [
|
available_tables = [
|
||||||
User,
|
User,
|
||||||
Telegram,
|
Telegram,
|
||||||
Discord,
|
Discord,
|
||||||
|
@ -38,4 +38,4 @@ tables = [
|
||||||
]
|
]
|
||||||
|
|
||||||
# Don't change this, it should automatically generate __all__
|
# 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