From a781aaa41d174b3a9af6ef4d01c1d7d93e016dd2 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 14 Jul 2022 16:32:46 +0200 Subject: [PATCH] Added project structure --- .gitignore | 6 ++++ LICENSE | 0 README.md | 3 -- appsettings.json | 15 ++++++++++ cpl-workspace.json | 13 ++++++++ src/bot/__init__.py | 1 + src/bot/application.py | 16 ++++++++++ src/bot/appsettings.json | 15 ++++++++++ src/bot/bot.json | 48 ++++++++++++++++++++++++++++++ src/bot/main.py | 18 +++++++++++ src/bot/startup.py | 16 ++++++++++ src/bot_commands/__init__.py | 1 + src/bot_commands/bot-commands.json | 46 ++++++++++++++++++++++++++++ src/bot_core/__init__.py | 1 + src/bot_core/bot-core.json | 46 ++++++++++++++++++++++++++++ src/bot_data/__init__.py | 1 + src/bot_data/bot-data.json | 46 ++++++++++++++++++++++++++++ src/bot_events/__init__.py | 1 + src/bot_events/bot-events.json | 46 ++++++++++++++++++++++++++++ 19 files changed, 336 insertions(+), 3 deletions(-) create mode 100644 LICENSE create mode 100644 appsettings.json create mode 100644 cpl-workspace.json create mode 100644 src/bot/__init__.py create mode 100644 src/bot/application.py create mode 100644 src/bot/appsettings.json create mode 100644 src/bot/bot.json create mode 100644 src/bot/main.py create mode 100644 src/bot/startup.py create mode 100644 src/bot_commands/__init__.py create mode 100644 src/bot_commands/bot-commands.json create mode 100644 src/bot_core/__init__.py create mode 100644 src/bot_core/bot-core.json create mode 100644 src/bot_data/__init__.py create mode 100644 src/bot_data/bot-data.json create mode 100644 src/bot_events/__init__.py create mode 100644 src/bot_events/bot-events.json diff --git a/.gitignore b/.gitignore index f8b73e7a..23fa008e 100644 --- a/.gitignore +++ b/.gitignore @@ -138,3 +138,9 @@ dmypy.json # Cython debug symbols cython_debug/ +# custom vs code +PythonImportHelper-v2-Completion.json +appsettings.*.json + +# idea +.idea/ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..e69de29b diff --git a/README.md b/README.md index da28f04e..e69de29b 100644 --- a/README.md +++ b/README.md @@ -1,3 +0,0 @@ -# kd_discord_bot - -Discord moderation Bot for the Keksdose discord server. \ No newline at end of file diff --git a/appsettings.json b/appsettings.json new file mode 100644 index 00000000..629e6ebd --- /dev/null +++ b/appsettings.json @@ -0,0 +1,15 @@ +{ + "TimeFormatSettings": { + "DateFormat": "%Y-%m-%d", + "TimeFormat": "%H:%M:%S", + "DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f", + "DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S" + }, + + "LoggingSettings": { + "Path": "logs/", + "Filename": "log_$start_time.log", + "ConsoleLogLevel": "ERROR", + "FileLogLevel": "WARN" + } +} diff --git a/cpl-workspace.json b/cpl-workspace.json new file mode 100644 index 00000000..32428f91 --- /dev/null +++ b/cpl-workspace.json @@ -0,0 +1,13 @@ +{ + "WorkspaceSettings": { + "DefaultProject": "bot", + "Projects": { + "bot": "src/bot/bot.json", + "bot-commands": "src/bot_commands/bot-commands.json", + "bot-events": "src/bot_events/bot-events.json", + "bot-core": "src/bot_core/bot-core.json", + "bot-data": "src/bot_data/bot-data.json" + }, + "Scripts": {} + } +} \ No newline at end of file diff --git a/src/bot/__init__.py b/src/bot/__init__.py new file mode 100644 index 00000000..ad5eca30 --- /dev/null +++ b/src/bot/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/src/bot/application.py b/src/bot/application.py new file mode 100644 index 00000000..b2df0250 --- /dev/null +++ b/src/bot/application.py @@ -0,0 +1,16 @@ +from cpl_core.application import ApplicationABC +from cpl_core.configuration import ConfigurationABC +from cpl_core.console import Console +from cpl_core.dependency_injection import ServiceProviderABC + + +class Application(ApplicationABC): + + def __init__(self, config: ConfigurationABC, services: ServiceProviderABC): + ApplicationABC.__init__(self, config, services) + + async def configure(self): + pass + + async def main(self): + Console.write_line('Hello World') diff --git a/src/bot/appsettings.json b/src/bot/appsettings.json new file mode 100644 index 00000000..629e6ebd --- /dev/null +++ b/src/bot/appsettings.json @@ -0,0 +1,15 @@ +{ + "TimeFormatSettings": { + "DateFormat": "%Y-%m-%d", + "TimeFormat": "%H:%M:%S", + "DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f", + "DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S" + }, + + "LoggingSettings": { + "Path": "logs/", + "Filename": "log_$start_time.log", + "ConsoleLogLevel": "ERROR", + "FileLogLevel": "WARN" + } +} diff --git a/src/bot/bot.json b/src/bot/bot.json new file mode 100644 index 00000000..cb799bbc --- /dev/null +++ b/src/bot/bot.json @@ -0,0 +1,48 @@ +{ + "ProjectSettings": { + "Name": "bot", + "Version": { + "Major": "1", + "Minor": "0", + "Micro": "0.dev1" + }, + "Author": "Sven Heidemann", + "AuthorEmail": "sven.heidemann@sh-edraft.de", + "Description": "Keksdose bot", + "LongDescription": "Discord bot for the Keksdose discord Server", + "URL": "https://www.sh-edraft.de", + "CopyrightDate": "2022", + "CopyrightName": "sh-edraft.de", + "LicenseName": "MIT", + "LicenseDescription": "MIT, see LICENSE for more details.", + "Dependencies": [ + "cpl-core>=2022.7.0", + "cpl-translation==2022.7.0", + "cpl-query==2022.7.0" + ], + "DevDependencies": [ + "cpl-cli>=2022.7.0.post1" + ], + "PythonVersion": ">=3.10.4", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "console", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "bot.main", + "EntryPoint": "bot", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/src/bot/main.py b/src/bot/main.py new file mode 100644 index 00000000..16b8170b --- /dev/null +++ b/src/bot/main.py @@ -0,0 +1,18 @@ +import asyncio + +from cpl_core.application import ApplicationBuilder + +from bot.application import Application +from bot.startup import Startup + + +async def main(): + app_builder = ApplicationBuilder(Application) + app_builder.use_startup(Startup) + app: Application = await app_builder.build_async() + await app.run_async() + + +if __name__ == '__main__': + ml = asyncio.get_event_loop() + ml.run_until_complete(main()) diff --git a/src/bot/startup.py b/src/bot/startup.py new file mode 100644 index 00000000..dadaee3b --- /dev/null +++ b/src/bot/startup.py @@ -0,0 +1,16 @@ +from cpl_core.application import StartupABC +from cpl_core.configuration import ConfigurationABC +from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC +from cpl_core.environment import ApplicationEnvironment + + +class Startup(StartupABC): + + def __init__(self): + StartupABC.__init__(self) + + async def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC: + return configuration + + async def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC: + return services.build_service_provider() diff --git a/src/bot_commands/__init__.py b/src/bot_commands/__init__.py new file mode 100644 index 00000000..ad5eca30 --- /dev/null +++ b/src/bot_commands/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/src/bot_commands/bot-commands.json b/src/bot_commands/bot-commands.json new file mode 100644 index 00000000..021b62f1 --- /dev/null +++ b/src/bot_commands/bot-commands.json @@ -0,0 +1,46 @@ +{ + "ProjectSettings": { + "Name": "bot-commands", + "Version": { + "Major": "1", + "Minor": "0", + "Micro": "0.dev1" + }, + "Author": "Sven Heidemann", + "AuthorEmail": "sven.heidemann@sh-edraft.de", + "Description": "Keksdose bot - commands", + "LongDescription": "Discord bot for the Keksdose discord Server - command package", + "URL": "https://www.sh-edraft.de", + "CopyrightDate": "2022", + "CopyrightName": "sh-edraft.de", + "LicenseName": "MIT", + "LicenseDescription": "MIT, see LICENSE for more details.", + "Dependencies": [ + "cpl-core>=2022.7.0" + ], + "DevDependencies": [ + "cpl-cli>=2022.7.0" + ], + "PythonVersion": ">=3.10.4", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "console", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "", + "EntryPoint": "", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/src/bot_core/__init__.py b/src/bot_core/__init__.py new file mode 100644 index 00000000..ad5eca30 --- /dev/null +++ b/src/bot_core/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/src/bot_core/bot-core.json b/src/bot_core/bot-core.json new file mode 100644 index 00000000..93f908da --- /dev/null +++ b/src/bot_core/bot-core.json @@ -0,0 +1,46 @@ +{ + "ProjectSettings": { + "Name": "bot-core", + "Version": { + "Major": "1", + "Minor": "0", + "Micro": "0.dev1" + }, + "Author": "Sven Heidemann", + "AuthorEmail": "sven.heidemann@sh-edraft.de", + "Description": "Keksdose bot - core", + "LongDescription": "Discord bot for the Keksdose discord Server - core package", + "URL": "https://www.sh-edraft.de", + "CopyrightDate": "2022", + "CopyrightName": "sh-edraft.de", + "LicenseName": "MIT", + "LicenseDescription": "MIT, see LICENSE for more details.", + "Dependencies": [ + "cpl-core>=2022.7.0" + ], + "DevDependencies": [ + "cpl-cli>=2022.7.0" + ], + "PythonVersion": ">=3.10.4", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "console", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "", + "EntryPoint": "", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/src/bot_data/__init__.py b/src/bot_data/__init__.py new file mode 100644 index 00000000..ad5eca30 --- /dev/null +++ b/src/bot_data/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/src/bot_data/bot-data.json b/src/bot_data/bot-data.json new file mode 100644 index 00000000..0a328b86 --- /dev/null +++ b/src/bot_data/bot-data.json @@ -0,0 +1,46 @@ +{ + "ProjectSettings": { + "Name": "bot-data", + "Version": { + "Major": "1", + "Minor": "0", + "Micro": "0.dev1" + }, + "Author": "Sven Heidemann", + "AuthorEmail": "sven.heidemann@sh-edraft.de", + "Description": "Keksdose bot - data", + "LongDescription": "Discord bot for the Keksdose discord Server - database package", + "URL": "https://www.sh-edraft.de", + "CopyrightDate": "2022", + "CopyrightName": "sh-edraft.de", + "LicenseName": "MIT", + "LicenseDescription": "MIT, see LICENSE for more details.", + "Dependencies": [ + "cpl-core>=2022.7.0" + ], + "DevDependencies": [ + "cpl-cli>=2022.7.0.post1" + ], + "PythonVersion": ">=3.10.4", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "library", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "", + "EntryPoint": "", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/src/bot_events/__init__.py b/src/bot_events/__init__.py new file mode 100644 index 00000000..ad5eca30 --- /dev/null +++ b/src/bot_events/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/src/bot_events/bot-events.json b/src/bot_events/bot-events.json new file mode 100644 index 00000000..16d53d94 --- /dev/null +++ b/src/bot_events/bot-events.json @@ -0,0 +1,46 @@ +{ + "ProjectSettings": { + "Name": "bot-events", + "Version": { + "Major": "1", + "Minor": "0", + "Micro": "0.dev1" + }, + "Author": "Sven Heidemann", + "AuthorEmail": "sven.heidemann@sh-edraft.de", + "Description": "Keksdose bot - events", + "LongDescription": "Discord bot for the Keksdose discord Server - event package", + "URL": "https://www.sh-edraft.de", + "CopyrightDate": "2022", + "CopyrightName": "sh-edraft.de", + "LicenseName": "MIT", + "LicenseDescription": "MIT, see LICENSE for more details.", + "Dependencies": [ + "cpl-core>=2022.7.0" + ], + "DevDependencies": [ + "cpl-cli>=2022.7.0" + ], + "PythonVersion": ">=3.10.4", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "console", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "", + "EntryPoint": "", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file