Added technician module #44
This commit is contained in:
@@ -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
|
||||
|
1
kdb-bot/src/modules/technician/__init__.py
Normal file
1
kdb-bot/src/modules/technician/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# imports:
|
0
kdb-bot/src/modules/technician/command/__init__.py
Normal file
0
kdb-bot/src/modules/technician/command/__init__.py
Normal file
@@ -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()
|
||||
|
@@ -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()
|
||||
|
46
kdb-bot/src/modules/technician/technician.json
Normal file
46
kdb-bot/src/modules/technician/technician.json
Normal file
@@ -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": []
|
||||
}
|
||||
}
|
27
kdb-bot/src/modules/technician/technician_module.py
Normal file
27
kdb-bot/src/modules/technician/technician_module.py
Normal file
@@ -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
|
Reference in New Issue
Block a user