From 90a517d2b19a8393dd764d940fec2ae15fa3c5bd Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 19 Jul 2022 11:58:33 +0200 Subject: [PATCH] Added restart command --- cpl-workspace.json | 16 +++--- src/bot/__init__.py | 4 +- src/bot/application.py | 3 ++ src/bot/bot.json | 6 ++- src/bot/config/appsettings.edrafts-lapi.json | 2 +- src/bot/main.py | 38 ++++++++++---- src/bot/startup_discord_extension.py | 7 ++- src/bot/translation/de.json | 4 ++ src/bot_core/__init__.py | 4 +- src/bot_core/abc/__init__.py | 4 +- src/bot_core/configuration/__init__.py | 4 +- src/bot_core/pipes/__init__.py | 4 +- src/bot_core/service/__init__.py | 4 +- src/bot_data/__init__.py | 4 +- src/bot_data/abc/__init__.py | 4 +- src/bot_data/migration/__init__.py | 4 +- src/bot_data/model/__init__.py | 4 +- src/bot_data/service/__init__.py | 4 +- src/modules/admin/__init__.py | 26 ++++++++++ src/modules/admin/admin.json | 46 ++++++++++++++++ src/modules/admin/command/__init__.py | 0 src/modules/admin/command/restart_command.py | 52 +++++++++++++++++++ src/modules/base/__init__.py | 4 +- src/modules/base/abc/__init__.py | 4 +- src/modules/base/command/__init__.py | 4 +- src/modules/base/command/afk_command.py | 8 --- src/modules/base/configuration/__init__.py | 4 +- src/modules/base/events/__init__.py | 4 +- src/modules/base/service/__init__.py | 4 +- src/modules/boot_log/__init__.py | 4 +- .../boot_log/configuration/__init__.py | 4 +- src/modules/database/__init__.py | 4 +- src/modules/moderator/__init__.py | 26 ++++++++++ src/modules/moderator/moderator.json | 46 ++++++++++++++++ src/modules/permission/__init__.py | 4 +- src/modules/permission/abc/__init__.py | 4 +- .../permission/configuration/__init__.py | 4 +- src/modules/permission/events/__init__.py | 4 +- src/modules/permission/service/__init__.py | 4 +- 39 files changed, 297 insertions(+), 83 deletions(-) create mode 100644 src/modules/admin/__init__.py create mode 100644 src/modules/admin/admin.json create mode 100644 src/modules/admin/command/__init__.py create mode 100644 src/modules/admin/command/restart_command.py create mode 100644 src/modules/moderator/__init__.py create mode 100644 src/modules/moderator/moderator.json diff --git a/cpl-workspace.json b/cpl-workspace.json index fff657b365..e2da15e5d3 100644 --- a/cpl-workspace.json +++ b/cpl-workspace.json @@ -5,21 +5,17 @@ "bot": "src/bot/bot.json", "bot-core": "src/bot_core/bot-core.json", "bot-data": "src/bot_data/bot-data.json", - "database": "src/modules/database/database.json", + "admin": "src/modules/admin/admin.json", "base": "src/modules/base/base.json", - "permission": "src/modules/permission/permission.json", - "boot-log": "src/modules/boot_log/boot-log.json" + "boot-log": "src/modules/boot_log/boot-log.json", + "database": "src/modules/database/database.json", + "moderator": "src/modules/moderator/moderator.json", + "permission": "src/modules/permission/permission.json" }, "Scripts": { "prod": "export KDB_ENVIRONMENT=production; export KDB_NAME=KDB-Prod; cpl start;", "stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-Stage; cpl start;", - "dev": "export KDB_ENVIRONMENT=development; export KDB_NAME=KDB-Dev; cpl start;", - - "ba": "cpl build-all", - "build-all": "cpl build-bot; cpl build-bot-core; cpl build-bot-data;", - "build-bot": "echo 'Build bot'; cd ./src/bot; cpl build; cd ../../;", - "build-bot-core": "echo 'Build bot-core'; cd ./src/bot_core; cpl build; cd ../../;", - "build-bot-data": "echo 'Build bot-data'; cd ./src/bot_data; cpl build; cd ../../;" + "dev": "export KDB_ENVIRONMENT=development; export KDB_NAME=KDB-Dev; cpl start;" } } } \ No newline at end of file diff --git a/src/bot/__init__.py b/src/bot/__init__.py index cb8e9bd044..dc049f8b46 100644 --- a/src/bot/__init__.py +++ b/src/bot/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/bot/application.py b/src/bot/application.py index 592d58c396..f2088027f3 100644 --- a/src/bot/application.py +++ b/src/bot/application.py @@ -66,3 +66,6 @@ class Application(DiscordBotApplicationABC): self._logger.error(__name__, 'stop failed', e) Console.write_line() + + def is_restart(self): + return True if self._configuration.get_configuration('IS_RESTART') == 'true' else False diff --git a/src/bot/bot.json b/src/bot/bot.json index b74a7adf6b..3c29a9bbec 100644 --- a/src/bot/bot.json +++ b/src/bot/bot.json @@ -4,7 +4,7 @@ "Version": { "Major": "1", "Minor": "0", - "Micro": "0.dev1" + "Micro": "0.dev2" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", @@ -50,7 +50,9 @@ "../modules/base/base.json", "../modules/boot_log/boot-log.json", "../modules/database/database.json", - "../modules/permission/permission.json" + "../modules/permission/permission.json", + "../modules/admin/admin.json", + "../modules/moderator/moderator.json" ] } } \ No newline at end of file diff --git a/src/bot/config/appsettings.edrafts-lapi.json b/src/bot/config/appsettings.edrafts-lapi.json index d774a73768..38c8258779 100644 --- a/src/bot/config/appsettings.edrafts-lapi.json +++ b/src/bot/config/appsettings.edrafts-lapi.json @@ -17,7 +17,7 @@ }, "DiscordBot": { "Token": "OTk4MTYwNDI3Njg5MTgxMjM3.GI7h67.BqD6Lu1Tz0MuG8iktYrcLnHi1pNozyMiWFGTKI", - "Prefix": "!kde " + "Prefix": "!ke " }, "Bot": { "910199451145076828": { diff --git a/src/bot/main.py b/src/bot/main.py index 6ab2b9db6c..c2e53cf069 100644 --- a/src/bot/main.py +++ b/src/bot/main.py @@ -2,6 +2,7 @@ import asyncio from typing import Optional from cpl_core.application import ApplicationBuilder +from cpl_core.console import Console from bot.application import Application from bot.startup import Startup @@ -11,31 +12,46 @@ from modules.boot_log.boot_log_extension import BootLogExtension from modules.database.database_extension import DatabaseExtension -class Main: +class Program: def __init__(self): - self._app: Optional[Application] = None + self.app: Optional[Application] = None - async def main(self): + async def start(self): app_builder = ApplicationBuilder(Application) app_builder.use_extension(StartupDiscordExtension) app_builder.use_extension(StartupMigrationExtension) app_builder.use_extension(BootLogExtension) app_builder.use_extension(DatabaseExtension) app_builder.use_startup(Startup) - self._app: Application = await app_builder.build_async() - await self._app.run_async() + self.app: Application = await app_builder.build_async() + await self.app.run_async() async def stop(self): - await self._app.stop_async() + await self.app.stop_async() + + +def main(): + program = Program() + try: + asyncio.run(program.start()) + except KeyboardInterrupt: + asyncio.run(program.stop()) + except Exception as e: + Console.error(f'[ ERROR ] [ {__name__} ]: Cannot start the bot', str(e)) + finally: + try: + asyncio.run(program.stop()) + except Exception as e: + Console.error(f'[ ERROR ] [ {__name__} ]: Cannot stop the bot', str(e)) + + if program.app is not None and program.app.is_restart(): + del program + main() if __name__ == '__main__': - main = Main() - try: - asyncio.run(main.main()) - except KeyboardInterrupt: - asyncio.run(main.stop()) + main() # (( # ( `) diff --git a/src/bot/startup_discord_extension.py b/src/bot/startup_discord_extension.py index 84a895dbf7..25884bba61 100644 --- a/src/bot/startup_discord_extension.py +++ b/src/bot/startup_discord_extension.py @@ -5,6 +5,7 @@ from cpl_core.environment import ApplicationEnvironmentABC from cpl_discord import get_discord_collection from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum +from modules.admin.command.restart_command import RestartCommand from modules.base.command.afk_command import AFKCommand from modules.base.command.help_command import HelpCommand from modules.base.command.info_command import InfoCommand @@ -33,11 +34,15 @@ class StartupDiscordExtension(StartupExtensionABC): services.add_discord() dc = get_discord_collection(services) """ commands """ + # admin + dc.add_command(RestartCommand) + # moderator + dc.add_command(PurgeCommand) + # simple dc.add_command(AFKCommand) dc.add_command(HelpCommand) dc.add_command(InfoCommand) dc.add_command(PingCommand) - dc.add_command(PurgeCommand) dc.add_command(UserInfoCommand) """ events """ # on_member_join diff --git a/src/bot/translation/de.json b/src/bot/translation/de.json index f0f8ec7c9f..dbf7880a02 100644 --- a/src/bot/translation/de.json +++ b/src/bot/translation/de.json @@ -6,6 +6,10 @@ "not_implemented_yet": "Ey Alter, das kann ich noch nicht..." }, "modules": { + "admin": { + "restart_message": "Bin gleich wieder da :D" + }, + "moderator": {}, "base": { "welcome_message": "Hello There!\nIch heiße dich bei {} herzlichst willkommen!", "welcome_message_for_team": "{} hat gerade das Irrenhaus betreten.", diff --git a/src/bot_core/__init__.py b/src/bot_core/__init__.py index 72c0622f40..a00b8a64b5 100644 --- a/src/bot_core/__init__.py +++ b/src/bot_core/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/bot_core/abc/__init__.py b/src/bot_core/abc/__init__.py index 27ad201312..a15e30c192 100644 --- a/src/bot_core/abc/__init__.py +++ b/src/bot_core/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/bot_core/configuration/__init__.py b/src/bot_core/configuration/__init__.py index 8776de6bf9..ef011752c0 100644 --- a/src/bot_core/configuration/__init__.py +++ b/src/bot_core/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/bot_core/pipes/__init__.py b/src/bot_core/pipes/__init__.py index d3090a0a23..adc0ffb5f1 100644 --- a/src/bot_core/pipes/__init__.py +++ b/src/bot_core/pipes/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.pipes' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/bot_core/service/__init__.py b/src/bot_core/service/__init__.py index 8dbab469c8..33fa6d8f72 100644 --- a/src/bot_core/service/__init__.py +++ b/src/bot_core/service/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_core.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/bot_data/__init__.py b/src/bot_data/__init__.py index d1a4442348..41632b0408 100644 --- a/src/bot_data/__init__.py +++ b/src/bot_data/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_data' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/bot_data/abc/__init__.py b/src/bot_data/abc/__init__.py index 6dcb307fe3..5a6b93c119 100644 --- a/src/bot_data/abc/__init__.py +++ b/src/bot_data/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_data.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/bot_data/migration/__init__.py b/src/bot_data/migration/__init__.py index bd72eb300c..3588521fda 100644 --- a/src/bot_data/migration/__init__.py +++ b/src/bot_data/migration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_data.migration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/bot_data/model/__init__.py b/src/bot_data/model/__init__.py index 05bb31b48e..07a8945c87 100644 --- a/src/bot_data/model/__init__.py +++ b/src/bot_data/model/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_data.model' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/bot_data/service/__init__.py b/src/bot_data/service/__init__.py index 953cb02db1..9bf9dcfd30 100644 --- a/src/bot_data/service/__init__.py +++ b/src/bot_data/service/__init__.py @@ -15,7 +15,7 @@ __title__ = 'bot_data.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/modules/admin/__init__.py b/src/modules/admin/__init__.py new file mode 100644 index 0000000000..cdee6cea5c --- /dev/null +++ b/src/modules/admin/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +""" +bot Keksdose bot +~~~~~~~~~~~~~~~~~~~ + +Discord bot for the Keksdose discord Server + +:copyright: (c) 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'modules.admin' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2022 sh-edraft.de' +__version__ = '1.0.0.dev2' + +from collections import namedtuple + + +# imports: + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/modules/admin/admin.json b/src/modules/admin/admin.json new file mode 100644 index 0000000000..6c2ac50b44 --- /dev/null +++ b/src/modules/admin/admin.json @@ -0,0 +1,46 @@ +{ + "ProjectSettings": { + "Name": "admin", + "Version": { + "Major": "0", + "Minor": "0", + "Micro": "0" + }, + "Author": "", + "AuthorEmail": "", + "Description": "", + "LongDescription": "", + "URL": "", + "CopyrightDate": "", + "CopyrightName": "", + "LicenseName": "", + "LicenseDescription": "", + "Dependencies": [ + "cpl-core>=2022.7.0.post5" + ], + "DevDependencies": [ + "cpl-cli>=2022.7.0.post2" + ], + "PythonVersion": ">=3.10.4", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "library", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "admin.main", + "EntryPoint": "admin", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/src/modules/admin/command/__init__.py b/src/modules/admin/command/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/modules/admin/command/restart_command.py b/src/modules/admin/command/restart_command.py new file mode 100644 index 0000000000..fc7da711a2 --- /dev/null +++ b/src/modules/admin/command/restart_command.py @@ -0,0 +1,52 @@ +from cpl_core.configuration import ConfigurationABC +from cpl_core.logging import LoggerABC +from cpl_discord.command import DiscordCommandABC +from cpl_discord.service import DiscordBotServiceABC +from cpl_translation import TranslatePipe +from discord.ext import commands +from discord.ext.commands import Context + +from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC +from bot_core.abc.message_service_abc import MessageServiceABC +from modules.permission.abc.permission_service_abc import PermissionServiceABC + + +class RestartCommand(DiscordCommandABC): + + def __init__( + self, + logger: LoggerABC, + config: ConfigurationABC, + message_service: MessageServiceABC, + bot: DiscordBotServiceABC, + client_utils: ClientUtilsServiceABC, + translate: TranslatePipe, + permissions: PermissionServiceABC, + ): + DiscordCommandABC.__init__(self) + + self._logger = logger + self._config = config + self._message_service = message_service + self._bot = bot + self._client_utils = client_utils + self._t = translate + self._permissions = permissions + + self._logger.trace(__name__, f'Loaded command service: {type(self).__name__}') + + @commands.command() + async def restart(self, ctx: Context): + self._logger.debug(__name__, f'Received command restart {ctx}') + self._client_utils.received_command(ctx.guild.id) + + if not self._permissions.is_member_moderator(ctx.author): + await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) + self._logger.trace(__name__, f'Finished restart command') + return + + self._config.add_configuration('IS_RESTART', 'true') + await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.admin.restart_message')) + await self._bot.logout() + + self._logger.trace(__name__, f'Finished restart command') diff --git a/src/modules/base/__init__.py b/src/modules/base/__init__.py index 3d69314303..07b9a59b4a 100644 --- a/src/modules/base/__init__.py +++ b/src/modules/base/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/modules/base/abc/__init__.py b/src/modules/base/abc/__init__.py index 697662c10c..a9ca4b434f 100644 --- a/src/modules/base/abc/__init__.py +++ b/src/modules/base/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/modules/base/command/__init__.py b/src/modules/base/command/__init__.py index ecf5e1dd61..fe78a1c15d 100644 --- a/src/modules/base/command/__init__.py +++ b/src/modules/base/command/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base.command' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/modules/base/command/afk_command.py b/src/modules/base/command/afk_command.py index 50f64fe623..1f954feb29 100644 --- a/src/modules/base/command/afk_command.py +++ b/src/modules/base/command/afk_command.py @@ -1,5 +1,4 @@ from cpl_core.configuration import ConfigurationABC -from cpl_core.database.context import DatabaseContext from cpl_core.logging import LoggerABC from cpl_discord.command import DiscordCommandABC from cpl_discord.service import DiscordBotServiceABC @@ -10,8 +9,6 @@ from discord.ext.commands import Context from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC from bot_core.abc.message_service_abc import MessageServiceABC -from bot_core.configuration.server_settings import ServerSettings -from bot_data.abc.client_repository_abc import ClientRepositoryABC from modules.base.configuration.base_server_settings import BaseServerSettings @@ -22,8 +19,6 @@ class AFKCommand(DiscordCommandABC): logger: LoggerABC, config: ConfigurationABC, message_service: MessageServiceABC, - clients: ClientRepositoryABC, - db: DatabaseContext, bot: DiscordBotServiceABC, client_utils: ClientUtilsServiceABC, translate: TranslatePipe @@ -33,8 +28,6 @@ class AFKCommand(DiscordCommandABC): self._logger = logger self._config = config self._message_service = message_service - self._clients = clients - self._db = db self._bot = bot self._client_utils = client_utils self._t = translate @@ -46,7 +39,6 @@ class AFKCommand(DiscordCommandABC): self._logger.debug(__name__, f'Received command afk {ctx}') self._client_utils.received_command(ctx.guild.id) settings: BaseServerSettings = self._config.get_configuration(f'BaseServerSettings_{ctx.guild.id}') - server_settings: ServerSettings = self._config.get_configuration(f'ServerSettings_{ctx.guild.id}') if ctx.author.voice is None or ctx.author.voice.channel is None: await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.base.afk_command_channel_missing_message')) diff --git a/src/modules/base/configuration/__init__.py b/src/modules/base/configuration/__init__.py index 13ac976602..7eb4bcc66c 100644 --- a/src/modules/base/configuration/__init__.py +++ b/src/modules/base/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/modules/base/events/__init__.py b/src/modules/base/events/__init__.py index 53a5534687..b8f3c17630 100644 --- a/src/modules/base/events/__init__.py +++ b/src/modules/base/events/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base.events' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/modules/base/service/__init__.py b/src/modules/base/service/__init__.py index 78813b23d4..60832dbc59 100644 --- a/src/modules/base/service/__init__.py +++ b/src/modules/base/service/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.base.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/modules/boot_log/__init__.py b/src/modules/boot_log/__init__.py index c841fbdb05..ba53aa594b 100644 --- a/src/modules/boot_log/__init__.py +++ b/src/modules/boot_log/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.boot_log' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/modules/boot_log/configuration/__init__.py b/src/modules/boot_log/configuration/__init__.py index 2b5dfd5cd1..66bbbd5345 100644 --- a/src/modules/boot_log/configuration/__init__.py +++ b/src/modules/boot_log/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.boot_log.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/modules/database/__init__.py b/src/modules/database/__init__.py index 8f0adeedad..10b92d1d29 100644 --- a/src/modules/database/__init__.py +++ b/src/modules/database/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.database' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/modules/moderator/__init__.py b/src/modules/moderator/__init__.py new file mode 100644 index 0000000000..19de191200 --- /dev/null +++ b/src/modules/moderator/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +""" +bot Keksdose bot +~~~~~~~~~~~~~~~~~~~ + +Discord bot for the Keksdose discord Server + +:copyright: (c) 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'modules.moderator' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2022 sh-edraft.de' +__version__ = '1.0.0.dev2' + +from collections import namedtuple + + +# imports: + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/modules/moderator/moderator.json b/src/modules/moderator/moderator.json new file mode 100644 index 0000000000..d4e025be46 --- /dev/null +++ b/src/modules/moderator/moderator.json @@ -0,0 +1,46 @@ +{ + "ProjectSettings": { + "Name": "moderator", + "Version": { + "Major": "0", + "Minor": "0", + "Micro": "0" + }, + "Author": "", + "AuthorEmail": "", + "Description": "", + "LongDescription": "", + "URL": "", + "CopyrightDate": "", + "CopyrightName": "", + "LicenseName": "", + "LicenseDescription": "", + "Dependencies": [ + "cpl-core>=2022.7.0.post5" + ], + "DevDependencies": [ + "cpl-cli>=2022.7.0.post2" + ], + "PythonVersion": ">=3.10.4", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "library", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "moderator.main", + "EntryPoint": "moderator", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/src/modules/permission/__init__.py b/src/modules/permission/__init__.py index 8265580146..8b3b97b740 100644 --- a/src/modules/permission/__init__.py +++ b/src/modules/permission/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.permission' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/modules/permission/abc/__init__.py b/src/modules/permission/abc/__init__.py index 92b648db29..56d527c1ef 100644 --- a/src/modules/permission/abc/__init__.py +++ b/src/modules/permission/abc/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.permission.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/modules/permission/configuration/__init__.py b/src/modules/permission/configuration/__init__.py index 95882d5e8a..d52d37d679 100644 --- a/src/modules/permission/configuration/__init__.py +++ b/src/modules/permission/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.permission.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/modules/permission/events/__init__.py b/src/modules/permission/events/__init__.py index ae9d73a2a0..2745be3cd5 100644 --- a/src/modules/permission/events/__init__.py +++ b/src/modules/permission/events/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.permission.events' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2') diff --git a/src/modules/permission/service/__init__.py b/src/modules/permission/service/__init__.py index 9bdc09adb2..ae3f6d5d9c 100644 --- a/src/modules/permission/service/__init__.py +++ b/src/modules/permission/service/__init__.py @@ -15,7 +15,7 @@ __title__ = 'modules.permission.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' -__version__ = '1.0.0.dev1' +__version__ = '1.0.0.dev2' from collections import namedtuple @@ -23,4 +23,4 @@ from collections import namedtuple # imports VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='1', minor='0', micro='0.dev1') +version_info = VersionInfo(major='1', minor='0', micro='0.dev2')