diff --git a/kdb-bot/cpl-workspace.json b/kdb-bot/cpl-workspace.json index 6587cbf66d..ac1c4822fd 100644 --- a/kdb-bot/cpl-workspace.json +++ b/kdb-bot/cpl-workspace.json @@ -13,6 +13,7 @@ "level": "src/modules/level/level.json", "permission": "src/modules/permission/permission.json", "stats": "src/modules/stats/stats.json", + "technician": "src/modules/technician/technician.json", "get-version": "tools/get_version/get-version.json", "post-build": "tools/post_build/post-build.json", "set-version": "tools/set_version/set-version.json" @@ -20,10 +21,8 @@ "Scripts": { "sv": "cpl set-version", "set-version": "cpl run set-version $ARGS; echo '';", - "gv": "cpl get-version", "get-version": "export VERSION=$(cpl run get-version); echo $VERSION;", - "pre-build": "cpl set-version $ARGS", "post-build": "cpl run post-build", diff --git a/kdb-bot/src/bot/config b/kdb-bot/src/bot/config index bd8d3a5dad..7eeac4a343 160000 --- a/kdb-bot/src/bot/config +++ b/kdb-bot/src/bot/config @@ -1 +1 @@ -Subproject commit bd8d3a5dad13e0fdcad79b767c032997b716b1a4 +Subproject commit 7eeac4a343fcefb0aaff63a8fd28d35b46930f9a diff --git a/kdb-bot/src/bot/module_list.py b/kdb-bot/src/bot/module_list.py index 3eb60cd3e1..cde01ceead 100644 --- a/kdb-bot/src/bot/module_list.py +++ b/kdb-bot/src/bot/module_list.py @@ -11,6 +11,7 @@ from modules.database.database_module import DatabaseModule from modules.level.level_module import LevelModule from modules.permission.permission_module import PermissionModule from modules.stats.stats_module import StatsModule +from modules.technician.technician_module import TechnicianModule class ModuleList: @@ -28,6 +29,7 @@ class ModuleList: PermissionModule, ApiModule, StatsModule, + TechnicianModule, # has to be last! BootLogModule, CoreExtensionModule, diff --git a/kdb-bot/src/bot/translation/de.json b/kdb-bot/src/bot/translation/de.json index 5b67528961..986e5de0fd 100644 --- a/kdb-bot/src/bot/translation/de.json +++ b/kdb-bot/src/bot/translation/de.json @@ -72,11 +72,6 @@ } }, "modules": { - "admin": { - "restart_message": "Bin gleich wieder da :D", - "shutdown_message": "Trauert nicht um mich, es war eine logische Entscheidung. Das Wohl von Vielen, es wiegt schwerer als das Wohl von Wenigen oder eines Einzelnen. Ich war es und ich werde es immer sein, Euer Freund. Lebt lange und in Frieden :)", - "deploy_message": "Der neue Stand wurde hochgeladen." - }, "auto_role": { "list": { "title": "Beobachtete Nachrichten:", @@ -249,6 +244,10 @@ "failed": "Statistik kann nicht gelöscht werden :(", "success": "Statistik wurde gelöscht :D" } + }, + "technician": { + "restart_message": "Bin gleich wieder da :D", + "shutdown_message": "Trauert nicht um mich, es war eine logische Entscheidung. Das Wohl von Vielen, es wiegt schwerer als das Wohl von Wenigen oder eines Einzelnen. Ich war es und ich werde es immer sein, Euer Freund. Lebt lange und in Frieden :)" } }, "api": { diff --git a/kdb-bot/src/bot_api/config b/kdb-bot/src/bot_api/config index 98303ffd45..43a44b31f2 160000 --- a/kdb-bot/src/bot_api/config +++ b/kdb-bot/src/bot_api/config @@ -1 +1 @@ -Subproject commit 98303ffd45445eecfad57f8b1be86729de3661d2 +Subproject commit 43a44b31f2efc644baadbf830b6414bab085fdea diff --git a/kdb-bot/src/modules/base/base_module.py b/kdb-bot/src/modules/base/base_module.py index 8da27656a9..cacde84ba7 100644 --- a/kdb-bot/src/modules/base/base_module.py +++ b/kdb-bot/src/modules/base/base_module.py @@ -12,8 +12,6 @@ from modules.base.command.help_command import HelpCommand from modules.base.command.info_command import InfoCommand from modules.base.command.ping_command import PingCommand from modules.base.command.purge_command import PurgeCommand -from modules.base.command.restart_command import RestartCommand -from modules.base.command.shutdown_command import ShutdownCommand from modules.base.command.user_group import UserGroup from modules.base.events.base_on_command_error_event import BaseOnCommandErrorEvent from modules.base.events.base_on_command_event import BaseOnCommandEvent @@ -41,8 +39,6 @@ class BaseModule(ModuleABC): self._dc.add_command(InfoCommand) self._dc.add_command(PingCommand) - self._dc.add_command(RestartCommand) - self._dc.add_command(ShutdownCommand) self._dc.add_command(PurgeCommand) self._dc.add_command(UserGroup) # events diff --git a/kdb-bot/src/modules/technician/__init__.py b/kdb-bot/src/modules/technician/__init__.py new file mode 100644 index 0000000000..ad5eca3064 --- /dev/null +++ b/kdb-bot/src/modules/technician/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/kdb-bot/src/modules/technician/command/__init__.py b/kdb-bot/src/modules/technician/command/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/kdb-bot/src/modules/base/command/restart_command.py b/kdb-bot/src/modules/technician/command/restart_command.py similarity index 95% rename from kdb-bot/src/modules/base/command/restart_command.py rename to kdb-bot/src/modules/technician/command/restart_command.py index c1fd3ae59a..0a14e41b16 100644 --- a/kdb-bot/src/modules/base/command/restart_command.py +++ b/kdb-bot/src/modules/technician/command/restart_command.py @@ -44,13 +44,13 @@ class RestartCommand(DiscordCommandABC): @commands.hybrid_command() @commands.guild_only() @CommandChecks.check_is_ready() - @CommandChecks.check_is_member_moderator() + @CommandChecks.check_is_member_technician() async def restart(self, ctx: Context): self._logger.debug(__name__, f'Received command restart {ctx}') self._config.add_configuration('IS_RESTART', 'true') await self._client_utils.presence_game('common.presence.restart') - await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.admin.restart_message')) + await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.technician.restart_message')) await asyncio.sleep(self._settings.wait_for_restart) await self._bot.stop_async() diff --git a/kdb-bot/src/modules/base/command/shutdown_command.py b/kdb-bot/src/modules/technician/command/shutdown_command.py similarity index 95% rename from kdb-bot/src/modules/base/command/shutdown_command.py rename to kdb-bot/src/modules/technician/command/shutdown_command.py index f8ebce5d05..f81d127af6 100644 --- a/kdb-bot/src/modules/base/command/shutdown_command.py +++ b/kdb-bot/src/modules/technician/command/shutdown_command.py @@ -45,12 +45,12 @@ class ShutdownCommand(DiscordCommandABC): @commands.hybrid_command() @commands.guild_only() @CommandChecks.check_is_ready() - @CommandChecks.check_is_member_moderator() + @CommandChecks.check_is_member_technician() async def shutdown(self, ctx: Context): self._logger.debug(__name__, f'Received command shutdown {ctx}') await self._client_utils.presence_game('common.presence.shutdown') - await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.admin.shutdown_message')) + await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.technician.shutdown_message')) await asyncio.sleep(self._settings.wait_for_shutdown) await self._bot.stop_async() diff --git a/kdb-bot/src/modules/technician/technician.json b/kdb-bot/src/modules/technician/technician.json new file mode 100644 index 0000000000..a1a3340e59 --- /dev/null +++ b/kdb-bot/src/modules/technician/technician.json @@ -0,0 +1,46 @@ +{ + "ProjectSettings": { + "Name": "technician", + "Version": { + "Major": "0", + "Minor": "0", + "Micro": "0" + }, + "Author": "", + "AuthorEmail": "", + "Description": "", + "LongDescription": "", + "URL": "", + "CopyrightDate": "", + "CopyrightName": "", + "LicenseName": "", + "LicenseDescription": "", + "Dependencies": [ + "cpl-core>=2022.10.0.post7" + ], + "DevDependencies": [ + "cpl-cli>=2022.10.0" + ], + "PythonVersion": ">=3.10.6", + "PythonPath": { + "win32": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "library", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "technician.main", + "EntryPoint": "technician", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/kdb-bot/src/modules/technician/technician_module.py b/kdb-bot/src/modules/technician/technician_module.py new file mode 100644 index 0000000000..089e36de65 --- /dev/null +++ b/kdb-bot/src/modules/technician/technician_module.py @@ -0,0 +1,27 @@ +from cpl_core.configuration import ConfigurationABC +from cpl_core.dependency_injection import ServiceCollectionABC +from cpl_core.environment import ApplicationEnvironmentABC +from cpl_discord.service.discord_collection_abc import DiscordCollectionABC + +from bot_core.abc.module_abc import ModuleABC +from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum +from modules.base.abc.base_helper_abc import BaseHelperABC +from modules.technician.command.restart_command import RestartCommand +from modules.technician.command.shutdown_command import ShutdownCommand +from modules.base.service.base_helper_service import BaseHelperService + + +class TechnicianModule(ModuleABC): + + def __init__(self, dc: DiscordCollectionABC): + ModuleABC.__init__(self, dc, FeatureFlagsEnum.base_module) + + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC): + pass + + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): + services.add_transient(BaseHelperABC, BaseHelperService) + # commands + self._dc.add_command(RestartCommand) + self._dc.add_command(ShutdownCommand) + # events