From 24ae39d9f6fd8a34e66d053b67189c0f4eae2842 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 00:52:49 +0100 Subject: [PATCH 001/113] Added first projects --- cpl-workspace.json | 13 ++++++++ src/gismo/__init__.py | 1 + src/gismo/application.py | 16 ++++++++++ src/gismo/appsettings.json | 15 ++++++++++ src/gismo/gismo.json | 48 ++++++++++++++++++++++++++++++ src/gismo/main.py | 18 +++++++++++ src/gismo/startup.py | 16 ++++++++++ src/gismo_cli/__init__.py | 1 + src/gismo_cli/application.py | 16 ++++++++++ src/gismo_cli/appsettings.json | 15 ++++++++++ src/gismo_cli/gismo-cli.json | 48 ++++++++++++++++++++++++++++++ src/gismo_cli/main.py | 18 +++++++++++ src/gismo_cli/startup.py | 16 ++++++++++ src/gismo_core/__init__.py | 1 + src/gismo_core/gismo-core.json | 43 ++++++++++++++++++++++++++ src/modules_core/LICENSE | 0 src/modules_core/README.md | 0 src/modules_core/__init__.py | 1 + src/modules_core/appsettings.json | 15 ++++++++++ src/modules_core/main.py | 9 ++++++ src/modules_core/modules_core.json | 43 ++++++++++++++++++++++++++ 21 files changed, 353 insertions(+) create mode 100644 cpl-workspace.json create mode 100644 src/gismo/__init__.py create mode 100644 src/gismo/application.py create mode 100644 src/gismo/appsettings.json create mode 100644 src/gismo/gismo.json create mode 100644 src/gismo/main.py create mode 100644 src/gismo/startup.py create mode 100644 src/gismo_cli/__init__.py create mode 100644 src/gismo_cli/application.py create mode 100644 src/gismo_cli/appsettings.json create mode 100644 src/gismo_cli/gismo-cli.json create mode 100644 src/gismo_cli/main.py create mode 100644 src/gismo_cli/startup.py create mode 100644 src/gismo_core/__init__.py create mode 100644 src/gismo_core/gismo-core.json create mode 100644 src/modules_core/LICENSE create mode 100644 src/modules_core/README.md create mode 100644 src/modules_core/__init__.py create mode 100644 src/modules_core/appsettings.json create mode 100644 src/modules_core/main.py create mode 100644 src/modules_core/modules_core.json diff --git a/cpl-workspace.json b/cpl-workspace.json new file mode 100644 index 0000000..cf21a2c --- /dev/null +++ b/cpl-workspace.json @@ -0,0 +1,13 @@ +{ + "WorkspaceSettings": { + "DefaultProject": "gismo", + "Projects": { + "gismo": "src/gismo/gismo.json", + "gismo-cli": "src/gismo_cli/gismo-cli.json", + "gismo-core": "src/gismo_core/gismo-core.json", + "modules_core": "src/modules_core/modules_core.json", + "boot-log": "src/modules/boot_log/boot-log.json" + }, + "Scripts": {} + } +} \ No newline at end of file diff --git a/src/gismo/__init__.py b/src/gismo/__init__.py new file mode 100644 index 0000000..ad5eca3 --- /dev/null +++ b/src/gismo/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/src/gismo/application.py b/src/gismo/application.py new file mode 100644 index 0000000..b2df025 --- /dev/null +++ b/src/gismo/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/gismo/appsettings.json b/src/gismo/appsettings.json new file mode 100644 index 0000000..629e6eb --- /dev/null +++ b/src/gismo/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/gismo/gismo.json b/src/gismo/gismo.json new file mode 100644 index 0000000..a3a8bb0 --- /dev/null +++ b/src/gismo/gismo.json @@ -0,0 +1,48 @@ +{ + "ProjectSettings": { + "Name": "gismo", + "Version": { + "Major": "0", + "Minor": "1", + "Micro": "0" + }, + "Author": "Sven Heidemann", + "AuthorEmail": "sven.heidemann@sh-edraft.de", + "Description": "sh-edraft Gismo", + "LongDescription": "sh-edraft Dicord bot Gismo", + "URL": "https://www.sh-edraft.de", + "CopyrightDate": "2021 - 2022", + "CopyrightName": "sh-edraft.de", + "LicenseName": "MIT", + "LicenseDescription": "MIT, see LICENSE for more details.", + "Dependencies": [ + "sh_cpl-core>=2021.10.2", + "sh_cpl-query>=2021.10.2" + ], + "PythonVersion": ">=3.9.2", + "PythonPath": { + "linux": "../../venv/bin/python" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "console", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "gismo.main", + "EntryPoint": "gismo", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": { + "cpl_cli": [ + "*.json" + ] + }, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/src/gismo/main.py b/src/gismo/main.py new file mode 100644 index 0000000..4311d0e --- /dev/null +++ b/src/gismo/main.py @@ -0,0 +1,18 @@ +import asyncio + +from cpl_core.application import ApplicationBuilder + +from gismo.application import Application +from gismo.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/gismo/startup.py b/src/gismo/startup.py new file mode 100644 index 0000000..dadaee3 --- /dev/null +++ b/src/gismo/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/gismo_cli/__init__.py b/src/gismo_cli/__init__.py new file mode 100644 index 0000000..ad5eca3 --- /dev/null +++ b/src/gismo_cli/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/src/gismo_cli/application.py b/src/gismo_cli/application.py new file mode 100644 index 0000000..b2df025 --- /dev/null +++ b/src/gismo_cli/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/gismo_cli/appsettings.json b/src/gismo_cli/appsettings.json new file mode 100644 index 0000000..629e6eb --- /dev/null +++ b/src/gismo_cli/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/gismo_cli/gismo-cli.json b/src/gismo_cli/gismo-cli.json new file mode 100644 index 0000000..37fc9ce --- /dev/null +++ b/src/gismo_cli/gismo-cli.json @@ -0,0 +1,48 @@ +{ + "ProjectSettings": { + "Name": "gismo-cli", + "Version": { + "Major": "0", + "Minor": "1", + "Micro": "0" + }, + "Author": "Sven Heidemann", + "AuthorEmail": "sven.heidemann@sh-edraft.de", + "Description": "sh-edraft Gismo CLI", + "LongDescription": "sh-edraft Dicord bot Gismo CLI", + "URL": "https://www.sh-edraft.de", + "CopyrightDate": "2021 - 2022", + "CopyrightName": "sh-edraft.de", + "LicenseName": "MIT", + "LicenseDescription": "MIT, see LICENSE for more details.", + "Dependencies": [ + "sh_cpl-core>=2021.10.2", + "sh_cpl-query>=2021.10.2" + ], + "PythonVersion": ">=3.9.2", + "PythonPath": { + "linux": "../../venv/bin/python" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "console", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "gismo.main", + "EntryPoint": "gismo", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": { + "cpl_cli": [ + "*.json" + ] + }, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/src/gismo_cli/main.py b/src/gismo_cli/main.py new file mode 100644 index 0000000..e16a50d --- /dev/null +++ b/src/gismo_cli/main.py @@ -0,0 +1,18 @@ +import asyncio + +from cpl_core.application import ApplicationBuilder + +from gismo_cli.application import Application +from gismo_cli.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/gismo_cli/startup.py b/src/gismo_cli/startup.py new file mode 100644 index 0000000..dadaee3 --- /dev/null +++ b/src/gismo_cli/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/gismo_core/__init__.py b/src/gismo_core/__init__.py new file mode 100644 index 0000000..ad5eca3 --- /dev/null +++ b/src/gismo_core/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/src/gismo_core/gismo-core.json b/src/gismo_core/gismo-core.json new file mode 100644 index 0000000..6623647 --- /dev/null +++ b/src/gismo_core/gismo-core.json @@ -0,0 +1,43 @@ +{ + "ProjectSettings": { + "Name": "gismo-core", + "Version": { + "Major": "0", + "Minor": "0", + "Micro": "0" + }, + "Author": "", + "AuthorEmail": "", + "Description": "", + "LongDescription": "", + "URL": "", + "CopyrightDate": "", + "CopyrightName": "", + "LicenseName": "", + "LicenseDescription": "", + "Dependencies": [ + "sh_cpl>=2021.10.2" + ], + "PythonVersion": ">=3.9.2", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "library", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "gismo_core.main", + "EntryPoint": "gismo-core", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/src/modules_core/LICENSE b/src/modules_core/LICENSE new file mode 100644 index 0000000..e69de29 diff --git a/src/modules_core/README.md b/src/modules_core/README.md new file mode 100644 index 0000000..e69de29 diff --git a/src/modules_core/__init__.py b/src/modules_core/__init__.py new file mode 100644 index 0000000..ad5eca3 --- /dev/null +++ b/src/modules_core/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/src/modules_core/appsettings.json b/src/modules_core/appsettings.json new file mode 100644 index 0000000..629e6eb --- /dev/null +++ b/src/modules_core/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/modules_core/main.py b/src/modules_core/main.py new file mode 100644 index 0000000..db8266c --- /dev/null +++ b/src/modules_core/main.py @@ -0,0 +1,9 @@ +from cpl_core.console import Console + + +def main(): + Console.write_line('Hello World') + + +if __name__ == '__main__': + main() diff --git a/src/modules_core/modules_core.json b/src/modules_core/modules_core.json new file mode 100644 index 0000000..1e2da9c --- /dev/null +++ b/src/modules_core/modules_core.json @@ -0,0 +1,43 @@ +{ + "ProjectSettings": { + "Name": "modules_core", + "Version": { + "Major": "0", + "Minor": "0", + "Micro": "0" + }, + "Author": "", + "AuthorEmail": "", + "Description": "", + "LongDescription": "", + "URL": "", + "CopyrightDate": "", + "CopyrightName": "", + "LicenseName": "", + "LicenseDescription": "", + "Dependencies": [ + "sh_cpl>=2021.10.2" + ], + "PythonVersion": ">=3.9.2", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "library", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "modules_core.main", + "EntryPoint": "modules_core", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file -- 2.45.2 From 1927860206d26a35f5f16189c12c1a4a7d5dc2b6 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 01:07:54 +0100 Subject: [PATCH 002/113] Added boot-log project --- cpl-workspace.json | 1 - src/modules/boot_log/__init__.py | 1 + src/modules/boot_log/appsettings.json | 15 ++++++++++ src/modules/boot_log/boot-log.json | 43 +++++++++++++++++++++++++++ src/modules/boot_log/main.py | 23 ++++++++++++++ 5 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 src/modules/boot_log/__init__.py create mode 100644 src/modules/boot_log/appsettings.json create mode 100644 src/modules/boot_log/boot-log.json create mode 100644 src/modules/boot_log/main.py diff --git a/cpl-workspace.json b/cpl-workspace.json index cf21a2c..70c1214 100644 --- a/cpl-workspace.json +++ b/cpl-workspace.json @@ -5,7 +5,6 @@ "gismo": "src/gismo/gismo.json", "gismo-cli": "src/gismo_cli/gismo-cli.json", "gismo-core": "src/gismo_core/gismo-core.json", - "modules_core": "src/modules_core/modules_core.json", "boot-log": "src/modules/boot_log/boot-log.json" }, "Scripts": {} diff --git a/src/modules/boot_log/__init__.py b/src/modules/boot_log/__init__.py new file mode 100644 index 0000000..ad5eca3 --- /dev/null +++ b/src/modules/boot_log/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/src/modules/boot_log/appsettings.json b/src/modules/boot_log/appsettings.json new file mode 100644 index 0000000..629e6eb --- /dev/null +++ b/src/modules/boot_log/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/modules/boot_log/boot-log.json b/src/modules/boot_log/boot-log.json new file mode 100644 index 0000000..32aa09c --- /dev/null +++ b/src/modules/boot_log/boot-log.json @@ -0,0 +1,43 @@ +{ + "ProjectSettings": { + "Name": "modules/boot-log", + "Version": { + "Major": "0", + "Minor": "0", + "Micro": "0" + }, + "Author": "", + "AuthorEmail": "", + "Description": "", + "LongDescription": "", + "URL": "", + "CopyrightDate": "", + "CopyrightName": "", + "LicenseName": "", + "LicenseDescription": "", + "Dependencies": [ + "sh_cpl>=2021.10.2" + ], + "PythonVersion": ">=3.9.2", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "library", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "modules/_boot_log.main", + "EntryPoint": "modules/boot-log", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/src/modules/boot_log/main.py b/src/modules/boot_log/main.py new file mode 100644 index 0000000..f716961 --- /dev/null +++ b/src/modules/boot_log/main.py @@ -0,0 +1,23 @@ +from cpl_core.configuration import Configuration, ConfigurationABC +from cpl_core.console import Console +from cpl_core.dependency_injection import ServiceCollection, ServiceProviderABC + + +def configure_configuration() -> ConfigurationABC: + config = Configuration() + return config + + +def configure_services(config: ConfigurationABC) -> ServiceProviderABC: + services = ServiceCollection(config) + return services.build_service_provider() + + +def main(): + config = configure_configuration() + provider = configure_services(config) + Console.write_line('Hello World') + + +if __name__ == '__main__': + main() -- 2.45.2 From bca2e02cc243c188bbd08445cb4e07a0999b6cf2 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 01:09:41 +0100 Subject: [PATCH 003/113] Added database projects --- cpl-workspace.json | 4 +++- src/database/__init__.py | 1 + src/database/appsettings.json | 15 ++++++++++++ src/database/database.json | 43 +++++++++++++++++++++++++++++++++++ src/gismo_db/__init__.py | 1 + src/gismo_db/gismo_db.json | 43 +++++++++++++++++++++++++++++++++++ 6 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 src/database/__init__.py create mode 100644 src/database/appsettings.json create mode 100644 src/database/database.json create mode 100644 src/gismo_db/__init__.py create mode 100644 src/gismo_db/gismo_db.json diff --git a/cpl-workspace.json b/cpl-workspace.json index 70c1214..9e42da8 100644 --- a/cpl-workspace.json +++ b/cpl-workspace.json @@ -5,7 +5,9 @@ "gismo": "src/gismo/gismo.json", "gismo-cli": "src/gismo_cli/gismo-cli.json", "gismo-core": "src/gismo_core/gismo-core.json", - "boot-log": "src/modules/boot_log/boot-log.json" + "boot-log": "src/modules/boot_log/boot-log.json", + "gismo_db": "src/gismo_db/gismo_db.json", + "database": "src/database/database.json" }, "Scripts": {} } diff --git a/src/database/__init__.py b/src/database/__init__.py new file mode 100644 index 0000000..ad5eca3 --- /dev/null +++ b/src/database/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/src/database/appsettings.json b/src/database/appsettings.json new file mode 100644 index 0000000..629e6eb --- /dev/null +++ b/src/database/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/database/database.json b/src/database/database.json new file mode 100644 index 0000000..21ba584 --- /dev/null +++ b/src/database/database.json @@ -0,0 +1,43 @@ +{ + "ProjectSettings": { + "Name": "database", + "Version": { + "Major": "0", + "Minor": "0", + "Micro": "0" + }, + "Author": "", + "AuthorEmail": "", + "Description": "", + "LongDescription": "", + "URL": "", + "CopyrightDate": "", + "CopyrightName": "", + "LicenseName": "", + "LicenseDescription": "", + "Dependencies": [ + "sh_cpl>=2021.10.2" + ], + "PythonVersion": ">=3.9.2", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "library", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "database.main", + "EntryPoint": "database", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/src/gismo_db/__init__.py b/src/gismo_db/__init__.py new file mode 100644 index 0000000..ad5eca3 --- /dev/null +++ b/src/gismo_db/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/src/gismo_db/gismo_db.json b/src/gismo_db/gismo_db.json new file mode 100644 index 0000000..33952aa --- /dev/null +++ b/src/gismo_db/gismo_db.json @@ -0,0 +1,43 @@ +{ + "ProjectSettings": { + "Name": "gismo_db", + "Version": { + "Major": "0", + "Minor": "0", + "Micro": "0" + }, + "Author": "", + "AuthorEmail": "", + "Description": "", + "LongDescription": "", + "URL": "", + "CopyrightDate": "", + "CopyrightName": "", + "LicenseName": "", + "LicenseDescription": "", + "Dependencies": [ + "sh_cpl>=2021.10.2" + ], + "PythonVersion": ">=3.9.2", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "library", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "gismo_db.main", + "EntryPoint": "gismo_db", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file -- 2.45.2 From c82e8e3065e46184ad516dd77fbcc68cf728ec83 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 01:18:33 +0100 Subject: [PATCH 004/113] Added tool projects --- cpl-workspace.json | 4 +- tools/level_generator/LICENSE | 0 tools/level_generator/README.md | 0 tools/level_generator/__init__.py | 1 + tools/level_generator/application.py | 16 +++++++ tools/level_generator/appsettings.json | 15 +++++++ tools/level_generator/level-generator.json | 43 +++++++++++++++++++ tools/level_generator/main.py | 14 ++++++ tools/level_generator/startup.py | 16 +++++++ tools/ontime_calculator/LICENSE | 0 tools/ontime_calculator/README.md | 0 tools/ontime_calculator/__init__.py | 1 + tools/ontime_calculator/application.py | 16 +++++++ tools/ontime_calculator/appsettings.json | 15 +++++++ tools/ontime_calculator/main.py | 14 ++++++ .../ontime_calculator/ontime-calculator.json | 43 +++++++++++++++++++ tools/ontime_calculator/startup.py | 16 +++++++ 17 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 tools/level_generator/LICENSE create mode 100644 tools/level_generator/README.md create mode 100644 tools/level_generator/__init__.py create mode 100644 tools/level_generator/application.py create mode 100644 tools/level_generator/appsettings.json create mode 100644 tools/level_generator/level-generator.json create mode 100644 tools/level_generator/main.py create mode 100644 tools/level_generator/startup.py create mode 100644 tools/ontime_calculator/LICENSE create mode 100644 tools/ontime_calculator/README.md create mode 100644 tools/ontime_calculator/__init__.py create mode 100644 tools/ontime_calculator/application.py create mode 100644 tools/ontime_calculator/appsettings.json create mode 100644 tools/ontime_calculator/main.py create mode 100644 tools/ontime_calculator/ontime-calculator.json create mode 100644 tools/ontime_calculator/startup.py diff --git a/cpl-workspace.json b/cpl-workspace.json index 9e42da8..c813310 100644 --- a/cpl-workspace.json +++ b/cpl-workspace.json @@ -7,7 +7,9 @@ "gismo-core": "src/gismo_core/gismo-core.json", "boot-log": "src/modules/boot_log/boot-log.json", "gismo_db": "src/gismo_db/gismo_db.json", - "database": "src/database/database.json" + "database": "src/database/database.json", + "level-generator": "tools/level_generator/level-generator.json", + "ontime-calculator": "tools/ontime_calculator/ontime-calculator.json" }, "Scripts": {} } diff --git a/tools/level_generator/LICENSE b/tools/level_generator/LICENSE new file mode 100644 index 0000000..e69de29 diff --git a/tools/level_generator/README.md b/tools/level_generator/README.md new file mode 100644 index 0000000..e69de29 diff --git a/tools/level_generator/__init__.py b/tools/level_generator/__init__.py new file mode 100644 index 0000000..ad5eca3 --- /dev/null +++ b/tools/level_generator/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/tools/level_generator/application.py b/tools/level_generator/application.py new file mode 100644 index 0000000..34a68c8 --- /dev/null +++ b/tools/level_generator/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) + + def configure(self): + pass + + def main(self): + Console.write_line('Hello World') diff --git a/tools/level_generator/appsettings.json b/tools/level_generator/appsettings.json new file mode 100644 index 0000000..629e6eb --- /dev/null +++ b/tools/level_generator/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/tools/level_generator/level-generator.json b/tools/level_generator/level-generator.json new file mode 100644 index 0000000..4fcdfe9 --- /dev/null +++ b/tools/level_generator/level-generator.json @@ -0,0 +1,43 @@ +{ + "ProjectSettings": { + "Name": "tools/level-generator", + "Version": { + "Major": "0", + "Minor": "0", + "Micro": "0" + }, + "Author": "", + "AuthorEmail": "", + "Description": "", + "LongDescription": "", + "URL": "", + "CopyrightDate": "", + "CopyrightName": "", + "LicenseName": "", + "LicenseDescription": "", + "Dependencies": [ + "sh_cpl>=2021.10.2" + ], + "PythonVersion": ">=3.9.2", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "console", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "tools/_level_generator.main", + "EntryPoint": "tools/level-generator", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/tools/level_generator/main.py b/tools/level_generator/main.py new file mode 100644 index 0000000..49614d1 --- /dev/null +++ b/tools/level_generator/main.py @@ -0,0 +1,14 @@ +from cpl_core.application import ApplicationBuilder + +from level_generator.application import Application +from level_generator.startup import Startup + + +def main(): + app_builder = ApplicationBuilder(Application) + app_builder.use_startup(Startup) + app_builder.build().run() + + +if __name__ == '__main__': + main() diff --git a/tools/level_generator/startup.py b/tools/level_generator/startup.py new file mode 100644 index 0000000..359c03d --- /dev/null +++ b/tools/level_generator/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) + + def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC: + return configuration + + def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC: + return services.build_service_provider() diff --git a/tools/ontime_calculator/LICENSE b/tools/ontime_calculator/LICENSE new file mode 100644 index 0000000..e69de29 diff --git a/tools/ontime_calculator/README.md b/tools/ontime_calculator/README.md new file mode 100644 index 0000000..e69de29 diff --git a/tools/ontime_calculator/__init__.py b/tools/ontime_calculator/__init__.py new file mode 100644 index 0000000..ad5eca3 --- /dev/null +++ b/tools/ontime_calculator/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/tools/ontime_calculator/application.py b/tools/ontime_calculator/application.py new file mode 100644 index 0000000..34a68c8 --- /dev/null +++ b/tools/ontime_calculator/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) + + def configure(self): + pass + + def main(self): + Console.write_line('Hello World') diff --git a/tools/ontime_calculator/appsettings.json b/tools/ontime_calculator/appsettings.json new file mode 100644 index 0000000..629e6eb --- /dev/null +++ b/tools/ontime_calculator/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/tools/ontime_calculator/main.py b/tools/ontime_calculator/main.py new file mode 100644 index 0000000..0fffb04 --- /dev/null +++ b/tools/ontime_calculator/main.py @@ -0,0 +1,14 @@ +from cpl_core.application import ApplicationBuilder + +from ontime_calculator.application import Application +from ontime_calculator.startup import Startup + + +def main(): + app_builder = ApplicationBuilder(Application) + app_builder.use_startup(Startup) + app_builder.build().run() + + +if __name__ == '__main__': + main() diff --git a/tools/ontime_calculator/ontime-calculator.json b/tools/ontime_calculator/ontime-calculator.json new file mode 100644 index 0000000..9ec006b --- /dev/null +++ b/tools/ontime_calculator/ontime-calculator.json @@ -0,0 +1,43 @@ +{ + "ProjectSettings": { + "Name": "tools/ontime-calculator", + "Version": { + "Major": "0", + "Minor": "0", + "Micro": "0" + }, + "Author": "", + "AuthorEmail": "", + "Description": "", + "LongDescription": "", + "URL": "", + "CopyrightDate": "", + "CopyrightName": "", + "LicenseName": "", + "LicenseDescription": "", + "Dependencies": [ + "sh_cpl>=2021.10.2" + ], + "PythonVersion": ">=3.9.2", + "PythonPath": { + "linux": "" + }, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "console", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "tools/_ontime_calculator.main", + "EntryPoint": "tools/ontime-calculator", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/tools/ontime_calculator/startup.py b/tools/ontime_calculator/startup.py new file mode 100644 index 0000000..359c03d --- /dev/null +++ b/tools/ontime_calculator/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) + + def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC: + return configuration + + def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC: + return services.build_service_provider() -- 2.45.2 From eda1caf36adc6a8e7738c2fc69700571a0cf3f9a Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 01:22:20 +0100 Subject: [PATCH 005/113] Renamed projects --- cpl-workspace.json | 5 ++-- src/gismo/__init__.py | 24 +++++++++++++++++++ src/gismo/gismo.json | 7 +++++- src/gismo_db/{gismo_db.json => gismo-db.json} | 2 +- src/modules_core/LICENSE | 0 src/modules_core/README.md | 0 src/modules_core/appsettings.json | 15 ------------ src/modules_core/main.py | 9 ------- .../{modules_core.json => modules-core.json} | 4 ++-- 9 files changed, 36 insertions(+), 30 deletions(-) rename src/gismo_db/{gismo_db.json => gismo-db.json} (97%) delete mode 100644 src/modules_core/LICENSE delete mode 100644 src/modules_core/README.md delete mode 100644 src/modules_core/appsettings.json delete mode 100644 src/modules_core/main.py rename src/modules_core/{modules_core.json => modules-core.json} (92%) diff --git a/cpl-workspace.json b/cpl-workspace.json index c813310..4c07f53 100644 --- a/cpl-workspace.json +++ b/cpl-workspace.json @@ -5,9 +5,10 @@ "gismo": "src/gismo/gismo.json", "gismo-cli": "src/gismo_cli/gismo-cli.json", "gismo-core": "src/gismo_core/gismo-core.json", - "boot-log": "src/modules/boot_log/boot-log.json", - "gismo_db": "src/gismo_db/gismo_db.json", + "gismo-db": "src/gismo_db/gismo_db.json", "database": "src/database/database.json", + "modules-core": "src/modules_core/modules-core.json", + "boot-log": "src/modules/boot_log/boot-log.json", "level-generator": "tools/level_generator/level-generator.json", "ontime-calculator": "tools/ontime_calculator/ontime-calculator.json" }, diff --git a/src/gismo/__init__.py b/src/gismo/__init__.py index ad5eca3..0242bb0 100644 --- a/src/gismo/__init__.py +++ b/src/gismo/__init__.py @@ -1 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +gismo sh-edraft Gismo +~~~~~~~~~~~~~~~~~~~ + +sh-edraft Dicord bot Gismo + +:copyright: (c) 2021 - 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'gismo' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' +__version__ = '0.1.0' + +from collections import namedtuple + # imports: + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='1', micro='0') diff --git a/src/gismo/gismo.json b/src/gismo/gismo.json index a3a8bb0..4640298 100644 --- a/src/gismo/gismo.json +++ b/src/gismo/gismo.json @@ -43,6 +43,11 @@ "*.json" ] }, - "ProjectReferences": [] + "ProjectReferences": [ + "../gismo_core/gismo-core.json", + "../gismo_db/gismo-db.json", + "../modules/*", + "../modules_core/modules-core.json" + ] } } \ No newline at end of file diff --git a/src/gismo_db/gismo_db.json b/src/gismo_db/gismo-db.json similarity index 97% rename from src/gismo_db/gismo_db.json rename to src/gismo_db/gismo-db.json index 33952aa..31a89ee 100644 --- a/src/gismo_db/gismo_db.json +++ b/src/gismo_db/gismo-db.json @@ -1,6 +1,6 @@ { "ProjectSettings": { - "Name": "gismo_db", + "Name": "gismo-db", "Version": { "Major": "0", "Minor": "0", diff --git a/src/modules_core/LICENSE b/src/modules_core/LICENSE deleted file mode 100644 index e69de29..0000000 diff --git a/src/modules_core/README.md b/src/modules_core/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/src/modules_core/appsettings.json b/src/modules_core/appsettings.json deleted file mode 100644 index 629e6eb..0000000 --- a/src/modules_core/appsettings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "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/modules_core/main.py b/src/modules_core/main.py deleted file mode 100644 index db8266c..0000000 --- a/src/modules_core/main.py +++ /dev/null @@ -1,9 +0,0 @@ -from cpl_core.console import Console - - -def main(): - Console.write_line('Hello World') - - -if __name__ == '__main__': - main() diff --git a/src/modules_core/modules_core.json b/src/modules_core/modules-core.json similarity index 92% rename from src/modules_core/modules_core.json rename to src/modules_core/modules-core.json index 1e2da9c..ea2a0e5 100644 --- a/src/modules_core/modules_core.json +++ b/src/modules_core/modules-core.json @@ -1,6 +1,6 @@ { "ProjectSettings": { - "Name": "modules_core", + "Name": "modules-core", "Version": { "Major": "0", "Minor": "0", @@ -29,7 +29,7 @@ "SourcePath": "", "OutputPath": "../../dist", "Main": "modules_core.main", - "EntryPoint": "modules_core", + "EntryPoint": "modules-core", "IncludePackageData": false, "Included": [], "Excluded": [ -- 2.45.2 From 056335e84bd467b1abc099a12fe59125620def49 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 01:24:10 +0100 Subject: [PATCH 006/113] Added project references --- src/gismo/gismo.json | 4 ++-- src/gismo_core/__init__.py | 24 ++++++++++++++++++++++++ src/gismo_db/__init__.py | 24 ++++++++++++++++++++++++ src/modules/boot_log/__init__.py | 24 ++++++++++++++++++++++++ src/modules_core/__init__.py | 24 ++++++++++++++++++++++++ 5 files changed, 98 insertions(+), 2 deletions(-) diff --git a/src/gismo/gismo.json b/src/gismo/gismo.json index 4640298..d5dda70 100644 --- a/src/gismo/gismo.json +++ b/src/gismo/gismo.json @@ -46,8 +46,8 @@ "ProjectReferences": [ "../gismo_core/gismo-core.json", "../gismo_db/gismo-db.json", - "../modules/*", - "../modules_core/modules-core.json" + "../modules_core/modules-core.json", + "../modules/boot_log/boot-log.json" ] } } \ No newline at end of file diff --git a/src/gismo_core/__init__.py b/src/gismo_core/__init__.py index ad5eca3..671be7b 100644 --- a/src/gismo_core/__init__.py +++ b/src/gismo_core/__init__.py @@ -1 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +gismo sh-edraft Gismo +~~~~~~~~~~~~~~~~~~~ + +sh-edraft Dicord bot Gismo + +:copyright: (c) 2021 - 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'gismo_core' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' +__version__ = '0.1.0' + +from collections import namedtuple + # imports: + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='1', micro='0') diff --git a/src/gismo_db/__init__.py b/src/gismo_db/__init__.py index ad5eca3..4265bbc 100644 --- a/src/gismo_db/__init__.py +++ b/src/gismo_db/__init__.py @@ -1 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +gismo sh-edraft Gismo +~~~~~~~~~~~~~~~~~~~ + +sh-edraft Dicord bot Gismo + +:copyright: (c) 2021 - 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'gismo_db' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' +__version__ = '0.1.0' + +from collections import namedtuple + # imports: + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='1', micro='0') diff --git a/src/modules/boot_log/__init__.py b/src/modules/boot_log/__init__.py index ad5eca3..3354a8e 100644 --- a/src/modules/boot_log/__init__.py +++ b/src/modules/boot_log/__init__.py @@ -1 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +gismo sh-edraft Gismo +~~~~~~~~~~~~~~~~~~~ + +sh-edraft Dicord bot Gismo + +:copyright: (c) 2021 - 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'modules.boot_log' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' +__version__ = '0.1.0' + +from collections import namedtuple + # imports: + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='1', micro='0') diff --git a/src/modules_core/__init__.py b/src/modules_core/__init__.py index ad5eca3..5a29729 100644 --- a/src/modules_core/__init__.py +++ b/src/modules_core/__init__.py @@ -1 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +gismo sh-edraft Gismo +~~~~~~~~~~~~~~~~~~~ + +sh-edraft Dicord bot Gismo + +:copyright: (c) 2021 - 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'modules_core' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' +__version__ = '0.1.0' + +from collections import namedtuple + # imports: + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='1', micro='0') -- 2.45.2 From 744501b3c2ca3c3d25a1c7a2e57a08bf03f3a7fb Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 01:27:32 +0100 Subject: [PATCH 007/113] Improved projects files --- src/database/database.json | 25 +++++++++++++------------ src/gismo_cli/gismo-cli.json | 4 ++-- src/gismo_core/gismo-core.json | 25 +++++++++++++------------ src/gismo_db/gismo-db.json | 25 +++++++++++++------------ src/modules/boot_log/appsettings.json | 15 --------------- src/modules/boot_log/boot-log.json | 25 +++++++++++++------------ src/modules_core/modules-core.json | 25 +++++++++++++------------ 7 files changed, 67 insertions(+), 77 deletions(-) delete mode 100644 src/modules/boot_log/appsettings.json diff --git a/src/database/database.json b/src/database/database.json index 21ba584..c743e12 100644 --- a/src/database/database.json +++ b/src/database/database.json @@ -3,24 +3,25 @@ "Name": "database", "Version": { "Major": "0", - "Minor": "0", + "Minor": "1", "Micro": "0" }, - "Author": "", - "AuthorEmail": "", - "Description": "", - "LongDescription": "", - "URL": "", - "CopyrightDate": "", - "CopyrightName": "", - "LicenseName": "", - "LicenseDescription": "", + "Author": "Sven Heidemann", + "AuthorEmail": "sven.heidemann@sh-edraft.de", + "Description": "sh-edraft Gismo - database core", + "LongDescription": "sh-edraft Dicord bot Gismo - database implementation of cpl.database", + "URL": "https://www.sh-edraft.de", + "CopyrightDate": "2021 - 2022", + "CopyrightName": "sh-edraft.de", + "LicenseName": "MIT", + "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "sh_cpl>=2021.10.2" + "sh_cpl-core>=2021.10.2", + "sh_cpl-query>=2021.10.2" ], "PythonVersion": ">=3.9.2", "PythonPath": { - "linux": "" + "linux": "../../venv/bin/python" }, "Classifiers": [] }, diff --git a/src/gismo_cli/gismo-cli.json b/src/gismo_cli/gismo-cli.json index 37fc9ce..eebe3c2 100644 --- a/src/gismo_cli/gismo-cli.json +++ b/src/gismo_cli/gismo-cli.json @@ -8,8 +8,8 @@ }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", - "Description": "sh-edraft Gismo CLI", - "LongDescription": "sh-edraft Dicord bot Gismo CLI", + "Description": "sh-edraft Gismo - CLI", + "LongDescription": "sh-edraft Dicord bot Gismo - command line interface", "URL": "https://www.sh-edraft.de", "CopyrightDate": "2021 - 2022", "CopyrightName": "sh-edraft.de", diff --git a/src/gismo_core/gismo-core.json b/src/gismo_core/gismo-core.json index 6623647..368ba0a 100644 --- a/src/gismo_core/gismo-core.json +++ b/src/gismo_core/gismo-core.json @@ -3,24 +3,25 @@ "Name": "gismo-core", "Version": { "Major": "0", - "Minor": "0", + "Minor": "1", "Micro": "0" }, - "Author": "", - "AuthorEmail": "", - "Description": "", - "LongDescription": "", - "URL": "", - "CopyrightDate": "", - "CopyrightName": "", - "LicenseName": "", - "LicenseDescription": "", + "Author": "Sven Heidemann", + "AuthorEmail": "sven.heidemann@sh-edraft.de", + "Description": "sh-edraft Gismo - core", + "LongDescription": "sh-edraft Dicord bot Gismo - core library", + "URL": "https://www.sh-edraft.de", + "CopyrightDate": "2021 - 2022", + "CopyrightName": "sh-edraft.de", + "LicenseName": "MIT", + "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "sh_cpl>=2021.10.2" + "sh_cpl-core>=2021.10.2", + "sh_cpl-query>=2021.10.2" ], "PythonVersion": ">=3.9.2", "PythonPath": { - "linux": "" + "linux": "../../venv/bin/python" }, "Classifiers": [] }, diff --git a/src/gismo_db/gismo-db.json b/src/gismo_db/gismo-db.json index 31a89ee..c546daa 100644 --- a/src/gismo_db/gismo-db.json +++ b/src/gismo_db/gismo-db.json @@ -3,24 +3,25 @@ "Name": "gismo-db", "Version": { "Major": "0", - "Minor": "0", + "Minor": "1", "Micro": "0" }, - "Author": "", - "AuthorEmail": "", - "Description": "", - "LongDescription": "", - "URL": "", - "CopyrightDate": "", - "CopyrightName": "", - "LicenseName": "", - "LicenseDescription": "", + "Author": "Sven Heidemann", + "AuthorEmail": "sven.heidemann@sh-edraft.de", + "Description": "sh-edraft Gismo - Database", + "LongDescription": "sh-edraft Dicord bot Gismo - Database", + "URL": "https://www.sh-edraft.de", + "CopyrightDate": "2021 - 2022", + "CopyrightName": "sh-edraft.de", + "LicenseName": "MIT", + "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "sh_cpl>=2021.10.2" + "sh_cpl-core>=2021.10.2", + "sh_cpl-query>=2021.10.2" ], "PythonVersion": ">=3.9.2", "PythonPath": { - "linux": "" + "linux": "../../venv/bin/python" }, "Classifiers": [] }, diff --git a/src/modules/boot_log/appsettings.json b/src/modules/boot_log/appsettings.json deleted file mode 100644 index 629e6eb..0000000 --- a/src/modules/boot_log/appsettings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "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/modules/boot_log/boot-log.json b/src/modules/boot_log/boot-log.json index 32aa09c..d86f1a0 100644 --- a/src/modules/boot_log/boot-log.json +++ b/src/modules/boot_log/boot-log.json @@ -3,24 +3,25 @@ "Name": "modules/boot-log", "Version": { "Major": "0", - "Minor": "0", + "Minor": "1", "Micro": "0" }, - "Author": "", - "AuthorEmail": "", - "Description": "", - "LongDescription": "", - "URL": "", - "CopyrightDate": "", - "CopyrightName": "", - "LicenseName": "", - "LicenseDescription": "", + "Author": "Sven Heidemann", + "AuthorEmail": "sven.heidemann@sh-edraft.de", + "Description": "sh-edraft Gismo - Boot log", + "LongDescription": "sh-edraft Dicord bot Gismo - Boot log", + "URL": "https://www.sh-edraft.de", + "CopyrightDate": "2021 - 2022", + "CopyrightName": "sh-edraft.de", + "LicenseName": "MIT", + "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "sh_cpl>=2021.10.2" + "sh_cpl-core>=2021.10.2", + "sh_cpl-query>=2021.10.2" ], "PythonVersion": ">=3.9.2", "PythonPath": { - "linux": "" + "linux": "../../venv/bin/python" }, "Classifiers": [] }, diff --git a/src/modules_core/modules-core.json b/src/modules_core/modules-core.json index ea2a0e5..b1e991d 100644 --- a/src/modules_core/modules-core.json +++ b/src/modules_core/modules-core.json @@ -3,24 +3,25 @@ "Name": "modules-core", "Version": { "Major": "0", - "Minor": "0", + "Minor": "1", "Micro": "0" }, - "Author": "", - "AuthorEmail": "", - "Description": "", - "LongDescription": "", - "URL": "", - "CopyrightDate": "", - "CopyrightName": "", - "LicenseName": "", - "LicenseDescription": "", + "Author": "Sven Heidemann", + "AuthorEmail": "sven.heidemann@sh-edraft.de", + "Description": "sh-edraft Gismo - Modules core", + "LongDescription": "sh-edraft Dicord bot Gismo - Modules core", + "URL": "https://www.sh-edraft.de", + "CopyrightDate": "2021 - 2022", + "CopyrightName": "sh-edraft.de", + "LicenseName": "MIT", + "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "sh_cpl>=2021.10.2" + "sh_cpl-core>=2021.10.2", + "sh_cpl-query>=2021.10.2" ], "PythonVersion": ">=3.9.2", "PythonPath": { - "linux": "" + "linux": "../../venv/bin/python" }, "Classifiers": [] }, -- 2.45.2 From 059e34575104d23af1195ed78f64343153b0f6ba Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 11:29:10 +0100 Subject: [PATCH 008/113] Added vs code settings --- .vscode/settings.json | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7786c39 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,26 @@ +{ + "workbench.colorCustomizations": { + "activityBar.activeBackground": "#fbed80", + "activityBar.activeBorder": "#06b9a5", + "activityBar.background": "#fbed80", + "activityBar.foreground": "#15202b", + "activityBar.inactiveForeground": "#15202b99", + "activityBarBadge.background": "#06b9a5", + "activityBarBadge.foreground": "#15202b", + "editorGroup.border": "#fbed80", + "panel.border": "#fbed80", + "sash.hoverBorder": "#fbed80", + "sideBar.border": "#fbed80", + "statusBar.background": "#f9e64f", + "statusBar.foreground": "#15202b", + "statusBarItem.hoverBackground": "#f7df1e", + "statusBarItem.remoteBackground": "#f9e64f", + "statusBarItem.remoteForeground": "#15202b", + "titleBar.activeBackground": "#f9e64f", + "titleBar.activeForeground": "#15202b", + "titleBar.inactiveBackground": "#f9e64f99", + "titleBar.inactiveForeground": "#15202b99" + }, + "peacock.color": "#f9e64f", + "python.pythonPath": "venv/bin/python", +} \ No newline at end of file -- 2.45.2 From b1becbe8667990c39d47ccd82b3249b6b401f8b2 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 17:05:48 +0100 Subject: [PATCH 009/113] Improved tools --- tools/level_generator/LICENSE | 0 tools/level_generator/README.md | 0 tools/level_generator/application.py | 42 +++++++++++++++++- tools/level_generator/appsettings.json | 15 ------- tools/ontime_calculator/LICENSE | 0 tools/ontime_calculator/README.md | 0 tools/ontime_calculator/application.py | 11 ++++- tools/ontime_calculator/appsettings.json | 15 ------- .../ontime_calculator/ontime-calculator.json | 43 ------------------- 9 files changed, 51 insertions(+), 75 deletions(-) delete mode 100644 tools/level_generator/LICENSE delete mode 100644 tools/level_generator/README.md delete mode 100644 tools/level_generator/appsettings.json delete mode 100644 tools/ontime_calculator/LICENSE delete mode 100644 tools/ontime_calculator/README.md delete mode 100644 tools/ontime_calculator/appsettings.json delete mode 100644 tools/ontime_calculator/ontime-calculator.json diff --git a/tools/level_generator/LICENSE b/tools/level_generator/LICENSE deleted file mode 100644 index e69de29..0000000 diff --git a/tools/level_generator/README.md b/tools/level_generator/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/tools/level_generator/application.py b/tools/level_generator/application.py index 34a68c8..6f142b5 100644 --- a/tools/level_generator/application.py +++ b/tools/level_generator/application.py @@ -1,3 +1,5 @@ +import json + from cpl_core.application import ApplicationABC from cpl_core.configuration import ConfigurationABC from cpl_core.console import Console @@ -13,4 +15,42 @@ class Application(ApplicationABC): pass def main(self): - Console.write_line('Hello World') + f = open("./Levels.txt", "r", encoding='utf-8') + i = 0 + lines = f.readlines() + json_list = [] + + for line in lines: + if i > 0: + line = line.split('\n')[0] + words = line.split(' ') + use_words = [] + for word in words: + if word != '': + use_words.append(word) + + if len(use_words) == 6: + string = use_words[2] + use_words.remove(use_words[2]) + use_words[1] += f' {string}' + + loc_json = { + "id": int(use_words[0]), + "alias": use_words[1], + "min_ontime": int(use_words[2]), + "min_message_count": int(use_words[3]), + "color": use_words[4], + "hoist": "False", + "mentionable": "True", + "PermissionBagId": 0 + } + json_list.append(loc_json) + + i += 1 + + f.close() + + Console.write_line(json_list) + json_format = json.dumps(json_list, ensure_ascii=False) + with open("../src/sh_dobby_bot/assets/Level.json", "w", encoding='utf-8') as outfile: + outfile.write(json_format) diff --git a/tools/level_generator/appsettings.json b/tools/level_generator/appsettings.json deleted file mode 100644 index 629e6eb..0000000 --- a/tools/level_generator/appsettings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "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/tools/ontime_calculator/LICENSE b/tools/ontime_calculator/LICENSE deleted file mode 100644 index e69de29..0000000 diff --git a/tools/ontime_calculator/README.md b/tools/ontime_calculator/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/tools/ontime_calculator/application.py b/tools/ontime_calculator/application.py index 34a68c8..c860ec2 100644 --- a/tools/ontime_calculator/application.py +++ b/tools/ontime_calculator/application.py @@ -13,4 +13,13 @@ class Application(ApplicationABC): pass def main(self): - Console.write_line('Hello World') + ontime = 0 + mc = 0 + for i in range(0, 31): + Console.write_line(f'i: {i} {ontime} {mc}') + if i == 0: + ontime = 4 + mc = 10 + else: + ontime = round((ontime * 1.2561), 0) + mc = round((mc * 1.26), 0) diff --git a/tools/ontime_calculator/appsettings.json b/tools/ontime_calculator/appsettings.json deleted file mode 100644 index 629e6eb..0000000 --- a/tools/ontime_calculator/appsettings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "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/tools/ontime_calculator/ontime-calculator.json b/tools/ontime_calculator/ontime-calculator.json deleted file mode 100644 index 9ec006b..0000000 --- a/tools/ontime_calculator/ontime-calculator.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "ProjectSettings": { - "Name": "tools/ontime-calculator", - "Version": { - "Major": "0", - "Minor": "0", - "Micro": "0" - }, - "Author": "", - "AuthorEmail": "", - "Description": "", - "LongDescription": "", - "URL": "", - "CopyrightDate": "", - "CopyrightName": "", - "LicenseName": "", - "LicenseDescription": "", - "Dependencies": [ - "sh_cpl>=2021.10.2" - ], - "PythonVersion": ">=3.9.2", - "PythonPath": { - "linux": "" - }, - "Classifiers": [] - }, - "BuildSettings": { - "ProjectType": "console", - "SourcePath": "", - "OutputPath": "../../dist", - "Main": "tools/_ontime_calculator.main", - "EntryPoint": "tools/ontime-calculator", - "IncludePackageData": false, - "Included": [], - "Excluded": [ - "*/__pycache__", - "*/logs", - "*/tests" - ], - "PackageData": {}, - "ProjectReferences": [] - } -} \ No newline at end of file -- 2.45.2 From 97a3ba24a643bed07e442421f65af096dc283ddc Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 18:09:34 +0100 Subject: [PATCH 010/113] Added some config files --- .gitignore | 3 +++ LICENSE | 2 +- src/gismo/application.py | 14 +++++----- src/gismo/appsettings.development.json | 15 +++++++++++ src/gismo/appsettings.edrafts-pc.json | 5 ++++ src/gismo/appsettings.production.json | 15 +++++++++++ src/gismo/appsettings.staging.json | 15 +++++++++++ src/gismo/gismo.json | 3 ++- src/gismo/main.py | 4 +-- src/gismo/startup.py | 13 ++++++++++ src/gismo_core/__init__.py | 26 +------------------ src/gismo_core/abc/__init__.py | 1 + src/gismo_core/abc/bot_service_abc.py | 13 ++++++++++ src/gismo_core/configuration/__init__.py | 1 + .../configuration/discord_settings.py | 23 ++++++++++++++++ src/gismo_core/services/__init__.py | 1 + src/gismo_core/services/bot_service.py | 15 +++++++++++ 17 files changed, 133 insertions(+), 36 deletions(-) create mode 100644 src/gismo/appsettings.development.json create mode 100644 src/gismo/appsettings.edrafts-pc.json create mode 100644 src/gismo/appsettings.production.json create mode 100644 src/gismo/appsettings.staging.json create mode 100644 src/gismo_core/abc/__init__.py create mode 100644 src/gismo_core/abc/bot_service_abc.py create mode 100644 src/gismo_core/configuration/__init__.py create mode 100644 src/gismo_core/configuration/discord_settings.py create mode 100644 src/gismo_core/services/__init__.py create mode 100644 src/gismo_core/services/bot_service.py diff --git a/.gitignore b/.gitignore index f8b73e7..c337315 100644 --- a/.gitignore +++ b/.gitignore @@ -138,3 +138,6 @@ dmypy.json # Cython debug symbols cython_debug/ +# gismo +g-env/ + diff --git a/LICENSE b/LICENSE index 204b93d..a23c753 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -MIT License Copyright (c) +MIT License Copyright (c) 2021-2022 sh-edraft.de Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/gismo/application.py b/src/gismo/application.py index b2df025..a85f7d3 100644 --- a/src/gismo/application.py +++ b/src/gismo/application.py @@ -1,16 +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) + self._bot: BotService = services.get_service(BotServiceABC) + self._logger: LoggerABC = services.get_service(LoggerABC) + async def configure(self): pass async def main(self): - Console.write_line('Hello World') + try: + await self._bot.run() + except Exception as e: + self._logger.error(__name__, 'A fatal error occured starting the bot', e) diff --git a/src/gismo/appsettings.development.json b/src/gismo/appsettings.development.json new file mode 100644 index 0000000..c18c91e --- /dev/null +++ b/src/gismo/appsettings.development.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": "TRACE", + "FileLogLevel": "TRACE" + } +} diff --git a/src/gismo/appsettings.edrafts-pc.json b/src/gismo/appsettings.edrafts-pc.json new file mode 100644 index 0000000..07e013f --- /dev/null +++ b/src/gismo/appsettings.edrafts-pc.json @@ -0,0 +1,5 @@ +{ + "Discord": { + "Token": "" + } +} diff --git a/src/gismo/appsettings.production.json b/src/gismo/appsettings.production.json new file mode 100644 index 0000000..629e6eb --- /dev/null +++ b/src/gismo/appsettings.production.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/gismo/appsettings.staging.json b/src/gismo/appsettings.staging.json new file mode 100644 index 0000000..1fce9ac --- /dev/null +++ b/src/gismo/appsettings.staging.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": "DEBUG", + "FileLogLevel": "DEBUG" + } +} diff --git a/src/gismo/gismo.json b/src/gismo/gismo.json index d5dda70..b8a447a 100644 --- a/src/gismo/gismo.json +++ b/src/gismo/gismo.json @@ -17,7 +17,8 @@ "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ "sh_cpl-core>=2021.10.2", - "sh_cpl-query>=2021.10.2" + "sh_cpl-query>=2021.10.2", + "discord.py==1.7.3" ], "PythonVersion": ">=3.9.2", "PythonPath": { diff --git a/src/gismo/main.py b/src/gismo/main.py index 4311d0e..808c102 100644 --- a/src/gismo/main.py +++ b/src/gismo/main.py @@ -2,8 +2,8 @@ import asyncio from cpl_core.application import ApplicationBuilder -from gismo.application import Application -from gismo.startup import Startup +from application import Application +from startup import Startup async def main(): diff --git a/src/gismo/startup.py b/src/gismo/startup.py index dadaee3..333f888 100644 --- a/src/gismo/startup.py +++ b/src/gismo/startup.py @@ -3,6 +3,9 @@ from cpl_core.configuration import ConfigurationABC from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC from cpl_core.environment import ApplicationEnvironment +from gismo_core.abc.bot_service_abc import BotServiceABC +from gismo_core.services.bot_service import BotService + class Startup(StartupABC): @@ -10,7 +13,17 @@ class Startup(StartupABC): StartupABC.__init__(self) async def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC: + configuration.add_environment_variables('GISMO_') + configuration.add_console_arguments() + configuration.add_json_file(f'appsettings.json', optional=False) + configuration.add_json_file(f'appsettings.{environment.environment_name}.json', optional=True) + configuration.add_json_file(f'appsettings.{environment.host_name}.json', optional=True) + return configuration async def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC: + services.add_logging() + + services.add_singleton(BotServiceABC, BotService) + return services.build_service_provider() diff --git a/src/gismo_core/__init__.py b/src/gismo_core/__init__.py index 671be7b..425ab6c 100644 --- a/src/gismo_core/__init__.py +++ b/src/gismo_core/__init__.py @@ -1,25 +1 @@ -# -*- coding: utf-8 -*- - -""" -gismo sh-edraft Gismo -~~~~~~~~~~~~~~~~~~~ - -sh-edraft Dicord bot Gismo - -:copyright: (c) 2021 - 2022 sh-edraft.de -:license: MIT, see LICENSE for more details. - -""" - -__title__ = 'gismo_core' -__author__ = 'Sven Heidemann' -__license__ = 'MIT' -__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' -__version__ = '0.1.0' - -from collections import namedtuple - -# imports: - -VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='1', micro='0') +# imports diff --git a/src/gismo_core/abc/__init__.py b/src/gismo_core/abc/__init__.py new file mode 100644 index 0000000..425ab6c --- /dev/null +++ b/src/gismo_core/abc/__init__.py @@ -0,0 +1 @@ +# imports diff --git a/src/gismo_core/abc/bot_service_abc.py b/src/gismo_core/abc/bot_service_abc.py new file mode 100644 index 0000000..62972ca --- /dev/null +++ b/src/gismo_core/abc/bot_service_abc.py @@ -0,0 +1,13 @@ +from abc import ABC, abstractmethod + + +class BotServiceABC(ABC): + + @abstractmethod + def __init__(self): pass + + @abstractmethod + async def run(self): pass + + @abstractmethod + async def exit(self): pass diff --git a/src/gismo_core/configuration/__init__.py b/src/gismo_core/configuration/__init__.py new file mode 100644 index 0000000..425ab6c --- /dev/null +++ b/src/gismo_core/configuration/__init__.py @@ -0,0 +1 @@ +# imports diff --git a/src/gismo_core/configuration/discord_settings.py b/src/gismo_core/configuration/discord_settings.py new file mode 100644 index 0000000..948729c --- /dev/null +++ b/src/gismo_core/configuration/discord_settings.py @@ -0,0 +1,23 @@ +import traceback + +from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC +from cpl_core.console import Console + + +class DiscordSettings(ConfigurationModelABC): + + def __init__(self): + ConfigurationModelABC.__init__(self) + + self._token: str = '' + + @property + def token(self) -> str: + return self._token + + def from_dict(self, settings: dict): + try: + self._token = settings['Token'] + except Exception as e: + Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings') + Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}') diff --git a/src/gismo_core/services/__init__.py b/src/gismo_core/services/__init__.py new file mode 100644 index 0000000..425ab6c --- /dev/null +++ b/src/gismo_core/services/__init__.py @@ -0,0 +1 @@ +# imports diff --git a/src/gismo_core/services/bot_service.py b/src/gismo_core/services/bot_service.py new file mode 100644 index 0000000..e70f973 --- /dev/null +++ b/src/gismo_core/services/bot_service.py @@ -0,0 +1,15 @@ +from gismo_core.abc.bot_service_abc import BotServiceABC +from gismo_core.configuration.discord_settings import DiscordSettings + + +class BotService(BotServiceABC): + + def __init__(self, discord_settings: DiscordSettings): + # setup self + commands.Bot.__init__(self, command_prefix=discord_settings.bot.prefix, help_command=None) + + async def run(self): + pass + + async def exit(self): + pass -- 2.45.2 From abe9a7b472e6ee87924cf994ec9397a729cf1629 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 19:36:39 +0100 Subject: [PATCH 011/113] Improved files --- .vscode/settings.json | 2 +- src/gismo/application.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 7786c39..3062c47 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -22,5 +22,5 @@ "titleBar.inactiveForeground": "#15202b99" }, "peacock.color": "#f9e64f", - "python.pythonPath": "venv/bin/python", + "python.pythonPath": "${workspaceRoot}/venv/bin/python", } \ No newline at end of file diff --git a/src/gismo/application.py b/src/gismo/application.py index a85f7d3..573a1e5 100644 --- a/src/gismo/application.py +++ b/src/gismo/application.py @@ -1,3 +1,12 @@ +from cpl_core.application import ApplicationABC +from cpl_core.configuration import ConfigurationABC +from cpl_core.dependency_injection import ServiceProviderABC +from cpl_core.logging import LoggerABC + +from gismo_core.abc.bot_service_abc import BotServiceABC +from gismo_core.services.bot_service import BotService + + class Application(ApplicationABC): def __init__(self, config: ConfigurationABC, services: ServiceProviderABC): -- 2.45.2 From 26a93c5ea1c24a5a52b35578e5456cd3e8f7dd1f Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 20:34:15 +0100 Subject: [PATCH 012/113] Added functionality to connect to discord web api --- src/gismo/__init__.py | 4 +++- src/gismo/application.py | 4 ++-- src/gismo/appsettings.development.json | 8 +++++++ src/gismo/appsettings.edrafts-pc.json | 3 --- src/gismo/appsettings.production.json | 8 +++++++ src/gismo/gismo.json | 3 ++- src/gismo/main.py | 8 +++---- src/gismo_core/abc/bot_service_abc.py | 8 +++---- src/gismo_core/configuration/bot_settings.py | 23 ++++++++++++++++++ src/gismo_core/services/bot_service.py | 25 ++++++++++++++------ 10 files changed, 72 insertions(+), 22 deletions(-) create mode 100644 src/gismo_core/configuration/bot_settings.py diff --git a/src/gismo/__init__.py b/src/gismo/__init__.py index 0242bb0..5411e9b 100644 --- a/src/gismo/__init__.py +++ b/src/gismo/__init__.py @@ -19,7 +19,9 @@ __version__ = '0.1.0' from collections import namedtuple -# imports: +# imports: +import nest_asyncio +nest_asyncio.apply() VersionInfo = namedtuple('VersionInfo', 'major minor micro') version_info = VersionInfo(major='0', minor='1', micro='0') diff --git a/src/gismo/application.py b/src/gismo/application.py index 573a1e5..c5bf158 100644 --- a/src/gismo/application.py +++ b/src/gismo/application.py @@ -20,6 +20,6 @@ class Application(ApplicationABC): async def main(self): try: - await self._bot.run() + await self._bot.start_async() except Exception as e: - self._logger.error(__name__, 'A fatal error occured starting the bot', e) + self._logger.error(__name__, 'Start failed', e) diff --git a/src/gismo/appsettings.development.json b/src/gismo/appsettings.development.json index c18c91e..f48a355 100644 --- a/src/gismo/appsettings.development.json +++ b/src/gismo/appsettings.development.json @@ -11,5 +11,13 @@ "Filename": "log_$start_time.log", "ConsoleLogLevel": "TRACE", "FileLogLevel": "TRACE" + }, + + "Discord": { + "Token": "OTA5ODc4NDcyNzExNzU3ODQ1.YZKsXA.BXBszIF3z3wHpoe9s3pKfO3Yd5c" + }, + + "Bot": { + "Prefix": "!dev-g" } } diff --git a/src/gismo/appsettings.edrafts-pc.json b/src/gismo/appsettings.edrafts-pc.json index 07e013f..2c63c08 100644 --- a/src/gismo/appsettings.edrafts-pc.json +++ b/src/gismo/appsettings.edrafts-pc.json @@ -1,5 +1,2 @@ { - "Discord": { - "Token": "" - } } diff --git a/src/gismo/appsettings.production.json b/src/gismo/appsettings.production.json index 629e6eb..c31e974 100644 --- a/src/gismo/appsettings.production.json +++ b/src/gismo/appsettings.production.json @@ -11,5 +11,13 @@ "Filename": "log_$start_time.log", "ConsoleLogLevel": "ERROR", "FileLogLevel": "WARN" + }, + + "Discord": { + "Token": "OTA5ODc3NDg3MjEzODk5ODQ3.YZKrcQ.qwfDWBFdkOzxZZT10jUWG5fY2RA" + }, + + "Bot": { + "Prefix": "!g" } } diff --git a/src/gismo/gismo.json b/src/gismo/gismo.json index b8a447a..95a329a 100644 --- a/src/gismo/gismo.json +++ b/src/gismo/gismo.json @@ -18,7 +18,8 @@ "Dependencies": [ "sh_cpl-core>=2021.10.2", "sh_cpl-query>=2021.10.2", - "discord.py==1.7.3" + "discord.py==1.7.3", + "nest-asyncio==1.5.1" ], "PythonVersion": ">=3.9.2", "PythonPath": { diff --git a/src/gismo/main.py b/src/gismo/main.py index 808c102..ad64e2d 100644 --- a/src/gismo/main.py +++ b/src/gismo/main.py @@ -1,15 +1,15 @@ import asyncio -from cpl_core.application import ApplicationBuilder +from cpl_core.application import ApplicationBuilder, ApplicationABC -from application import Application -from startup import Startup +from gismo.application import Application +from gismo.startup import Startup async def main(): app_builder = ApplicationBuilder(Application) app_builder.use_startup(Startup) - app: Application = await app_builder.build_async() + app: ApplicationABC = await app_builder.build_async() await app.run_async() diff --git a/src/gismo_core/abc/bot_service_abc.py b/src/gismo_core/abc/bot_service_abc.py index 62972ca..458cd95 100644 --- a/src/gismo_core/abc/bot_service_abc.py +++ b/src/gismo_core/abc/bot_service_abc.py @@ -5,9 +5,9 @@ class BotServiceABC(ABC): @abstractmethod def __init__(self): pass - + @abstractmethod - async def run(self): pass - + async def start_async(self): pass + @abstractmethod - async def exit(self): pass + async def stop_async(self): pass diff --git a/src/gismo_core/configuration/bot_settings.py b/src/gismo_core/configuration/bot_settings.py new file mode 100644 index 0000000..e682e25 --- /dev/null +++ b/src/gismo_core/configuration/bot_settings.py @@ -0,0 +1,23 @@ +import traceback + +from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC +from cpl_core.console import Console + + +class BotSettings(ConfigurationModelABC): + + def __init__(self): + ConfigurationModelABC.__init__(self) + + self._prefix: str = '' + + @property + def prefix(self) -> str: + return self._prefix + + def from_dict(self, settings: dict): + try: + self._prefix = settings['Prefix'] + except Exception as e: + Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings') + Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}') diff --git a/src/gismo_core/services/bot_service.py b/src/gismo_core/services/bot_service.py index e70f973..ceff6de 100644 --- a/src/gismo_core/services/bot_service.py +++ b/src/gismo_core/services/bot_service.py @@ -1,15 +1,26 @@ +from cpl_core.logging import LoggerABC +from discord.ext import commands + from gismo_core.abc.bot_service_abc import BotServiceABC +from gismo_core.configuration.bot_settings import BotSettings from gismo_core.configuration.discord_settings import DiscordSettings -class BotService(BotServiceABC): +class BotService(BotServiceABC, commands.Bot): - def __init__(self, discord_settings: DiscordSettings): + def __init__(self, logger: LoggerABC, discord_settings: DiscordSettings, bot_settings: BotSettings): + self._logger = logger + self._discord_settings = discord_settings + self._bot_settings: BotSettings = bot_settings # setup self - commands.Bot.__init__(self, command_prefix=discord_settings.bot.prefix, help_command=None) + commands.Bot.__init__(self, command_prefix=bot_settings.prefix, help_command=None) - async def run(self): - pass + async def start_async(self): + self.run(self._discord_settings.token) - async def exit(self): - pass + async def stop_async(self): + try: + pass + # save data + except Exception as e: + self._logger.error(__name__, 'Stop failed', e) -- 2.45.2 From a3bf5535f6e42ee61d4b53964c33c408a8b7a001 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 20:38:57 +0100 Subject: [PATCH 013/113] Improved BootLog module --- src/modules/__init__.py | 0 src/modules/boot_log/main.py | 28 +++++++++------------------- 2 files changed, 9 insertions(+), 19 deletions(-) create mode 100644 src/modules/__init__.py diff --git a/src/modules/__init__.py b/src/modules/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/modules/boot_log/main.py b/src/modules/boot_log/main.py index f716961..592134f 100644 --- a/src/modules/boot_log/main.py +++ b/src/modules/boot_log/main.py @@ -1,23 +1,13 @@ -from cpl_core.configuration import Configuration, ConfigurationABC -from cpl_core.console import Console -from cpl_core.dependency_injection import ServiceCollection, ServiceProviderABC +from cpl_core.logging import LoggerABC + +from gismo_core.abc.bot_service_abc import BotServiceABC -def configure_configuration() -> ConfigurationABC: - config = Configuration() - return config +class BootLog: + def __init__(self, logger: LoggerABC, bot: BotServiceABC): + self._logger = logger + self._bot = bot -def configure_services(config: ConfigurationABC) -> ServiceProviderABC: - services = ServiceCollection(config) - return services.build_service_provider() - - -def main(): - config = configure_configuration() - provider = configure_services(config) - Console.write_line('Hello World') - - -if __name__ == '__main__': - main() + def on_ready(self): + self._logger.info(__name__, f'Bot started: {self._bot}') -- 2.45.2 From 562caeb10b7765d1dbc17c38a6948f1ae9a18ce7 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 21:23:06 +0100 Subject: [PATCH 014/113] Added support for dynamic loaded modules --- .vscode/launch.json | 31 +++++++++++++++++++ src/gismo/application.py | 3 +- src/gismo/startup.py | 17 +++++++--- .../{services => service}/__init__.py | 0 .../{services => service}/bot_service.py | 14 +++++++-- src/modules/boot_log/main.py | 9 ++++-- src/modules_core/__init__.py | 26 +--------------- src/modules_core/abc/__init__.py | 1 + src/modules_core/abc/module_abc.py | 7 +++++ src/modules_core/abc/module_service_abc.py | 14 +++++++++ src/modules_core/service/__init__.py | 1 + src/modules_core/service/module_service.py | 21 +++++++++++++ 12 files changed, 110 insertions(+), 34 deletions(-) create mode 100644 .vscode/launch.json rename src/gismo_core/{services => service}/__init__.py (100%) rename src/gismo_core/{services => service}/bot_service.py (65%) create mode 100644 src/modules_core/abc/__init__.py create mode 100644 src/modules_core/abc/module_abc.py create mode 100644 src/modules_core/abc/module_service_abc.py create mode 100644 src/modules_core/service/__init__.py create mode 100644 src/modules_core/service/module_service.py diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..255ae11 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,31 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Aktuelle Datei", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal" + }, + { + "name": "Gismo", + "type": "python", + "request": "launch", + "cwd": "${workspaceFolder}/src/gismo", + "program": "main.py", + "console": "integratedTerminal", + "args": [ + "--customer=sh-edraft.de" + ], + "env": { + "CPL_NAME": "Gismo", + "GISMO_ENVIRONMENT": "development", + "PYTHONPATH": "${workspaceFolder}/src/:$PATHONPATH" + } + } + ] +} \ No newline at end of file diff --git a/src/gismo/application.py b/src/gismo/application.py index c5bf158..a000017 100644 --- a/src/gismo/application.py +++ b/src/gismo/application.py @@ -4,7 +4,8 @@ from cpl_core.dependency_injection import ServiceProviderABC from cpl_core.logging import LoggerABC from gismo_core.abc.bot_service_abc import BotServiceABC -from gismo_core.services.bot_service import BotService +from gismo_core.service.bot_service import BotService +from modules_core.abc.module_service_abc import ModuleServiceABC class Application(ApplicationABC): diff --git a/src/gismo/startup.py b/src/gismo/startup.py index 333f888..9155d35 100644 --- a/src/gismo/startup.py +++ b/src/gismo/startup.py @@ -1,10 +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.configuration import ConfigurationABC, ConsoleArgument +from cpl_core.console.console import Console +from cpl_core.dependency_injection import (ServiceCollectionABC, + ServiceProviderABC) from cpl_core.environment import ApplicationEnvironment from gismo_core.abc.bot_service_abc import BotServiceABC -from gismo_core.services.bot_service import BotService +from gismo_core.service.bot_service import BotService +from modules.boot_log.main import BootLog +from modules_core.abc.module_abc import ModuleABC +from modules_core.abc.module_service_abc import ModuleServiceABC +from modules_core.service.module_service import ModuleService class Startup(StartupABC): @@ -14,7 +20,7 @@ class Startup(StartupABC): async def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC: configuration.add_environment_variables('GISMO_') - configuration.add_console_arguments() + configuration.add_json_file(f'appsettings.json', optional=False) configuration.add_json_file(f'appsettings.{environment.environment_name}.json', optional=True) configuration.add_json_file(f'appsettings.{environment.host_name}.json', optional=True) @@ -24,6 +30,9 @@ class Startup(StartupABC): async def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC: services.add_logging() + services.add_singleton(ModuleServiceABC, ModuleService) services.add_singleton(BotServiceABC, BotService) + + services.add_singleton(ModuleABC, BootLog) return services.build_service_provider() diff --git a/src/gismo_core/services/__init__.py b/src/gismo_core/service/__init__.py similarity index 100% rename from src/gismo_core/services/__init__.py rename to src/gismo_core/service/__init__.py diff --git a/src/gismo_core/services/bot_service.py b/src/gismo_core/service/bot_service.py similarity index 65% rename from src/gismo_core/services/bot_service.py rename to src/gismo_core/service/bot_service.py index ceff6de..da34f9c 100644 --- a/src/gismo_core/services/bot_service.py +++ b/src/gismo_core/service/bot_service.py @@ -4,19 +4,27 @@ from discord.ext import commands from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.configuration.bot_settings import BotSettings from gismo_core.configuration.discord_settings import DiscordSettings +from modules_core.abc.module_service_abc import ModuleServiceABC class BotService(BotServiceABC, commands.Bot): - def __init__(self, logger: LoggerABC, discord_settings: DiscordSettings, bot_settings: BotSettings): + def __init__(self, logger: LoggerABC, modules: ModuleServiceABC, discord_settings: DiscordSettings, bot_settings: BotSettings): + # services self._logger = logger + self._modules = modules + + # settings self._discord_settings = discord_settings self._bot_settings: BotSettings = bot_settings - # setup self + + # setup super commands.Bot.__init__(self, command_prefix=bot_settings.prefix, help_command=None) async def start_async(self): + self._modules.start_modules() self.run(self._discord_settings.token) + # continue at on_ready async def stop_async(self): try: @@ -24,3 +32,5 @@ class BotService(BotServiceABC, commands.Bot): # save data except Exception as e: self._logger.error(__name__, 'Stop failed', e) + + async def on_ready(self): pass diff --git a/src/modules/boot_log/main.py b/src/modules/boot_log/main.py index 592134f..70634f0 100644 --- a/src/modules/boot_log/main.py +++ b/src/modules/boot_log/main.py @@ -1,13 +1,18 @@ from cpl_core.logging import LoggerABC from gismo_core.abc.bot_service_abc import BotServiceABC +from modules_core.abc.module_abc import ModuleABC +from modules_core.abc.module_service_abc import ModuleServiceABC -class BootLog: +class BootLog(ModuleABC): - def __init__(self, logger: LoggerABC, bot: BotServiceABC): + def __init__(self, logger: LoggerABC, modules: ModuleServiceABC, bot: BotServiceABC): self._logger = logger + self._modules = modules self._bot = bot + modules.register(self) + def on_ready(self): self._logger.info(__name__, f'Bot started: {self._bot}') diff --git a/src/modules_core/__init__.py b/src/modules_core/__init__.py index 5a29729..425ab6c 100644 --- a/src/modules_core/__init__.py +++ b/src/modules_core/__init__.py @@ -1,25 +1 @@ -# -*- coding: utf-8 -*- - -""" -gismo sh-edraft Gismo -~~~~~~~~~~~~~~~~~~~ - -sh-edraft Dicord bot Gismo - -:copyright: (c) 2021 - 2022 sh-edraft.de -:license: MIT, see LICENSE for more details. - -""" - -__title__ = 'modules_core' -__author__ = 'Sven Heidemann' -__license__ = 'MIT' -__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' -__version__ = '0.1.0' - -from collections import namedtuple - -# imports: - -VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='0', minor='1', micro='0') +# imports diff --git a/src/modules_core/abc/__init__.py b/src/modules_core/abc/__init__.py new file mode 100644 index 0000000..425ab6c --- /dev/null +++ b/src/modules_core/abc/__init__.py @@ -0,0 +1 @@ +# imports diff --git a/src/modules_core/abc/module_abc.py b/src/modules_core/abc/module_abc.py new file mode 100644 index 0000000..bdf1b63 --- /dev/null +++ b/src/modules_core/abc/module_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class ModuleABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/module_service_abc.py b/src/modules_core/abc/module_service_abc.py new file mode 100644 index 0000000..b510857 --- /dev/null +++ b/src/modules_core/abc/module_service_abc.py @@ -0,0 +1,14 @@ +from abc import ABC, abstractmethod +from codecs import register + + +class ModuleServiceABC(ABC): + + @abstractmethod + def __init__(self): pass + + @abstractmethod + def register(self): pass + + @abstractmethod + def start_modules(self): pass diff --git a/src/modules_core/service/__init__.py b/src/modules_core/service/__init__.py new file mode 100644 index 0000000..425ab6c --- /dev/null +++ b/src/modules_core/service/__init__.py @@ -0,0 +1 @@ +# imports diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py new file mode 100644 index 0000000..de14dd7 --- /dev/null +++ b/src/modules_core/service/module_service.py @@ -0,0 +1,21 @@ +from cpl_core.environment.application_environment_abc import \ + ApplicationEnvironmentABC +from cpl_core.logging import LoggerABC +from cpl_query.extension import List + +from modules_core.abc.module_abc import ModuleABC +from modules_core.abc.module_service_abc import ModuleServiceABC + + +class ModuleService(ModuleServiceABC): + + def __init__(self, logger: LoggerABC, env: ApplicationEnvironmentABC): + self._logger = logger + self._env = env + self._modules: List[ModuleABC] = List() + + def register(self, module: ModuleABC): + self._modules.append(module) + + def start_modules(self): + self._modules.for_each(lambda m: m.echo()) -- 2.45.2 From 4763c41b1084d3af1a64b0b7c3b940fe6d136dfa Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 21:25:57 +0100 Subject: [PATCH 015/113] Improved log statements --- src/gismo_core/service/bot_service.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gismo_core/service/bot_service.py b/src/gismo_core/service/bot_service.py index da34f9c..3baba01 100644 --- a/src/gismo_core/service/bot_service.py +++ b/src/gismo_core/service/bot_service.py @@ -22,7 +22,11 @@ class BotService(BotServiceABC, commands.Bot): commands.Bot.__init__(self, command_prefix=bot_settings.prefix, help_command=None) async def start_async(self): + self._logger.trace(__name__, 'Loading modules:') self._modules.start_modules() + self._logger.trace(__name__, 'Finished loading modules') + + self._logger.trace(__name__, 'Try to connect to discord') self.run(self._discord_settings.token) # continue at on_ready @@ -32,5 +36,3 @@ class BotService(BotServiceABC, commands.Bot): # save data except Exception as e: self._logger.error(__name__, 'Stop failed', e) - - async def on_ready(self): pass -- 2.45.2 From f2ee3d64f612217b5fbec7f0fb920f290e231ff4 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 21:52:28 +0100 Subject: [PATCH 016/113] Improved dynamic modules support --- src/gismo/startup.py | 4 ++-- src/gismo_core/service/bot_service.py | 8 ++++---- src/modules/boot_log/main.py | 10 +++++----- src/modules_core/abc/module_abc.py | 6 ++++++ src/modules_core/abc/module_service_abc.py | 5 +---- src/modules_core/events_enum.py | 6 ++++++ src/modules_core/service/module_service.py | 22 ++++++++++++++++------ 7 files changed, 40 insertions(+), 21 deletions(-) create mode 100644 src/modules_core/events_enum.py diff --git a/src/gismo/startup.py b/src/gismo/startup.py index 9155d35..020f76f 100644 --- a/src/gismo/startup.py +++ b/src/gismo/startup.py @@ -32,7 +32,7 @@ class Startup(StartupABC): services.add_singleton(ModuleServiceABC, ModuleService) services.add_singleton(BotServiceABC, BotService) - - services.add_singleton(ModuleABC, BootLog) + + services.add_transient(ModuleABC, BootLog) return services.build_service_provider() diff --git a/src/gismo_core/service/bot_service.py b/src/gismo_core/service/bot_service.py index 3baba01..b284d59 100644 --- a/src/gismo_core/service/bot_service.py +++ b/src/gismo_core/service/bot_service.py @@ -22,13 +22,12 @@ class BotService(BotServiceABC, commands.Bot): commands.Bot.__init__(self, command_prefix=bot_settings.prefix, help_command=None) async def start_async(self): - self._logger.trace(__name__, 'Loading modules:') - self._modules.start_modules() - self._logger.trace(__name__, 'Finished loading modules') - self._logger.trace(__name__, 'Try to connect to discord') self.run(self._discord_settings.token) # continue at on_ready + + async def on_ready(self): + await self._modules.start_modules() async def stop_async(self): try: @@ -36,3 +35,4 @@ class BotService(BotServiceABC, commands.Bot): # save data except Exception as e: self._logger.error(__name__, 'Stop failed', e) + diff --git a/src/modules/boot_log/main.py b/src/modules/boot_log/main.py index 70634f0..6a46716 100644 --- a/src/modules/boot_log/main.py +++ b/src/modules/boot_log/main.py @@ -7,12 +7,12 @@ from modules_core.abc.module_service_abc import ModuleServiceABC class BootLog(ModuleABC): - def __init__(self, logger: LoggerABC, modules: ModuleServiceABC, bot: BotServiceABC): + def __init__(self, logger: LoggerABC, bot: BotServiceABC): self._logger = logger - self._modules = modules self._bot = bot + + self._logger.info(__name__, 'LOADED') + ModuleABC.__init__(self) - modules.register(self) - - def on_ready(self): + async def on_ready(self): self._logger.info(__name__, f'Bot started: {self._bot}') diff --git a/src/modules_core/abc/module_abc.py b/src/modules_core/abc/module_abc.py index bdf1b63..836c29a 100644 --- a/src/modules_core/abc/module_abc.py +++ b/src/modules_core/abc/module_abc.py @@ -1,7 +1,13 @@ from abc import ABC, abstractmethod +from cpl_query.extension import List +from modules_core.events_enum import EventsEnum class ModuleABC(ABC): @abstractmethod def __init__(self): pass + + # @property + # @abstractmethod + # def events(self) -> List[EventsEnum]: pass diff --git a/src/modules_core/abc/module_service_abc.py b/src/modules_core/abc/module_service_abc.py index b510857..0d906ca 100644 --- a/src/modules_core/abc/module_service_abc.py +++ b/src/modules_core/abc/module_service_abc.py @@ -8,7 +8,4 @@ class ModuleServiceABC(ABC): def __init__(self): pass @abstractmethod - def register(self): pass - - @abstractmethod - def start_modules(self): pass + async def start_modules(self): pass diff --git a/src/modules_core/events_enum.py b/src/modules_core/events_enum.py new file mode 100644 index 0000000..fafe57e --- /dev/null +++ b/src/modules_core/events_enum.py @@ -0,0 +1,6 @@ +from enum import Enum + + +class EventsEnum(Enum): + + on_ready = 'on_ready' diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index de14dd7..359d9e6 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -1,7 +1,13 @@ +from os import path + +import discord +from cpl_core.dependency_injection.service_provider_abc import \ + ServiceProviderABC from cpl_core.environment.application_environment_abc import \ ApplicationEnvironmentABC from cpl_core.logging import LoggerABC from cpl_query.extension import List +from discord.ext import commands from modules_core.abc.module_abc import ModuleABC from modules_core.abc.module_service_abc import ModuleServiceABC @@ -9,13 +15,17 @@ from modules_core.abc.module_service_abc import ModuleServiceABC class ModuleService(ModuleServiceABC): - def __init__(self, logger: LoggerABC, env: ApplicationEnvironmentABC): + def __init__(self, logger: LoggerABC, services: ServiceProviderABC, env: ApplicationEnvironmentABC): self._logger = logger + self._services = services self._env = env self._modules: List[ModuleABC] = List() + self._modules.extend(ModuleABC.__subclasses__()) - def register(self, module: ModuleABC): - self._modules.append(module) - - def start_modules(self): - self._modules.for_each(lambda m: m.echo()) + async def start_modules(self): + self._logger.info(__name__, self._modules) + modules = self._modules.where(lambda m: hasattr(m, 'on_ready')) + self._logger.info(__name__, f'HIER: {modules}') + for module_type in modules: + module = self._services.get_service(module_type) + await module.on_ready() -- 2.45.2 From 647e847d17eb8db2d4537f4d4a86ecb5ad0d81b6 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 15 Nov 2021 21:54:06 +0100 Subject: [PATCH 017/113] Improved logging --- src/modules/boot_log/main.py | 7 ++----- src/modules_core/service/module_service.py | 4 +--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/modules/boot_log/main.py b/src/modules/boot_log/main.py index 6a46716..23ba19f 100644 --- a/src/modules/boot_log/main.py +++ b/src/modules/boot_log/main.py @@ -7,12 +7,9 @@ from modules_core.abc.module_service_abc import ModuleServiceABC class BootLog(ModuleABC): - def __init__(self, logger: LoggerABC, bot: BotServiceABC): + def __init__(self, logger: LoggerABC): self._logger = logger - self._bot = bot - - self._logger.info(__name__, 'LOADED') ModuleABC.__init__(self) async def on_ready(self): - self._logger.info(__name__, f'Bot started: {self._bot}') + self._logger.info(__name__, f'Bot started') diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index 359d9e6..e7264a5 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -23,9 +23,7 @@ class ModuleService(ModuleServiceABC): self._modules.extend(ModuleABC.__subclasses__()) async def start_modules(self): - self._logger.info(__name__, self._modules) - modules = self._modules.where(lambda m: hasattr(m, 'on_ready')) - self._logger.info(__name__, f'HIER: {modules}') + modules = self._modules.where(lambda m: hasattr(m, 'on_ready') and callable(m.on_ready)) for module_type in modules: module = self._services.get_service(module_type) await module.on_ready() -- 2.45.2 From d413ace7215a1217e389f04bd9dd8acc171736e2 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 16 Nov 2021 09:12:44 +0100 Subject: [PATCH 018/113] Improved BootLog module --- .vscode/settings.json | 3 --- src/gismo/main.py | 2 ++ src/gismo/startup.py | 2 +- src/modules/boot_log/boot_log.py | 22 ++++++++++++++++++++++ src/modules/boot_log/boot_log_extension.py | 19 +++++++++++++++++++ src/modules/boot_log/main.py | 15 --------------- 6 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 src/modules/boot_log/boot_log.py create mode 100644 src/modules/boot_log/boot_log_extension.py delete mode 100644 src/modules/boot_log/main.py diff --git a/.vscode/settings.json b/.vscode/settings.json index 3062c47..10cee69 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,10 +7,7 @@ "activityBar.inactiveForeground": "#15202b99", "activityBarBadge.background": "#06b9a5", "activityBarBadge.foreground": "#15202b", - "editorGroup.border": "#fbed80", - "panel.border": "#fbed80", "sash.hoverBorder": "#fbed80", - "sideBar.border": "#fbed80", "statusBar.background": "#f9e64f", "statusBar.foreground": "#15202b", "statusBarItem.hoverBackground": "#f7df1e", diff --git a/src/gismo/main.py b/src/gismo/main.py index ad64e2d..98aa58b 100644 --- a/src/gismo/main.py +++ b/src/gismo/main.py @@ -4,10 +4,12 @@ from cpl_core.application import ApplicationBuilder, ApplicationABC from gismo.application import Application from gismo.startup import Startup +from modules.boot_log.boot_log_extension import BootLogExtension async def main(): app_builder = ApplicationBuilder(Application) + app_builder.use_extension(BootLogExtension) app_builder.use_startup(Startup) app: ApplicationABC = await app_builder.build_async() await app.run_async() diff --git a/src/gismo/startup.py b/src/gismo/startup.py index 020f76f..bfe0155 100644 --- a/src/gismo/startup.py +++ b/src/gismo/startup.py @@ -7,7 +7,7 @@ from cpl_core.environment import ApplicationEnvironment from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.service.bot_service import BotService -from modules.boot_log.main import BootLog +from modules.boot_log.boot_log import BootLog from modules_core.abc.module_abc import ModuleABC from modules_core.abc.module_service_abc import ModuleServiceABC from modules_core.service.module_service import ModuleService diff --git a/src/modules/boot_log/boot_log.py b/src/modules/boot_log/boot_log.py new file mode 100644 index 0000000..83a03a0 --- /dev/null +++ b/src/modules/boot_log/boot_log.py @@ -0,0 +1,22 @@ +from datetime import datetime + +from cpl_core.configuration.configuration_abc import ConfigurationABC +from cpl_core.logging import LoggerABC + +from gismo_core.abc.bot_service_abc import BotServiceABC +from modules_core.abc.module_abc import ModuleABC +from modules_core.abc.module_service_abc import ModuleServiceABC + + +class BootLog(ModuleABC): + + def __init__(self, config: ConfigurationABC, logger: LoggerABC): + self._config = config + self._logger = logger + ModuleABC.__init__(self) + + async def on_ready(self): + self._logger.info(__name__, f'Bot started') + start_time = self._config.get_configuration('StartTime') + init_time = round((datetime.now() - start_time).total_seconds(), 2) + self._logger.debug(__name__, f'InitTime: {init_time}s') diff --git a/src/modules/boot_log/boot_log_extension.py b/src/modules/boot_log/boot_log_extension.py new file mode 100644 index 0000000..8bd8e36 --- /dev/null +++ b/src/modules/boot_log/boot_log_extension.py @@ -0,0 +1,19 @@ +from datetime import datetime + +from cpl_core.application.application_extension_abc import \ + ApplicationExtensionABC +from cpl_core.configuration.configuration_abc import ConfigurationABC +from cpl_core.dependency_injection.service_provider_abc import \ + ServiceProviderABC +from cpl_core.logging import LoggerABC + + +class BootLogExtension(ApplicationExtensionABC): + + def __init__(self): + pass + + async def run(self, config: ConfigurationABC, services: ServiceProviderABC): + logger: LoggerABC = services.get_service(LoggerABC) + logger.trace(__name__, 'Boot extension started') + config.add_configuration('StartTime', datetime.now()) diff --git a/src/modules/boot_log/main.py b/src/modules/boot_log/main.py deleted file mode 100644 index 23ba19f..0000000 --- a/src/modules/boot_log/main.py +++ /dev/null @@ -1,15 +0,0 @@ -from cpl_core.logging import LoggerABC - -from gismo_core.abc.bot_service_abc import BotServiceABC -from modules_core.abc.module_abc import ModuleABC -from modules_core.abc.module_service_abc import ModuleServiceABC - - -class BootLog(ModuleABC): - - def __init__(self, logger: LoggerABC): - self._logger = logger - ModuleABC.__init__(self) - - async def on_ready(self): - self._logger.info(__name__, f'Bot started') -- 2.45.2 From 9c25ec9f2426adaa86be82ee58e3275b823be0e6 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 16 Nov 2021 09:41:55 +0100 Subject: [PATCH 019/113] Improved logging for BootLog module --- src/gismo_core/abc/bot_service_abc.py | 4 +++- src/modules/boot_log/boot_log.py | 30 +++++++++++++++++++++------ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/gismo_core/abc/bot_service_abc.py b/src/gismo_core/abc/bot_service_abc.py index 458cd95..5ce856e 100644 --- a/src/gismo_core/abc/bot_service_abc.py +++ b/src/gismo_core/abc/bot_service_abc.py @@ -1,7 +1,9 @@ from abc import ABC, abstractmethod +from discord.ext import commands -class BotServiceABC(ABC): + +class BotServiceABC(ABC, commands.Bot): @abstractmethod def __init__(self): pass diff --git a/src/modules/boot_log/boot_log.py b/src/modules/boot_log/boot_log.py index 83a03a0..1a20b15 100644 --- a/src/modules/boot_log/boot_log.py +++ b/src/modules/boot_log/boot_log.py @@ -1,22 +1,40 @@ from datetime import datetime from cpl_core.configuration.configuration_abc import ConfigurationABC -from cpl_core.logging import LoggerABC +from cpl_core.console import Console +from cpl_core.logging import LoggerABC, LoggingLevelEnum +from cpl_core.logging.logging_settings import LoggingSettings from gismo_core.abc.bot_service_abc import BotServiceABC from modules_core.abc.module_abc import ModuleABC -from modules_core.abc.module_service_abc import ModuleServiceABC class BootLog(ModuleABC): - def __init__(self, config: ConfigurationABC, logger: LoggerABC): + def __init__(self, config: ConfigurationABC, logging_st: LoggingSettings, logger: LoggerABC, bot: BotServiceABC): self._config = config + self._logging_st = logging_st self._logger = logger + self._bot = bot ModuleABC.__init__(self) async def on_ready(self): self._logger.info(__name__, f'Bot started') - start_time = self._config.get_configuration('StartTime') - init_time = round((datetime.now() - start_time).total_seconds(), 2) - self._logger.debug(__name__, f'InitTime: {init_time}s') + try: + start_time = self._config.get_configuration('StartTime') + init_time = round((datetime.now() - start_time).total_seconds(), 2) + self._logger.info(__name__, f'Init time: {init_time}s') + # print warning if initialisation took too long + if init_time >= 30: + self._logger.warn(__name__, 'It takes long time to start the bot!') + + # print error if initialisation took way too long + elif init_time >= 90: + self._logger.error(__name__, 'It takes very long time to start the bot!!!') + except Exception as e: + self._logger.error(__name__, 'Init time calculation failed', e) + return + + self._logger.header(f'{self._bot.user.name}:') + if self._logging_st.console.value >= LoggingLevelEnum.INFO.value: + Console.banner(self._bot.user.name) \ No newline at end of file -- 2.45.2 From 16546b4d3c611ca569f4e7e18db8bb7e74f882d7 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 16 Nov 2021 11:12:42 +0100 Subject: [PATCH 020/113] Improved imports --- src/gismo/startup.py | 6 ++---- src/modules/boot_log/boot_log.py | 5 ++--- src/modules/boot_log/boot_log_extension.py | 8 +++----- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/gismo/startup.py b/src/gismo/startup.py index bfe0155..4e8120e 100644 --- a/src/gismo/startup.py +++ b/src/gismo/startup.py @@ -1,8 +1,6 @@ from cpl_core.application import StartupABC -from cpl_core.configuration import ConfigurationABC, ConsoleArgument -from cpl_core.console.console import Console -from cpl_core.dependency_injection import (ServiceCollectionABC, - ServiceProviderABC) +from cpl_core.configuration import ConfigurationABC +from cpl_core.dependency_injection import ServiceCollectionABC, ServiceProviderABC from cpl_core.environment import ApplicationEnvironment from gismo_core.abc.bot_service_abc import BotServiceABC diff --git a/src/modules/boot_log/boot_log.py b/src/modules/boot_log/boot_log.py index 1a20b15..a28dad1 100644 --- a/src/modules/boot_log/boot_log.py +++ b/src/modules/boot_log/boot_log.py @@ -1,9 +1,8 @@ from datetime import datetime -from cpl_core.configuration.configuration_abc import ConfigurationABC +from cpl_core.configuration import ConfigurationABC from cpl_core.console import Console -from cpl_core.logging import LoggerABC, LoggingLevelEnum -from cpl_core.logging.logging_settings import LoggingSettings +from cpl_core.logging import LoggerABC, LoggingLevelEnum, LoggingSettings from gismo_core.abc.bot_service_abc import BotServiceABC from modules_core.abc.module_abc import ModuleABC diff --git a/src/modules/boot_log/boot_log_extension.py b/src/modules/boot_log/boot_log_extension.py index 8bd8e36..c651cbf 100644 --- a/src/modules/boot_log/boot_log_extension.py +++ b/src/modules/boot_log/boot_log_extension.py @@ -1,10 +1,8 @@ from datetime import datetime -from cpl_core.application.application_extension_abc import \ - ApplicationExtensionABC -from cpl_core.configuration.configuration_abc import ConfigurationABC -from cpl_core.dependency_injection.service_provider_abc import \ - ServiceProviderABC +from cpl_core.application.application_extension_abc import ApplicationExtensionABC +from cpl_core.configuration import ConfigurationABC +from cpl_core.dependency_injection import ServiceProviderABC from cpl_core.logging import LoggerABC -- 2.45.2 From 2176037d08b60ac94c018a3884e5ed1576d21a7a Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 16 Nov 2021 11:41:34 +0100 Subject: [PATCH 021/113] Improved logging --- src/gismo/application.py | 1 + src/gismo/appsettings.edrafts-lapi.json | 2 ++ src/gismo/startup.py | 22 ++++++++++++++++++++-- src/gismo_core/service/bot_service.py | 2 ++ src/modules/boot_log/boot_log.py | 12 ++++++++---- src/modules/boot_log/boot_log_extension.py | 4 ++-- src/modules_core/service/module_service.py | 8 +++----- 7 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 src/gismo/appsettings.edrafts-lapi.json diff --git a/src/gismo/application.py b/src/gismo/application.py index a000017..51cf465 100644 --- a/src/gismo/application.py +++ b/src/gismo/application.py @@ -21,6 +21,7 @@ class Application(ApplicationABC): async def main(self): try: + self._logger.trace(__name__, f'Try to start {BotService}') await self._bot.start_async() except Exception as e: self._logger.error(__name__, 'Start failed', e) diff --git a/src/gismo/appsettings.edrafts-lapi.json b/src/gismo/appsettings.edrafts-lapi.json new file mode 100644 index 0000000..2c63c08 --- /dev/null +++ b/src/gismo/appsettings.edrafts-lapi.json @@ -0,0 +1,2 @@ +{ +} diff --git a/src/gismo/startup.py b/src/gismo/startup.py index 4e8120e..613d141 100644 --- a/src/gismo/startup.py +++ b/src/gismo/startup.py @@ -1,7 +1,12 @@ +from datetime import datetime +from typing import Optional + from cpl_core.application import StartupABC from cpl_core.configuration import ConfigurationABC -from cpl_core.dependency_injection import ServiceCollectionABC, ServiceProviderABC +from cpl_core.dependency_injection import (ServiceCollectionABC, + ServiceProviderABC) from cpl_core.environment import ApplicationEnvironment +from cpl_core.logging.logger_abc import LoggerABC from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.service.bot_service import BotService @@ -15,6 +20,9 @@ class Startup(StartupABC): def __init__(self): StartupABC.__init__(self) + self._start_time = datetime.now() + + self._config: Optional[ConfigurationABC] = None async def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC: configuration.add_environment_variables('GISMO_') @@ -23,6 +31,9 @@ class Startup(StartupABC): configuration.add_json_file(f'appsettings.{environment.environment_name}.json', optional=True) configuration.add_json_file(f'appsettings.{environment.host_name}.json', optional=True) + configuration.add_configuration('Startup_StartTime', self._start_time) + + self._config = configuration return configuration async def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC: @@ -33,4 +44,11 @@ class Startup(StartupABC): services.add_transient(ModuleABC, BootLog) - return services.build_service_provider() + provider: ServiceProviderABC = services.build_service_provider() + + startup_init_time = round((datetime.now() - self._config.get_configuration('Startup_StartTime')).total_seconds(), 2) + self._config.add_configuration('Startup_InitTime', startup_init_time) + logger: LoggerABC = provider.get_service(LoggerABC) + logger.debug(__name__, f'Startup Init time: {startup_init_time}s') + + return provider diff --git a/src/gismo_core/service/bot_service.py b/src/gismo_core/service/bot_service.py index b284d59..ce8e125 100644 --- a/src/gismo_core/service/bot_service.py +++ b/src/gismo_core/service/bot_service.py @@ -27,9 +27,11 @@ class BotService(BotServiceABC, commands.Bot): # continue at on_ready async def on_ready(self): + self._logger.info(__name__, 'Connected to discord') await self._modules.start_modules() async def stop_async(self): + self._logger.debug(__name__, f'Try to stop {BotService}') try: pass # save data diff --git a/src/modules/boot_log/boot_log.py b/src/modules/boot_log/boot_log.py index a28dad1..b02795b 100644 --- a/src/modules/boot_log/boot_log.py +++ b/src/modules/boot_log/boot_log.py @@ -16,13 +16,15 @@ class BootLog(ModuleABC): self._logger = logger self._bot = bot ModuleABC.__init__(self) + self._logger.trace(__name__, f'Module {type(self)} loaded') async def on_ready(self): - self._logger.info(__name__, f'Bot started') + self._logger.debug(__name__, f'Module {type(self)} started') try: - start_time = self._config.get_configuration('StartTime') + start_time = self._config.get_configuration('Bot_StartTime') init_time = round((datetime.now() - start_time).total_seconds(), 2) - self._logger.info(__name__, f'Init time: {init_time}s') + self._config.add_configuration('InitTime', init_time) + self._logger.debug(__name__, f'Bot Init time: {init_time}s') # print warning if initialisation took too long if init_time >= 30: self._logger.warn(__name__, 'It takes long time to start the bot!') @@ -36,4 +38,6 @@ class BootLog(ModuleABC): self._logger.header(f'{self._bot.user.name}:') if self._logging_st.console.value >= LoggingLevelEnum.INFO.value: - Console.banner(self._bot.user.name) \ No newline at end of file + Console.banner(self._bot.user.name) + + self._logger.trace(__name__, f'Module {type(self)} stopped') \ No newline at end of file diff --git a/src/modules/boot_log/boot_log_extension.py b/src/modules/boot_log/boot_log_extension.py index c651cbf..9d66642 100644 --- a/src/modules/boot_log/boot_log_extension.py +++ b/src/modules/boot_log/boot_log_extension.py @@ -13,5 +13,5 @@ class BootLogExtension(ApplicationExtensionABC): async def run(self, config: ConfigurationABC, services: ServiceProviderABC): logger: LoggerABC = services.get_service(LoggerABC) - logger.trace(__name__, 'Boot extension started') - config.add_configuration('StartTime', datetime.now()) + logger.debug(__name__, 'BootLog extension started') + config.add_configuration('Bot_StartTime', datetime.now()) diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index e7264a5..032f6b0 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -1,14 +1,11 @@ from os import path import discord -from cpl_core.dependency_injection.service_provider_abc import \ - ServiceProviderABC -from cpl_core.environment.application_environment_abc import \ - ApplicationEnvironmentABC +from cpl_core.dependency_injection import ServiceProviderABC +from cpl_core.environment import ApplicationEnvironmentABC from cpl_core.logging import LoggerABC from cpl_query.extension import List from discord.ext import commands - from modules_core.abc.module_abc import ModuleABC from modules_core.abc.module_service_abc import ModuleServiceABC @@ -23,6 +20,7 @@ class ModuleService(ModuleServiceABC): self._modules.extend(ModuleABC.__subclasses__()) async def start_modules(self): + self._logger.trace(__name__, 'Start loading modules') modules = self._modules.where(lambda m: hasattr(m, 'on_ready') and callable(m.on_ready)) for module_type in modules: module = self._services.get_service(module_type) -- 2.45.2 From d2c233a855b91b106ca6ad00dc45df7b7eee8160 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 16 Nov 2021 18:34:41 +0100 Subject: [PATCH 022/113] Improved bot startup logic --- src/gismo/__init__.py | 2 -- src/gismo/application.py | 2 +- src/gismo/appsettings.development.json | 10 +++++++- src/gismo/main.py | 3 +-- src/gismo/startup.py | 2 +- src/gismo_core/configuration/bot_settings.py | 17 ++++++++++++-- .../configuration/discord_settings.py | 2 +- .../configuration/server_settings.py | 23 +++++++++++++++++++ src/gismo_core/service/bot_service.py | 20 ++++++++++++---- src/modules/boot_log/boot_log.py | 13 +++++++++-- src/modules_core/abc/module_service_abc.py | 2 +- src/modules_core/service/module_service.py | 8 ++----- 12 files changed, 80 insertions(+), 24 deletions(-) create mode 100644 src/gismo_core/configuration/server_settings.py diff --git a/src/gismo/__init__.py b/src/gismo/__init__.py index 5411e9b..ca405f7 100644 --- a/src/gismo/__init__.py +++ b/src/gismo/__init__.py @@ -20,8 +20,6 @@ __version__ = '0.1.0' from collections import namedtuple # imports: -import nest_asyncio -nest_asyncio.apply() VersionInfo = namedtuple('VersionInfo', 'major minor micro') version_info = VersionInfo(major='0', minor='1', micro='0') diff --git a/src/gismo/application.py b/src/gismo/application.py index 51cf465..460d01a 100644 --- a/src/gismo/application.py +++ b/src/gismo/application.py @@ -5,7 +5,6 @@ from cpl_core.logging import LoggerABC from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.service.bot_service import BotService -from modules_core.abc.module_service_abc import ModuleServiceABC class Application(ApplicationABC): @@ -23,5 +22,6 @@ class Application(ApplicationABC): try: self._logger.trace(__name__, f'Try to start {BotService}') await self._bot.start_async() + self._logger.trace(__name__, f'Stopped {BotService}') except Exception as e: self._logger.error(__name__, 'Start failed', e) diff --git a/src/gismo/appsettings.development.json b/src/gismo/appsettings.development.json index f48a355..2b42152 100644 --- a/src/gismo/appsettings.development.json +++ b/src/gismo/appsettings.development.json @@ -18,6 +18,14 @@ }, "Bot": { - "Prefix": "!dev-g" + "Prefix": "!dev-g", + "Servers": [ + { + "Id": "511824600884051979" + }, + { + "Id": "910199451145076828" + } + ] } } diff --git a/src/gismo/main.py b/src/gismo/main.py index 98aa58b..808b885 100644 --- a/src/gismo/main.py +++ b/src/gismo/main.py @@ -1,6 +1,6 @@ import asyncio -from cpl_core.application import ApplicationBuilder, ApplicationABC +from cpl_core.application import ApplicationABC, ApplicationBuilder from gismo.application import Application from gismo.startup import Startup @@ -14,7 +14,6 @@ async def main(): app: ApplicationABC = 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/gismo/startup.py b/src/gismo/startup.py index 613d141..e96b327 100644 --- a/src/gismo/startup.py +++ b/src/gismo/startup.py @@ -6,7 +6,7 @@ from cpl_core.configuration import ConfigurationABC from cpl_core.dependency_injection import (ServiceCollectionABC, ServiceProviderABC) from cpl_core.environment import ApplicationEnvironment -from cpl_core.logging.logger_abc import LoggerABC +from cpl_core.logging import LoggerABC from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.service.bot_service import BotService diff --git a/src/gismo_core/configuration/bot_settings.py b/src/gismo_core/configuration/bot_settings.py index e682e25..fb1bd63 100644 --- a/src/gismo_core/configuration/bot_settings.py +++ b/src/gismo_core/configuration/bot_settings.py @@ -1,7 +1,9 @@ import traceback -from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC +from cpl_core.configuration import ConfigurationModelABC from cpl_core.console import Console +from cpl_query.extension import List +from gismo_core.configuration.server_settings import ServerSettings class BotSettings(ConfigurationModelABC): @@ -10,14 +12,25 @@ class BotSettings(ConfigurationModelABC): ConfigurationModelABC.__init__(self) self._prefix: str = '' + self._servers: List[ServerSettings] = List() @property def prefix(self) -> str: return self._prefix + + @property + def servers(self) -> List[ServerSettings]: + return self._servers def from_dict(self, settings: dict): try: self._prefix = settings['Prefix'] + servers = List(ServerSettings) + for s in settings['Servers']: + st = ServerSettings() + st.from_dict(s) + servers.append(st) + self._servers = servers except Exception as e: - Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings') + Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in settings') Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}') diff --git a/src/gismo_core/configuration/discord_settings.py b/src/gismo_core/configuration/discord_settings.py index 948729c..efec204 100644 --- a/src/gismo_core/configuration/discord_settings.py +++ b/src/gismo_core/configuration/discord_settings.py @@ -1,6 +1,6 @@ import traceback -from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC +from cpl_core.configuration import ConfigurationModelABC from cpl_core.console import Console diff --git a/src/gismo_core/configuration/server_settings.py b/src/gismo_core/configuration/server_settings.py new file mode 100644 index 0000000..6d067b3 --- /dev/null +++ b/src/gismo_core/configuration/server_settings.py @@ -0,0 +1,23 @@ +import traceback + +from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC +from cpl_core.console import Console + + +class ServerSettings(ConfigurationModelABC): + + def __init__(self): + ConfigurationModelABC.__init__(self) + + self._id: int = '' + + @property + def id(self) -> str: + return self._id + + def from_dict(self, settings: dict): + try: + self._id = settings['Id'] + except Exception as e: + Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in settings') + Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}') diff --git a/src/gismo_core/service/bot_service.py b/src/gismo_core/service/bot_service.py index ce8e125..98f7045 100644 --- a/src/gismo_core/service/bot_service.py +++ b/src/gismo_core/service/bot_service.py @@ -1,16 +1,18 @@ +from cpl_core.configuration import ConfigurationABC from cpl_core.logging import LoggerABC from discord.ext import commands - from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.configuration.bot_settings import BotSettings from gismo_core.configuration.discord_settings import DiscordSettings +from gismo_core.configuration.server_settings import ServerSettings from modules_core.abc.module_service_abc import ModuleServiceABC class BotService(BotServiceABC, commands.Bot): - def __init__(self, logger: LoggerABC, modules: ModuleServiceABC, discord_settings: DiscordSettings, bot_settings: BotSettings): + def __init__(self, config: ConfigurationABC, logger: LoggerABC, modules: ModuleServiceABC, discord_settings: DiscordSettings, bot_settings: BotSettings): # services + self._config = config self._logger = logger self._modules = modules @@ -23,12 +25,21 @@ class BotService(BotServiceABC, commands.Bot): async def start_async(self): self._logger.trace(__name__, 'Try to connect to discord') - self.run(self._discord_settings.token) + await self.start(self._discord_settings.token) # continue at on_ready async def on_ready(self): self._logger.info(__name__, 'Connected to discord') - await self._modules.start_modules() + + self._logger.debug(__name__, 'Try to load discord server configs') + for server in self._bot_settings.servers: + server: ServerSettings = server + self._logger.trace(__name__, f'Try to load config for server: {server.id}') + self._config.add_configuration(f'DSERVER_{server.id}', server) + self._logger.trace(__name__, f'Loaded config for server: {server.id}') + + + await self._modules.on_ready() async def stop_async(self): self._logger.debug(__name__, f'Try to stop {BotService}') @@ -37,4 +48,3 @@ class BotService(BotServiceABC, commands.Bot): # save data except Exception as e: self._logger.error(__name__, 'Stop failed', e) - diff --git a/src/modules/boot_log/boot_log.py b/src/modules/boot_log/boot_log.py index b02795b..b86dda1 100644 --- a/src/modules/boot_log/boot_log.py +++ b/src/modules/boot_log/boot_log.py @@ -3,7 +3,7 @@ from datetime import datetime from cpl_core.configuration import ConfigurationABC from cpl_core.console import Console from cpl_core.logging import LoggerABC, LoggingLevelEnum, LoggingSettings - +from discord import guild from gismo_core.abc.bot_service_abc import BotServiceABC from modules_core.abc.module_abc import ModuleABC @@ -40,4 +40,13 @@ class BootLog(ModuleABC): if self._logging_st.console.value >= LoggingLevelEnum.INFO.value: Console.banner(self._bot.user.name) - self._logger.trace(__name__, f'Module {type(self)} stopped') \ No newline at end of file + for g in self._bot.guilds: + g: guild = g + self._logger.debug(__name__, f'Server detected: {g.id}') + + server_config = self._config.get_configuration(f'DSERVER_{g.id}') + if server_config is None: + self._logger.error(__name__, f'Config for server {g.id} not found!') + await self._bot.close() + + self._logger.trace(__name__, f'Module {type(self)} stopped') diff --git a/src/modules_core/abc/module_service_abc.py b/src/modules_core/abc/module_service_abc.py index 0d906ca..543f2b9 100644 --- a/src/modules_core/abc/module_service_abc.py +++ b/src/modules_core/abc/module_service_abc.py @@ -8,4 +8,4 @@ class ModuleServiceABC(ABC): def __init__(self): pass @abstractmethod - async def start_modules(self): pass + async def on_ready(self): pass diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index 032f6b0..63c1bf7 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -1,11 +1,7 @@ -from os import path - -import discord from cpl_core.dependency_injection import ServiceProviderABC from cpl_core.environment import ApplicationEnvironmentABC from cpl_core.logging import LoggerABC from cpl_query.extension import List -from discord.ext import commands from modules_core.abc.module_abc import ModuleABC from modules_core.abc.module_service_abc import ModuleServiceABC @@ -19,8 +15,8 @@ class ModuleService(ModuleServiceABC): self._modules: List[ModuleABC] = List() self._modules.extend(ModuleABC.__subclasses__()) - async def start_modules(self): - self._logger.trace(__name__, 'Start loading modules') + async def on_ready(self): + self._logger.debug(__name__, 'Start on_ready modules') modules = self._modules.where(lambda m: hasattr(m, 'on_ready') and callable(m.on_ready)) for module_type in modules: module = self._services.get_service(module_type) -- 2.45.2 From 26e1ed7496a859ebfec641d13001c7940ed0c3e6 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 16 Nov 2021 19:06:09 +0100 Subject: [PATCH 023/113] Added message service --- src/gismo/appsettings.development.json | 6 ++- src/gismo/startup.py | 4 +- src/gismo_core/abc/message_service_abc.py | 24 +++++++++++ .../configuration/server_settings.py | 10 ++++- src/gismo_core/service/message_service.py | 40 +++++++++++++++++++ 5 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 src/gismo_core/abc/message_service_abc.py create mode 100644 src/gismo_core/service/message_service.py diff --git a/src/gismo/appsettings.development.json b/src/gismo/appsettings.development.json index 2b42152..d8dee8c 100644 --- a/src/gismo/appsettings.development.json +++ b/src/gismo/appsettings.development.json @@ -21,10 +21,12 @@ "Prefix": "!dev-g", "Servers": [ { - "Id": "511824600884051979" + "Id": "511824600884051979", + "MessageDeleteTimer": 2 }, { - "Id": "910199451145076828" + "Id": "910199451145076828", + "MessageDeleteTimer": 2 } ] } diff --git a/src/gismo/startup.py b/src/gismo/startup.py index e96b327..cd31396 100644 --- a/src/gismo/startup.py +++ b/src/gismo/startup.py @@ -7,9 +7,10 @@ from cpl_core.dependency_injection import (ServiceCollectionABC, ServiceProviderABC) from cpl_core.environment import ApplicationEnvironment from cpl_core.logging import LoggerABC - from gismo_core.abc.bot_service_abc import BotServiceABC +from gismo_core.abc.message_service_abc import MessageServiceABC from gismo_core.service.bot_service import BotService +from gismo_core.service.message_service import MessageService from modules.boot_log.boot_log import BootLog from modules_core.abc.module_abc import ModuleABC from modules_core.abc.module_service_abc import ModuleServiceABC @@ -41,6 +42,7 @@ class Startup(StartupABC): services.add_singleton(ModuleServiceABC, ModuleService) services.add_singleton(BotServiceABC, BotService) + services.add_transient(MessageServiceABC, MessageService) services.add_transient(ModuleABC, BootLog) diff --git a/src/gismo_core/abc/message_service_abc.py b/src/gismo_core/abc/message_service_abc.py new file mode 100644 index 0000000..5c0ab65 --- /dev/null +++ b/src/gismo_core/abc/message_service_abc.py @@ -0,0 +1,24 @@ +from abc import ABC, abstractmethod +from typing import Union + +import discord +from cpl_query.extension import List +from discord.ext.commands import Context + + +class MessageServiceABC(ABC): + + @abstractmethod + def __init__(self): pass + + @abstractmethod + async def delete_message(self, messages: List[discord.Message]): pass + + @abstractmethod + async def send_channel_message(self, channel: discord.TextChannel, message: str): pass + + @abstractmethod + async def send_dm_message(self, message: str, receiver: Union[discord.User, discord.Member]): pass + + @abstractmethod + async def send_ctx_msg(self, ctx: Context, message: str, file: discord.File = None): pass diff --git a/src/gismo_core/configuration/server_settings.py b/src/gismo_core/configuration/server_settings.py index 6d067b3..0f11b16 100644 --- a/src/gismo_core/configuration/server_settings.py +++ b/src/gismo_core/configuration/server_settings.py @@ -9,15 +9,21 @@ class ServerSettings(ConfigurationModelABC): def __init__(self): ConfigurationModelABC.__init__(self) - self._id: int = '' + self._id: int = 0 + self._message_delete_timer: int = 0 @property def id(self) -> str: return self._id + + @property + def message_delete_timer(self) -> int: + return self._message_delete_timer def from_dict(self, settings: dict): try: - self._id = settings['Id'] + self._id = int(settings['Id']) + self._message_delete_timer = int(settings['MessageDeleteTimer']) except Exception as e: Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in settings') Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}') diff --git a/src/gismo_core/service/message_service.py b/src/gismo_core/service/message_service.py new file mode 100644 index 0000000..f97aca0 --- /dev/null +++ b/src/gismo_core/service/message_service.py @@ -0,0 +1,40 @@ +import asyncio +from typing import Union + +import discord +from cpl_core.configuration.configuration_abc import ConfigurationABC +from cpl_core.logging import LoggerABC +from cpl_query.extension import List +from discord.ext.commands import Context + +from gismo_core.abc.bot_service_abc import BotServiceABC +from gismo_core.abc.message_service_abc import MessageServiceABC +from gismo_core.configuration.server_settings import ServerSettings + + +class MessageService(MessageServiceABC): + + def __init__(self, config: ConfigurationABC, logger: LoggerABC, bot: BotServiceABC): + self._config = config + self._logger = logger + self._bot = bot + + async def delete_message(self, messages: List[discord.Message]): + self._logger.debug(__name__, f'Try to delete {messages.count()} messages') + for message in messages: + message: discord.Message = message + server_st: ServerSettings = self._config.get_configuration(f'DSERVER_{message.g.id}') + await asyncio.sleep(server_st.message_delete_timer) + try: + self._logger.trace(__name__, f'Try to delete message: {message.content}') + await message.delete() + self._logger.trace(__name__, 'Deleted message') + except Exception as e: + self._logger.warn(__name__, f'Deleting message failed') + self._logger.debug(__name__, 'Deleting messages finished') + + async def send_channel_message(self, channel: discord.TextChannel, message: str): pass + + async def send_dm_message(self, message: str, receiver: Union[discord.User, discord.Member]): pass + + async def send_ctx_msg(self, ctx: Context, message: str, file: discord.File = None): pass -- 2.45.2 From e8e6a28d87f8f993b7ae07b7a0b76298d1e26799 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 16 Nov 2021 20:07:48 +0100 Subject: [PATCH 024/113] Added logic to delete message & send channel message --- src/gismo_core/service/message_service.py | 33 ++++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/gismo_core/service/message_service.py b/src/gismo_core/service/message_service.py index f97aca0..db8307c 100644 --- a/src/gismo_core/service/message_service.py +++ b/src/gismo_core/service/message_service.py @@ -22,18 +22,31 @@ class MessageService(MessageServiceABC): async def delete_message(self, messages: List[discord.Message]): self._logger.debug(__name__, f'Try to delete {messages.count()} messages') for message in messages: - message: discord.Message = message - server_st: ServerSettings = self._config.get_configuration(f'DSERVER_{message.g.id}') - await asyncio.sleep(server_st.message_delete_timer) - try: - self._logger.trace(__name__, f'Try to delete message: {message.content}') - await message.delete() - self._logger.trace(__name__, 'Deleted message') - except Exception as e: - self._logger.warn(__name__, f'Deleting message failed') + await self.delete_message(message) self._logger.debug(__name__, 'Deleting messages finished') + + async def delete_message(self, message: discord.Message): + server_st: ServerSettings = self._config.get_configuration(f'DSERVER_{message.g.id}') + await asyncio.sleep(server_st.message_delete_timer) + try: + self._logger.trace(__name__, f'Try to delete message: {message.content}') + await message.delete() + self._logger.trace(__name__, 'Deleted message') + except Exception as e: + self._logger.warn(__name__, f'Deleting message failed') + else: + self._logger.debug(__name__, f'Deleted message {message.content}') + self._logger.trace(__name__, 'Deleting messages finished') - async def send_channel_message(self, channel: discord.TextChannel, message: str): pass + async def send_channel_message(self, channel: discord.TextChannel, message: str): + self._logger.debug(__name__, f'Try to send message {message} to channel {channel.id}') + try: + msg = await channel.send(message) + await self.delete_message(msg) + except Exception as e: + self._logger.warn(__name__, f'Send message to channel {channel.id} failed') + else: + self._logger.debug(__name__, f'Send message to channel {channel.id}') async def send_dm_message(self, message: str, receiver: Union[discord.User, discord.Member]): pass -- 2.45.2 From b0b646bb2bdaa6b26270cb29c8c3673b77a05985 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 16 Nov 2021 20:12:42 +0100 Subject: [PATCH 025/113] Added logic to send dm messages --- src/gismo_core/service/message_service.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gismo_core/service/message_service.py b/src/gismo_core/service/message_service.py index db8307c..9009a6f 100644 --- a/src/gismo_core/service/message_service.py +++ b/src/gismo_core/service/message_service.py @@ -28,15 +28,13 @@ class MessageService(MessageServiceABC): async def delete_message(self, message: discord.Message): server_st: ServerSettings = self._config.get_configuration(f'DSERVER_{message.g.id}') await asyncio.sleep(server_st.message_delete_timer) + self._logger.debug(__name__, f'Try to delete message: {message.content}') try: - self._logger.trace(__name__, f'Try to delete message: {message.content}') await message.delete() - self._logger.trace(__name__, 'Deleted message') except Exception as e: - self._logger.warn(__name__, f'Deleting message failed') + self._logger.error(__name__, f'Deleting message failed', e) else: self._logger.debug(__name__, f'Deleted message {message.content}') - self._logger.trace(__name__, 'Deleting messages finished') async def send_channel_message(self, channel: discord.TextChannel, message: str): self._logger.debug(__name__, f'Try to send message {message} to channel {channel.id}') @@ -44,10 +42,17 @@ class MessageService(MessageServiceABC): msg = await channel.send(message) await self.delete_message(msg) except Exception as e: - self._logger.warn(__name__, f'Send message to channel {channel.id} failed') + self._logger.error(__name__, f'Send message to channel {channel.id} failed', e) else: self._logger.debug(__name__, f'Send message to channel {channel.id}') - async def send_dm_message(self, message: str, receiver: Union[discord.User, discord.Member]): pass + async def send_dm_message(self, message: str, receiver: Union[discord.User, discord.Member]): + self._logger.debug(__name__, f'Try to send message {message} to user {receiver.id}') + try: + await receiver.send(message) + except Exception as e: + self._logger.error(__name__, f'Send message to user {receiver.id} failed', e) + else: + self._logger.debug(__name__, f'Send message to user {receiver.id}') async def send_ctx_msg(self, ctx: Context, message: str, file: discord.File = None): pass -- 2.45.2 From 81499ef8e6a01954c438feb9dd3fe675e85f6712 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 16 Nov 2021 20:19:19 +0100 Subject: [PATCH 026/113] Added logic to send context messages --- src/gismo_core/service/message_service.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/gismo_core/service/message_service.py b/src/gismo_core/service/message_service.py index 9009a6f..40da6eb 100644 --- a/src/gismo_core/service/message_service.py +++ b/src/gismo_core/service/message_service.py @@ -39,8 +39,7 @@ class MessageService(MessageServiceABC): async def send_channel_message(self, channel: discord.TextChannel, message: str): self._logger.debug(__name__, f'Try to send message {message} to channel {channel.id}') try: - msg = await channel.send(message) - await self.delete_message(msg) + await self.delete_message(await channel.send(message)) except Exception as e: self._logger.error(__name__, f'Send message to channel {channel.id} failed', e) else: @@ -55,4 +54,19 @@ class MessageService(MessageServiceABC): else: self._logger.debug(__name__, f'Send message to user {receiver.id}') - async def send_ctx_msg(self, ctx: Context, message: str, file: discord.File = None): pass + async def send_ctx_msg(self, ctx: Context, message: Union[str, discord.File]): + if ctx is None: + self._logger.warn(__name__, 'Message context is empty') + self._logger.debug(__name__, f'Message: {message}') + return + + self._logger.debug(__name__, f'Try to send message {message} to channel {ctx.channel.id}') + try: + if isinstance(message, discord.File): + await self.delete_message(await ctx.send(file=message)) + else: + await self.delete_message(await ctx.send(message)) + except Exception as e: + self._logger.error(__name__, f'Send message to channel {ctx.channel.id} failed', e) + else: + self._logger.debug(__name__, f'Send message to channel {ctx.channel.id}') -- 2.45.2 From c254114987b53fbecb2b3acc92440e0ac64b99bb Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 16 Nov 2021 20:19:47 +0100 Subject: [PATCH 027/113] Added delete_message to ABC --- src/gismo_core/abc/message_service_abc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gismo_core/abc/message_service_abc.py b/src/gismo_core/abc/message_service_abc.py index 5c0ab65..1b91937 100644 --- a/src/gismo_core/abc/message_service_abc.py +++ b/src/gismo_core/abc/message_service_abc.py @@ -12,7 +12,10 @@ class MessageServiceABC(ABC): def __init__(self): pass @abstractmethod - async def delete_message(self, messages: List[discord.Message]): pass + async def delete_messages(self, messages: List[discord.Message]): pass + + @abstractmethod + async def delete_message(self, message: discord.Message): pass @abstractmethod async def send_channel_message(self, channel: discord.TextChannel, message: str): pass -- 2.45.2 From 5e1caf713caa52f3b8e00640aa24ce8d4d98d948 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 16 Nov 2021 20:37:51 +0100 Subject: [PATCH 028/113] Improved message service & added logic to send login message --- src/gismo/appsettings.development.json | 4 ++ .../configuration/server_settings.py | 12 +++++ src/gismo_core/service/message_service.py | 12 ++--- src/modules/boot_log/boot_log.py | 46 ++++++++++++++----- 4 files changed, 57 insertions(+), 17 deletions(-) diff --git a/src/gismo/appsettings.development.json b/src/gismo/appsettings.development.json index d8dee8c..19d2377 100644 --- a/src/gismo/appsettings.development.json +++ b/src/gismo/appsettings.development.json @@ -22,10 +22,14 @@ "Servers": [ { "Id": "511824600884051979", + "LoginMessageChannelId": "521260270757347328", + "LoginMessage": "Ich bin on the line :D\nDer Start hat {} Sekunden gedauert", "MessageDeleteTimer": 2 }, { "Id": "910199451145076828", + "LoginMessageChannelId": "910199452915093588", + "LoginMessage": "Ich bin on the line :D\nDer Start hat {} Sekunden gedauert", "MessageDeleteTimer": 2 } ] diff --git a/src/gismo_core/configuration/server_settings.py b/src/gismo_core/configuration/server_settings.py index 0f11b16..f339b9c 100644 --- a/src/gismo_core/configuration/server_settings.py +++ b/src/gismo_core/configuration/server_settings.py @@ -11,6 +11,8 @@ class ServerSettings(ConfigurationModelABC): self._id: int = 0 self._message_delete_timer: int = 0 + self._login_message_channel_id: int = 0 + self._login_message: str = '' @property def id(self) -> str: @@ -19,11 +21,21 @@ class ServerSettings(ConfigurationModelABC): @property def message_delete_timer(self) -> int: return self._message_delete_timer + + @property + def login_message_channel_id(self) -> int: + return self._login_message_channel_id + + @property + def login_message(self) -> str: + return self._login_message def from_dict(self, settings: dict): try: self._id = int(settings['Id']) self._message_delete_timer = int(settings['MessageDeleteTimer']) + self._login_message_channel_id = int(settings['LoginMessageChannelId']) + self._login_message = settings['LoginMessage'] except Exception as e: Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in settings') Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}') diff --git a/src/gismo_core/service/message_service.py b/src/gismo_core/service/message_service.py index 40da6eb..73effd4 100644 --- a/src/gismo_core/service/message_service.py +++ b/src/gismo_core/service/message_service.py @@ -19,14 +19,14 @@ class MessageService(MessageServiceABC): self._logger = logger self._bot = bot - async def delete_message(self, messages: List[discord.Message]): + async def delete_messages(self, messages: List[discord.Message]): self._logger.debug(__name__, f'Try to delete {messages.count()} messages') for message in messages: await self.delete_message(message) self._logger.debug(__name__, 'Deleting messages finished') async def delete_message(self, message: discord.Message): - server_st: ServerSettings = self._config.get_configuration(f'DSERVER_{message.g.id}') + server_st: ServerSettings = self._config.get_configuration(f'DSERVER_{message.guild.id}') await asyncio.sleep(server_st.message_delete_timer) self._logger.debug(__name__, f'Try to delete message: {message.content}') try: @@ -34,7 +34,7 @@ class MessageService(MessageServiceABC): except Exception as e: self._logger.error(__name__, f'Deleting message failed', e) else: - self._logger.debug(__name__, f'Deleted message {message.content}') + self._logger.info(__name__, f'Deleted message {message.content}') async def send_channel_message(self, channel: discord.TextChannel, message: str): self._logger.debug(__name__, f'Try to send message {message} to channel {channel.id}') @@ -43,7 +43,7 @@ class MessageService(MessageServiceABC): except Exception as e: self._logger.error(__name__, f'Send message to channel {channel.id} failed', e) else: - self._logger.debug(__name__, f'Send message to channel {channel.id}') + self._logger.info(__name__, f'Sent message to channel {channel.id}') async def send_dm_message(self, message: str, receiver: Union[discord.User, discord.Member]): self._logger.debug(__name__, f'Try to send message {message} to user {receiver.id}') @@ -52,7 +52,7 @@ class MessageService(MessageServiceABC): except Exception as e: self._logger.error(__name__, f'Send message to user {receiver.id} failed', e) else: - self._logger.debug(__name__, f'Send message to user {receiver.id}') + self._logger.info(__name__, f'Sent message to user {receiver.id}') async def send_ctx_msg(self, ctx: Context, message: Union[str, discord.File]): if ctx is None: @@ -69,4 +69,4 @@ class MessageService(MessageServiceABC): except Exception as e: self._logger.error(__name__, f'Send message to channel {ctx.channel.id} failed', e) else: - self._logger.debug(__name__, f'Send message to channel {ctx.channel.id}') + self._logger.info(__name__, f'Sent message to channel {ctx.channel.id}') diff --git a/src/modules/boot_log/boot_log.py b/src/modules/boot_log/boot_log.py index b86dda1..42ea00f 100644 --- a/src/modules/boot_log/boot_log.py +++ b/src/modules/boot_log/boot_log.py @@ -4,17 +4,30 @@ from cpl_core.configuration import ConfigurationABC from cpl_core.console import Console from cpl_core.logging import LoggerABC, LoggingLevelEnum, LoggingSettings from discord import guild + from gismo_core.abc.bot_service_abc import BotServiceABC +from gismo_core.abc.message_service_abc import MessageServiceABC +from gismo_core.configuration.server_settings import ServerSettings from modules_core.abc.module_abc import ModuleABC class BootLog(ModuleABC): - def __init__(self, config: ConfigurationABC, logging_st: LoggingSettings, logger: LoggerABC, bot: BotServiceABC): + def __init__( + self, + config: ConfigurationABC, + logging_st: LoggingSettings, + logger: LoggerABC, + bot: BotServiceABC, + message_service: MessageServiceABC + ): self._config = config self._logging_st = logging_st + self._logger = logger self._bot = bot + self._message_service = message_service + ModuleABC.__init__(self) self._logger.trace(__name__, f'Module {type(self)} loaded') @@ -27,26 +40,37 @@ class BootLog(ModuleABC): self._logger.debug(__name__, f'Bot Init time: {init_time}s') # print warning if initialisation took too long if init_time >= 30: - self._logger.warn(__name__, 'It takes long time to start the bot!') - + self._logger.warn( + __name__, 'It takes long time to start the bot!') + # print error if initialisation took way too long elif init_time >= 90: - self._logger.error(__name__, 'It takes very long time to start the bot!!!') + self._logger.error( + __name__, 'It takes very long time to start the bot!!!') except Exception as e: self._logger.error(__name__, 'Init time calculation failed', e) return - + self._logger.header(f'{self._bot.user.name}:') if self._logging_st.console.value >= LoggingLevelEnum.INFO.value: Console.banner(self._bot.user.name) - + for g in self._bot.guilds: g: guild = g self._logger.debug(__name__, f'Server detected: {g.id}') - - server_config = self._config.get_configuration(f'DSERVER_{g.id}') - if server_config is None: - self._logger.error(__name__, f'Config for server {g.id} not found!') + + server_settings: ServerSettings = self._config.get_configuration( + f'DSERVER_{g.id}') + if server_settings is None: + self._logger.error( + __name__, f'Config for server {g.id} not found!') await self._bot.close() - + return + + await self._message_service.send_channel_message( + self._bot.get_channel( + server_settings.login_message_channel_id), + server_settings.login_message.format(init_time) + ) + self._logger.trace(__name__, f'Module {type(self)} stopped') -- 2.45.2 From 9584b34f8f62417b252e54d7b4302a1492943967 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 16 Nov 2021 20:48:53 +0100 Subject: [PATCH 029/113] Improved logging to message service --- src/gismo_core/service/message_service.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gismo_core/service/message_service.py b/src/gismo_core/service/message_service.py index 73effd4..6a90d79 100644 --- a/src/gismo_core/service/message_service.py +++ b/src/gismo_core/service/message_service.py @@ -38,12 +38,14 @@ class MessageService(MessageServiceABC): async def send_channel_message(self, channel: discord.TextChannel, message: str): self._logger.debug(__name__, f'Try to send message {message} to channel {channel.id}') + msg = None try: - await self.delete_message(await channel.send(message)) + msg = await channel.send(message) except Exception as e: self._logger.error(__name__, f'Send message to channel {channel.id} failed', e) else: self._logger.info(__name__, f'Sent message to channel {channel.id}') + await self.delete_message(msg) async def send_dm_message(self, message: str, receiver: Union[discord.User, discord.Member]): self._logger.debug(__name__, f'Try to send message {message} to user {receiver.id}') @@ -61,12 +63,14 @@ class MessageService(MessageServiceABC): return self._logger.debug(__name__, f'Try to send message {message} to channel {ctx.channel.id}') + msg = None try: if isinstance(message, discord.File): - await self.delete_message(await ctx.send(file=message)) + msg = await ctx.send(file=message) else: - await self.delete_message(await ctx.send(message)) + msg = await ctx.send(message) except Exception as e: self._logger.error(__name__, f'Send message to channel {ctx.channel.id} failed', e) else: self._logger.info(__name__, f'Sent message to channel {ctx.channel.id}') + await self.delete_message(msg) -- 2.45.2 From 12492cf596eaa4363e615b9555097510a0658346 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 16 Nov 2021 21:01:16 +0100 Subject: [PATCH 030/113] Added on_message event --- src/gismo_core/service/bot_service.py | 24 ++++++++++++++-------- src/modules_core/abc/module_service_abc.py | 6 +++++- src/modules_core/service/module_service.py | 9 +++++++- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/gismo_core/service/bot_service.py b/src/gismo_core/service/bot_service.py index 98f7045..2f26e86 100644 --- a/src/gismo_core/service/bot_service.py +++ b/src/gismo_core/service/bot_service.py @@ -1,6 +1,8 @@ +import discord +from discord.ext import commands + from cpl_core.configuration import ConfigurationABC from cpl_core.logging import LoggerABC -from discord.ext import commands from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.configuration.bot_settings import BotSettings from gismo_core.configuration.discord_settings import DiscordSettings @@ -27,6 +29,14 @@ class BotService(BotServiceABC, commands.Bot): self._logger.trace(__name__, 'Try to connect to discord') await self.start(self._discord_settings.token) # continue at on_ready + + async def stop_async(self): + self._logger.debug(__name__, f'Try to stop {BotService}') + try: + pass + # save data + except Exception as e: + self._logger.error(__name__, 'Stop failed', e) async def on_ready(self): self._logger.info(__name__, 'Connected to discord') @@ -40,11 +50,7 @@ class BotService(BotServiceABC, commands.Bot): await self._modules.on_ready() - - async def stop_async(self): - self._logger.debug(__name__, f'Try to stop {BotService}') - try: - pass - # save data - except Exception as e: - self._logger.error(__name__, 'Stop failed', e) + + async def on_message(self, message: discord.Message): + self._logger.debug(__name__, f'Received message:\n{message}:\n{message.content}') + await self._modules.on_message(message) diff --git a/src/modules_core/abc/module_service_abc.py b/src/modules_core/abc/module_service_abc.py index 543f2b9..51bc8a0 100644 --- a/src/modules_core/abc/module_service_abc.py +++ b/src/modules_core/abc/module_service_abc.py @@ -1,5 +1,6 @@ from abc import ABC, abstractmethod -from codecs import register + +import discord class ModuleServiceABC(ABC): @@ -9,3 +10,6 @@ class ModuleServiceABC(ABC): @abstractmethod async def on_ready(self): pass + + @abstractmethod + async def on_message(self, message: discord.Message): pass diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index 63c1bf7..94a4e17 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -1,9 +1,13 @@ +import discord +from discord.ext import commands + from cpl_core.dependency_injection import ServiceProviderABC from cpl_core.environment import ApplicationEnvironmentABC from cpl_core.logging import LoggerABC from cpl_query.extension import List from modules_core.abc.module_abc import ModuleABC from modules_core.abc.module_service_abc import ModuleServiceABC +from modules_core.events_enum import EventsEnum class ModuleService(ModuleServiceABC): @@ -17,7 +21,10 @@ class ModuleService(ModuleServiceABC): async def on_ready(self): self._logger.debug(__name__, 'Start on_ready modules') - modules = self._modules.where(lambda m: hasattr(m, 'on_ready') and callable(m.on_ready)) + modules = self._modules.where(lambda m: hasattr(m, EventsEnum.on_ready.value) and callable(m.on_ready)) for module_type in modules: module = self._services.get_service(module_type) await module.on_ready() + + async def on_message(self, message: discord.Message): + pass \ No newline at end of file -- 2.45.2 From 880fe8a4c77d7478d71fb4a84b5f999ed13c6d05 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 16 Nov 2021 21:03:14 +0100 Subject: [PATCH 031/113] Added on_message to abc --- src/gismo_core/abc/bot_service_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gismo_core/abc/bot_service_abc.py b/src/gismo_core/abc/bot_service_abc.py index 5ce856e..c842923 100644 --- a/src/gismo_core/abc/bot_service_abc.py +++ b/src/gismo_core/abc/bot_service_abc.py @@ -1,5 +1,6 @@ from abc import ABC, abstractmethod +import discord from discord.ext import commands @@ -13,3 +14,6 @@ class BotServiceABC(ABC, commands.Bot): @abstractmethod async def stop_async(self): pass + + @abstractmethod + async def on_message(self, message: discord.Message): pass -- 2.45.2 From 5afbdb9b826bf0f994e4427ccfbf615ca9925be4 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 17 Nov 2021 18:45:57 +0100 Subject: [PATCH 032/113] Added start script & helper file --- .vscode/PythonImportHelper-v2-Completion.json | 1434 +++++++++++++++++ scripts/start.sh | 4 + 2 files changed, 1438 insertions(+) create mode 100644 .vscode/PythonImportHelper-v2-Completion.json create mode 100755 scripts/start.sh diff --git a/.vscode/PythonImportHelper-v2-Completion.json b/.vscode/PythonImportHelper-v2-Completion.json new file mode 100644 index 0000000..3911507 --- /dev/null +++ b/.vscode/PythonImportHelper-v2-Completion.json @@ -0,0 +1,1434 @@ +[ + { + "label": "ApplicationABC", + "importPath": "cpl_core.application", + "description": "cpl_core.application", + "isExtraImport": true, + "detail": "cpl_core.application", + "documentation": {} + }, + { + "label": "ApplicationBuilder", + "importPath": "cpl_core.application", + "description": "cpl_core.application", + "isExtraImport": true, + "detail": "cpl_core.application", + "documentation": {} + }, + { + "label": "StartupABC", + "importPath": "cpl_core.application", + "description": "cpl_core.application", + "isExtraImport": true, + "detail": "cpl_core.application", + "documentation": {} + }, + { + "label": "ApplicationABC", + "importPath": "cpl_core.application", + "description": "cpl_core.application", + "isExtraImport": true, + "detail": "cpl_core.application", + "documentation": {} + }, + { + "label": "ApplicationABC", + "importPath": "cpl_core.application", + "description": "cpl_core.application", + "isExtraImport": true, + "detail": "cpl_core.application", + "documentation": {} + }, + { + "label": "ApplicationBuilder", + "importPath": "cpl_core.application", + "description": "cpl_core.application", + "isExtraImport": true, + "detail": "cpl_core.application", + "documentation": {} + }, + { + "label": "StartupABC", + "importPath": "cpl_core.application", + "description": "cpl_core.application", + "isExtraImport": true, + "detail": "cpl_core.application", + "documentation": {} + }, + { + "label": "ApplicationABC", + "importPath": "cpl_core.application", + "description": "cpl_core.application", + "isExtraImport": true, + "detail": "cpl_core.application", + "documentation": {} + }, + { + "label": "ApplicationBuilder", + "importPath": "cpl_core.application", + "description": "cpl_core.application", + "isExtraImport": true, + "detail": "cpl_core.application", + "documentation": {} + }, + { + "label": "StartupABC", + "importPath": "cpl_core.application", + "description": "cpl_core.application", + "isExtraImport": true, + "detail": "cpl_core.application", + "documentation": {} + }, + { + "label": "ApplicationABC", + "importPath": "cpl_core.application", + "description": "cpl_core.application", + "isExtraImport": true, + "detail": "cpl_core.application", + "documentation": {} + }, + { + "label": "ApplicationBuilder", + "importPath": "cpl_core.application", + "description": "cpl_core.application", + "isExtraImport": true, + "detail": "cpl_core.application", + "documentation": {} + }, + { + "label": "StartupABC", + "importPath": "cpl_core.application", + "description": "cpl_core.application", + "isExtraImport": true, + "detail": "cpl_core.application", + "documentation": {} + }, + { + "label": "ApplicationABC", + "importPath": "cpl_core.application", + "description": "cpl_core.application", + "isExtraImport": true, + "detail": "cpl_core.application", + "documentation": {} + }, + { + "label": "ApplicationBuilder", + "importPath": "cpl_core.application", + "description": "cpl_core.application", + "isExtraImport": true, + "detail": "cpl_core.application", + "documentation": {} + }, + { + "label": "StartupABC", + "importPath": "cpl_core.application", + "description": "cpl_core.application", + "isExtraImport": true, + "detail": "cpl_core.application", + "documentation": {} + }, + { + "label": "ConfigurationABC", + "importPath": "cpl_core.configuration", + "description": "cpl_core.configuration", + "isExtraImport": true, + "detail": "cpl_core.configuration", + "documentation": {} + }, + { + "label": "ConfigurationABC", + "importPath": "cpl_core.configuration", + "description": "cpl_core.configuration", + "isExtraImport": true, + "detail": "cpl_core.configuration", + "documentation": {} + }, + { + "label": "Configuration", + "importPath": "cpl_core.configuration", + "description": "cpl_core.configuration", + "isExtraImport": true, + "detail": "cpl_core.configuration", + "documentation": {} + }, + { + "label": "ConfigurationABC", + "importPath": "cpl_core.configuration", + "description": "cpl_core.configuration", + "isExtraImport": true, + "detail": "cpl_core.configuration", + "documentation": {} + }, + { + "label": "ConfigurationABC", + "importPath": "cpl_core.configuration", + "description": "cpl_core.configuration", + "isExtraImport": true, + "detail": "cpl_core.configuration", + "documentation": {} + }, + { + "label": "ConfigurationABC", + "importPath": "cpl_core.configuration", + "description": "cpl_core.configuration", + "isExtraImport": true, + "detail": "cpl_core.configuration", + "documentation": {} + }, + { + "label": "ConfigurationABC", + "importPath": "cpl_core.configuration", + "description": "cpl_core.configuration", + "isExtraImport": true, + "detail": "cpl_core.configuration", + "documentation": {} + }, + { + "label": "ConfigurationABC", + "importPath": "cpl_core.configuration", + "description": "cpl_core.configuration", + "isExtraImport": true, + "detail": "cpl_core.configuration", + "documentation": {} + }, + { + "label": "ConfigurationModelABC", + "importPath": "cpl_core.configuration", + "description": "cpl_core.configuration", + "isExtraImport": true, + "detail": "cpl_core.configuration", + "documentation": {} + }, + { + "label": "ConfigurationModelABC", + "importPath": "cpl_core.configuration", + "description": "cpl_core.configuration", + "isExtraImport": true, + "detail": "cpl_core.configuration", + "documentation": {} + }, + { + "label": "ConfigurationABC", + "importPath": "cpl_core.configuration", + "description": "cpl_core.configuration", + "isExtraImport": true, + "detail": "cpl_core.configuration", + "documentation": {} + }, + { + "label": "ConfigurationABC", + "importPath": "cpl_core.configuration", + "description": "cpl_core.configuration", + "isExtraImport": true, + "detail": "cpl_core.configuration", + "documentation": {} + }, + { + "label": "ConfigurationABC", + "importPath": "cpl_core.configuration", + "description": "cpl_core.configuration", + "isExtraImport": true, + "detail": "cpl_core.configuration", + "documentation": {} + }, + { + "label": "ConfigurationABC", + "importPath": "cpl_core.configuration", + "description": "cpl_core.configuration", + "isExtraImport": true, + "detail": "cpl_core.configuration", + "documentation": {} + }, + { + "label": "ConfigurationABC", + "importPath": "cpl_core.configuration", + "description": "cpl_core.configuration", + "isExtraImport": true, + "detail": "cpl_core.configuration", + "documentation": {} + }, + { + "label": "ConfigurationABC", + "importPath": "cpl_core.configuration", + "description": "cpl_core.configuration", + "isExtraImport": true, + "detail": "cpl_core.configuration", + "documentation": {} + }, + { + "label": "ConfigurationABC", + "importPath": "cpl_core.configuration", + "description": "cpl_core.configuration", + "isExtraImport": true, + "detail": "cpl_core.configuration", + "documentation": {} + }, + { + "label": "Console", + "importPath": "cpl_core.console", + "description": "cpl_core.console", + "isExtraImport": true, + "detail": "cpl_core.console", + "documentation": {} + }, + { + "label": "Console", + "importPath": "cpl_core.console", + "description": "cpl_core.console", + "isExtraImport": true, + "detail": "cpl_core.console", + "documentation": {} + }, + { + "label": "Console", + "importPath": "cpl_core.console", + "description": "cpl_core.console", + "isExtraImport": true, + "detail": "cpl_core.console", + "documentation": {} + }, + { + "label": "Console", + "importPath": "cpl_core.console", + "description": "cpl_core.console", + "isExtraImport": true, + "detail": "cpl_core.console", + "documentation": {} + }, + { + "label": "Console", + "importPath": "cpl_core.console", + "description": "cpl_core.console", + "isExtraImport": true, + "detail": "cpl_core.console", + "documentation": {} + }, + { + "label": "Console", + "importPath": "cpl_core.console", + "description": "cpl_core.console", + "isExtraImport": true, + "detail": "cpl_core.console", + "documentation": {} + }, + { + "label": "Console", + "importPath": "cpl_core.console", + "description": "cpl_core.console", + "isExtraImport": true, + "detail": "cpl_core.console", + "documentation": {} + }, + { + "label": "Console", + "importPath": "cpl_core.console", + "description": "cpl_core.console", + "isExtraImport": true, + "detail": "cpl_core.console", + "documentation": {} + }, + { + "label": "Console", + "importPath": "cpl_core.console", + "description": "cpl_core.console", + "isExtraImport": true, + "detail": "cpl_core.console", + "documentation": {} + }, + { + "label": "ServiceProviderABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceProviderABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceCollectionABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceCollection", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceProviderABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceProviderABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceCollectionABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceProviderABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceProviderABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceProviderABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceCollectionABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceProviderABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceProviderABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceProviderABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceProviderABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceCollectionABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceProviderABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceProviderABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "ServiceCollectionABC", + "importPath": "cpl_core.dependency_injection", + "description": "cpl_core.dependency_injection", + "isExtraImport": true, + "detail": "cpl_core.dependency_injection", + "documentation": {} + }, + { + "label": "asyncio", + "kind": 6, + "isExtraImport": true, + "importPath": "asyncio", + "description": "asyncio", + "detail": "asyncio", + "documentation": {} + }, + { + "label": "Application", + "importPath": "gismo.application", + "description": "gismo.application", + "isExtraImport": true, + "detail": "gismo.application", + "documentation": {} + }, + { + "label": "Application", + "importPath": "gismo.application", + "description": "gismo.application", + "isExtraImport": true, + "detail": "gismo.application", + "documentation": {} + }, + { + "label": "Startup", + "importPath": "gismo.startup", + "description": "gismo.startup", + "isExtraImport": true, + "detail": "gismo.startup", + "documentation": {} + }, + { + "label": "Startup", + "importPath": "gismo.startup", + "description": "gismo.startup", + "isExtraImport": true, + "detail": "gismo.startup", + "documentation": {} + }, + { + "label": "ApplicationEnvironment", + "importPath": "cpl_core.environment", + "description": "cpl_core.environment", + "isExtraImport": true, + "detail": "cpl_core.environment", + "documentation": {} + }, + { + "label": "ApplicationEnvironment", + "importPath": "cpl_core.environment", + "description": "cpl_core.environment", + "isExtraImport": true, + "detail": "cpl_core.environment", + "documentation": {} + }, + { + "label": "ApplicationEnvironment", + "importPath": "cpl_core.environment", + "description": "cpl_core.environment", + "isExtraImport": true, + "detail": "cpl_core.environment", + "documentation": {} + }, + { + "label": "ApplicationEnvironmentABC", + "importPath": "cpl_core.environment", + "description": "cpl_core.environment", + "isExtraImport": true, + "detail": "cpl_core.environment", + "documentation": {} + }, + { + "label": "ApplicationEnvironment", + "importPath": "cpl_core.environment", + "description": "cpl_core.environment", + "isExtraImport": true, + "detail": "cpl_core.environment", + "documentation": {} + }, + { + "label": "ApplicationEnvironment", + "importPath": "cpl_core.environment", + "description": "cpl_core.environment", + "isExtraImport": true, + "detail": "cpl_core.environment", + "documentation": {} + }, + { + "label": "LoggerABC", + "importPath": "cpl_core.logging", + "description": "cpl_core.logging", + "isExtraImport": true, + "detail": "cpl_core.logging", + "documentation": {} + }, + { + "label": "LoggerABC", + "importPath": "cpl_core.logging", + "description": "cpl_core.logging", + "isExtraImport": true, + "detail": "cpl_core.logging", + "documentation": {} + }, + { + "label": "LoggerABC", + "importPath": "cpl_core.logging", + "description": "cpl_core.logging", + "isExtraImport": true, + "detail": "cpl_core.logging", + "documentation": {} + }, + { + "label": "LoggerABC", + "importPath": "cpl_core.logging", + "description": "cpl_core.logging", + "isExtraImport": true, + "detail": "cpl_core.logging", + "documentation": {} + }, + { + "label": "LoggerABC", + "importPath": "cpl_core.logging", + "description": "cpl_core.logging", + "isExtraImport": true, + "detail": "cpl_core.logging", + "documentation": {} + }, + { + "label": "LoggingLevelEnum", + "importPath": "cpl_core.logging", + "description": "cpl_core.logging", + "isExtraImport": true, + "detail": "cpl_core.logging", + "documentation": {} + }, + { + "label": "LoggingSettings", + "importPath": "cpl_core.logging", + "description": "cpl_core.logging", + "isExtraImport": true, + "detail": "cpl_core.logging", + "documentation": {} + }, + { + "label": "LoggerABC", + "importPath": "cpl_core.logging", + "description": "cpl_core.logging", + "isExtraImport": true, + "detail": "cpl_core.logging", + "documentation": {} + }, + { + "label": "LoggerABC", + "importPath": "cpl_core.logging", + "description": "cpl_core.logging", + "isExtraImport": true, + "detail": "cpl_core.logging", + "documentation": {} + }, + { + "label": "BotServiceABC", + "importPath": "gismo_core.abc.bot_service_abc", + "description": "gismo_core.abc.bot_service_abc", + "isExtraImport": true, + "detail": "gismo_core.abc.bot_service_abc", + "documentation": {} + }, + { + "label": "BotServiceABC", + "importPath": "gismo_core.abc.bot_service_abc", + "description": "gismo_core.abc.bot_service_abc", + "isExtraImport": true, + "detail": "gismo_core.abc.bot_service_abc", + "documentation": {} + }, + { + "label": "BotServiceABC", + "importPath": "gismo_core.abc.bot_service_abc", + "description": "gismo_core.abc.bot_service_abc", + "isExtraImport": true, + "detail": "gismo_core.abc.bot_service_abc", + "documentation": {} + }, + { + "label": "BotServiceABC", + "importPath": "gismo_core.abc.bot_service_abc", + "description": "gismo_core.abc.bot_service_abc", + "isExtraImport": true, + "detail": "gismo_core.abc.bot_service_abc", + "documentation": {} + }, + { + "label": "BotServiceABC", + "importPath": "gismo_core.abc.bot_service_abc", + "description": "gismo_core.abc.bot_service_abc", + "isExtraImport": true, + "detail": "gismo_core.abc.bot_service_abc", + "documentation": {} + }, + { + "label": "BotService", + "importPath": "gismo_core.service.bot_service", + "description": "gismo_core.service.bot_service", + "isExtraImport": true, + "detail": "gismo_core.service.bot_service", + "documentation": {} + }, + { + "label": "BotService", + "importPath": "gismo_core.service.bot_service", + "description": "gismo_core.service.bot_service", + "isExtraImport": true, + "detail": "gismo_core.service.bot_service", + "documentation": {} + }, + { + "label": "BootLogExtension", + "importPath": "modules.boot_log.boot_log_extension", + "description": "modules.boot_log.boot_log_extension", + "isExtraImport": true, + "detail": "modules.boot_log.boot_log_extension", + "documentation": {} + }, + { + "label": "datetime", + "importPath": "datetime", + "description": "datetime", + "isExtraImport": true, + "detail": "datetime", + "documentation": {} + }, + { + "label": "datetime", + "importPath": "datetime", + "description": "datetime", + "isExtraImport": true, + "detail": "datetime", + "documentation": {} + }, + { + "label": "datetime", + "importPath": "datetime", + "description": "datetime", + "isExtraImport": true, + "detail": "datetime", + "documentation": {} + }, + { + "label": "Optional", + "importPath": "typing", + "description": "typing", + "isExtraImport": true, + "detail": "typing", + "documentation": {} + }, + { + "label": "Union", + "importPath": "typing", + "description": "typing", + "isExtraImport": true, + "detail": "typing", + "documentation": {} + }, + { + "label": "Union", + "importPath": "typing", + "description": "typing", + "isExtraImport": true, + "detail": "typing", + "documentation": {} + }, + { + "label": "MessageServiceABC", + "importPath": "gismo_core.abc.message_service_abc", + "description": "gismo_core.abc.message_service_abc", + "isExtraImport": true, + "detail": "gismo_core.abc.message_service_abc", + "documentation": {} + }, + { + "label": "MessageServiceABC", + "importPath": "gismo_core.abc.message_service_abc", + "description": "gismo_core.abc.message_service_abc", + "isExtraImport": true, + "detail": "gismo_core.abc.message_service_abc", + "documentation": {} + }, + { + "label": "MessageServiceABC", + "importPath": "gismo_core.abc.message_service_abc", + "description": "gismo_core.abc.message_service_abc", + "isExtraImport": true, + "detail": "gismo_core.abc.message_service_abc", + "documentation": {} + }, + { + "label": "MessageService", + "importPath": "gismo_core.service.message_service", + "description": "gismo_core.service.message_service", + "isExtraImport": true, + "detail": "gismo_core.service.message_service", + "documentation": {} + }, + { + "label": "BootLog", + "importPath": "modules.boot_log.boot_log", + "description": "modules.boot_log.boot_log", + "isExtraImport": true, + "detail": "modules.boot_log.boot_log", + "documentation": {} + }, + { + "label": "ModuleABC", + "importPath": "modules_core.abc.module_abc", + "description": "modules_core.abc.module_abc", + "isExtraImport": true, + "detail": "modules_core.abc.module_abc", + "documentation": {} + }, + { + "label": "ModuleABC", + "importPath": "modules_core.abc.module_abc", + "description": "modules_core.abc.module_abc", + "isExtraImport": true, + "detail": "modules_core.abc.module_abc", + "documentation": {} + }, + { + "label": "ModuleABC", + "importPath": "modules_core.abc.module_abc", + "description": "modules_core.abc.module_abc", + "isExtraImport": true, + "detail": "modules_core.abc.module_abc", + "documentation": {} + }, + { + "label": "ModuleServiceABC", + "importPath": "modules_core.abc.module_service_abc", + "description": "modules_core.abc.module_service_abc", + "isExtraImport": true, + "detail": "modules_core.abc.module_service_abc", + "documentation": {} + }, + { + "label": "ModuleServiceABC", + "importPath": "modules_core.abc.module_service_abc", + "description": "modules_core.abc.module_service_abc", + "isExtraImport": true, + "detail": "modules_core.abc.module_service_abc", + "documentation": {} + }, + { + "label": "ModuleServiceABC", + "importPath": "modules_core.abc.module_service_abc", + "description": "modules_core.abc.module_service_abc", + "isExtraImport": true, + "detail": "modules_core.abc.module_service_abc", + "documentation": {} + }, + { + "label": "ModuleService", + "importPath": "modules_core.service.module_service", + "description": "modules_core.service.module_service", + "isExtraImport": true, + "detail": "modules_core.service.module_service", + "documentation": {} + }, + { + "label": "Application", + "importPath": "gismo_cli.application", + "description": "gismo_cli.application", + "isExtraImport": true, + "detail": "gismo_cli.application", + "documentation": {} + }, + { + "label": "Startup", + "importPath": "gismo_cli.startup", + "description": "gismo_cli.startup", + "isExtraImport": true, + "detail": "gismo_cli.startup", + "documentation": {} + }, + { + "label": "ABC", + "importPath": "abc", + "description": "abc", + "isExtraImport": true, + "detail": "abc", + "documentation": {} + }, + { + "label": "abstractmethod", + "importPath": "abc", + "description": "abc", + "isExtraImport": true, + "detail": "abc", + "documentation": {} + }, + { + "label": "ABC", + "importPath": "abc", + "description": "abc", + "isExtraImport": true, + "detail": "abc", + "documentation": {} + }, + { + "label": "abstractmethod", + "importPath": "abc", + "description": "abc", + "isExtraImport": true, + "detail": "abc", + "documentation": {} + }, + { + "label": "ABC", + "importPath": "abc", + "description": "abc", + "isExtraImport": true, + "detail": "abc", + "documentation": {} + }, + { + "label": "abstractmethod", + "importPath": "abc", + "description": "abc", + "isExtraImport": true, + "detail": "abc", + "documentation": {} + }, + { + "label": "ABC", + "importPath": "abc", + "description": "abc", + "isExtraImport": true, + "detail": "abc", + "documentation": {} + }, + { + "label": "abstractmethod", + "importPath": "abc", + "description": "abc", + "isExtraImport": true, + "detail": "abc", + "documentation": {} + }, + { + "label": "discord", + "kind": 6, + "isExtraImport": true, + "importPath": "discord", + "description": "discord", + "detail": "discord", + "documentation": {} + }, + { + "label": "guild", + "importPath": "discord", + "description": "discord", + "isExtraImport": true, + "detail": "discord", + "documentation": {} + }, + { + "label": "commands", + "importPath": "discord.ext", + "description": "discord.ext", + "isExtraImport": true, + "detail": "discord.ext", + "documentation": {} + }, + { + "label": "commands", + "importPath": "discord.ext", + "description": "discord.ext", + "isExtraImport": true, + "detail": "discord.ext", + "documentation": {} + }, + { + "label": "commands", + "importPath": "discord.ext", + "description": "discord.ext", + "isExtraImport": true, + "detail": "discord.ext", + "documentation": {} + }, + { + "label": "List", + "importPath": "cpl_query.extension", + "description": "cpl_query.extension", + "isExtraImport": true, + "detail": "cpl_query.extension", + "documentation": {} + }, + { + "label": "List", + "importPath": "cpl_query.extension", + "description": "cpl_query.extension", + "isExtraImport": true, + "detail": "cpl_query.extension", + "documentation": {} + }, + { + "label": "List", + "importPath": "cpl_query.extension", + "description": "cpl_query.extension", + "isExtraImport": true, + "detail": "cpl_query.extension", + "documentation": {} + }, + { + "label": "List", + "importPath": "cpl_query.extension", + "description": "cpl_query.extension", + "isExtraImport": true, + "detail": "cpl_query.extension", + "documentation": {} + }, + { + "label": "List", + "importPath": "cpl_query.extension", + "description": "cpl_query.extension", + "isExtraImport": true, + "detail": "cpl_query.extension", + "documentation": {} + }, + { + "label": "Context", + "importPath": "discord.ext.commands", + "description": "discord.ext.commands", + "isExtraImport": true, + "detail": "discord.ext.commands", + "documentation": {} + }, + { + "label": "Context", + "importPath": "discord.ext.commands", + "description": "discord.ext.commands", + "isExtraImport": true, + "detail": "discord.ext.commands", + "documentation": {} + }, + { + "label": "traceback", + "kind": 6, + "isExtraImport": true, + "importPath": "traceback", + "description": "traceback", + "detail": "traceback", + "documentation": {} + }, + { + "label": "ServerSettings", + "importPath": "gismo_core.configuration.server_settings", + "description": "gismo_core.configuration.server_settings", + "isExtraImport": true, + "detail": "gismo_core.configuration.server_settings", + "documentation": {} + }, + { + "label": "ServerSettings", + "importPath": "gismo_core.configuration.server_settings", + "description": "gismo_core.configuration.server_settings", + "isExtraImport": true, + "detail": "gismo_core.configuration.server_settings", + "documentation": {} + }, + { + "label": "ServerSettings", + "importPath": "gismo_core.configuration.server_settings", + "description": "gismo_core.configuration.server_settings", + "isExtraImport": true, + "detail": "gismo_core.configuration.server_settings", + "documentation": {} + }, + { + "label": "ServerSettings", + "importPath": "gismo_core.configuration.server_settings", + "description": "gismo_core.configuration.server_settings", + "isExtraImport": true, + "detail": "gismo_core.configuration.server_settings", + "documentation": {} + }, + { + "label": "ConfigurationModelABC", + "importPath": "cpl_core.configuration.configuration_model_abc", + "description": "cpl_core.configuration.configuration_model_abc", + "isExtraImport": true, + "detail": "cpl_core.configuration.configuration_model_abc", + "documentation": {} + }, + { + "label": "BotSettings", + "importPath": "gismo_core.configuration.bot_settings", + "description": "gismo_core.configuration.bot_settings", + "isExtraImport": true, + "detail": "gismo_core.configuration.bot_settings", + "documentation": {} + }, + { + "label": "DiscordSettings", + "importPath": "gismo_core.configuration.discord_settings", + "description": "gismo_core.configuration.discord_settings", + "isExtraImport": true, + "detail": "gismo_core.configuration.discord_settings", + "documentation": {} + }, + { + "label": "ConfigurationABC", + "importPath": "cpl_core.configuration.configuration_abc", + "description": "cpl_core.configuration.configuration_abc", + "isExtraImport": true, + "detail": "cpl_core.configuration.configuration_abc", + "documentation": {} + }, + { + "label": "ApplicationExtensionABC", + "importPath": "cpl_core.application.application_extension_abc", + "description": "cpl_core.application.application_extension_abc", + "isExtraImport": true, + "detail": "cpl_core.application.application_extension_abc", + "documentation": {} + }, + { + "label": "EventsEnum", + "importPath": "modules_core.events_enum", + "description": "modules_core.events_enum", + "isExtraImport": true, + "detail": "modules_core.events_enum", + "documentation": {} + }, + { + "label": "EventsEnum", + "importPath": "modules_core.events_enum", + "description": "modules_core.events_enum", + "isExtraImport": true, + "detail": "modules_core.events_enum", + "documentation": {} + }, + { + "label": "Enum", + "importPath": "enum", + "description": "enum", + "isExtraImport": true, + "detail": "enum", + "documentation": {} + }, + { + "label": "json", + "kind": 6, + "isExtraImport": true, + "importPath": "json", + "description": "json", + "detail": "json", + "documentation": {} + }, + { + "label": "Application", + "importPath": "level_generator.application", + "description": "level_generator.application", + "isExtraImport": true, + "detail": "level_generator.application", + "documentation": {} + }, + { + "label": "Startup", + "importPath": "level_generator.startup", + "description": "level_generator.startup", + "isExtraImport": true, + "detail": "level_generator.startup", + "documentation": {} + }, + { + "label": "Application", + "importPath": "ontime_calculator.application", + "description": "ontime_calculator.application", + "isExtraImport": true, + "detail": "ontime_calculator.application", + "documentation": {} + }, + { + "label": "Startup", + "importPath": "ontime_calculator.startup", + "description": "ontime_calculator.startup", + "isExtraImport": true, + "detail": "ontime_calculator.startup", + "documentation": {} + }, + { + "label": "Application", + "kind": 6, + "importPath": "dist.gismo.build.gismo.application", + "description": "dist.gismo.build.gismo.application", + "peekOfCode": "class Application(ApplicationABC):\n def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):\n ApplicationABC.__init__(self, config, services)\n async def configure(self):\n pass\n async def main(self):\n Console.write_line('Hello World')", + "detail": "dist.gismo.build.gismo.application", + "documentation": {} + }, + { + "label": "Startup", + "kind": 6, + "importPath": "dist.gismo.build.gismo.startup", + "description": "dist.gismo.build.gismo.startup", + "peekOfCode": "class Startup(StartupABC):\n def __init__(self):\n StartupABC.__init__(self)\n async def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:\n return configuration\n async def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:\n return services.build_service_provider()", + "detail": "dist.gismo.build.gismo.startup", + "documentation": {} + }, + { + "label": "configure_configuration", + "kind": 2, + "importPath": "dist.gismo.build.modules.boot_log.main", + "description": "dist.gismo.build.modules.boot_log.main", + "peekOfCode": "def configure_configuration() -> ConfigurationABC:\n config = Configuration()\n return config\ndef configure_services(config: ConfigurationABC) -> ServiceProviderABC:\n services = ServiceCollection(config)\n return services.build_service_provider()\ndef main():\n config = configure_configuration()\n provider = configure_services(config)\n Console.write_line('Hello World')", + "detail": "dist.gismo.build.modules.boot_log.main", + "documentation": {} + }, + { + "label": "configure_services", + "kind": 2, + "importPath": "dist.gismo.build.modules.boot_log.main", + "description": "dist.gismo.build.modules.boot_log.main", + "peekOfCode": "def configure_services(config: ConfigurationABC) -> ServiceProviderABC:\n services = ServiceCollection(config)\n return services.build_service_provider()\ndef main():\n config = configure_configuration()\n provider = configure_services(config)\n Console.write_line('Hello World')\nif __name__ == '__main__':\n main()", + "detail": "dist.gismo.build.modules.boot_log.main", + "documentation": {} + }, + { + "label": "main", + "kind": 2, + "importPath": "dist.gismo.build.modules.boot_log.main", + "description": "dist.gismo.build.modules.boot_log.main", + "peekOfCode": "def main():\n config = configure_configuration()\n provider = configure_services(config)\n Console.write_line('Hello World')\nif __name__ == '__main__':\n main()", + "detail": "dist.gismo.build.modules.boot_log.main", + "documentation": {} + }, + { + "label": "Application", + "kind": 6, + "importPath": "src.gismo.application", + "description": "src.gismo.application", + "peekOfCode": "class Application(ApplicationABC):\n def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):\n ApplicationABC.__init__(self, config, services)\n self._bot: BotService = services.get_service(BotServiceABC)\n self._logger: LoggerABC = services.get_service(LoggerABC)\n async def configure(self):\n pass\n async def main(self):\n try:\n self._logger.trace(__name__, f'Try to start {BotService}')", + "detail": "src.gismo.application", + "documentation": {} + }, + { + "label": "Startup", + "kind": 6, + "importPath": "src.gismo.startup", + "description": "src.gismo.startup", + "peekOfCode": "class Startup(StartupABC):\n def __init__(self):\n StartupABC.__init__(self)\n self._start_time = datetime.now()\n self._config: Optional[ConfigurationABC] = None\n async def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:\n configuration.add_environment_variables('GISMO_')\n configuration.add_json_file(f'appsettings.json', optional=False)\n configuration.add_json_file(f'appsettings.{environment.environment_name}.json', optional=True)\n configuration.add_json_file(f'appsettings.{environment.host_name}.json', optional=True)", + "detail": "src.gismo.startup", + "documentation": {} + }, + { + "label": "Application", + "kind": 6, + "importPath": "src.gismo_cli.application", + "description": "src.gismo_cli.application", + "peekOfCode": "class Application(ApplicationABC):\n def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):\n ApplicationABC.__init__(self, config, services)\n async def configure(self):\n pass\n async def main(self):\n Console.write_line('Hello World')", + "detail": "src.gismo_cli.application", + "documentation": {} + }, + { + "label": "Startup", + "kind": 6, + "importPath": "src.gismo_cli.startup", + "description": "src.gismo_cli.startup", + "peekOfCode": "class Startup(StartupABC):\n def __init__(self):\n StartupABC.__init__(self)\n async def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:\n return configuration\n async def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:\n return services.build_service_provider()", + "detail": "src.gismo_cli.startup", + "documentation": {} + }, + { + "label": "BotServiceABC", + "kind": 6, + "importPath": "src.gismo_core.abc.bot_service_abc", + "description": "src.gismo_core.abc.bot_service_abc", + "peekOfCode": "class BotServiceABC(ABC, commands.Bot):\n @abstractmethod\n def __init__(self): pass\n @abstractmethod\n async def start_async(self): pass\n @abstractmethod\n async def stop_async(self): pass\n @abstractmethod\n async def on_message(self, message: discord.Message): pass", + "detail": "src.gismo_core.abc.bot_service_abc", + "documentation": {} + }, + { + "label": "MessageServiceABC", + "kind": 6, + "importPath": "src.gismo_core.abc.message_service_abc", + "description": "src.gismo_core.abc.message_service_abc", + "peekOfCode": "class MessageServiceABC(ABC):\n @abstractmethod\n def __init__(self): pass\n @abstractmethod\n async def delete_messages(self, messages: List[discord.Message]): pass\n @abstractmethod\n async def delete_message(self, message: discord.Message): pass\n @abstractmethod\n async def send_channel_message(self, channel: discord.TextChannel, message: str): pass\n @abstractmethod", + "detail": "src.gismo_core.abc.message_service_abc", + "documentation": {} + }, + { + "label": "BotSettings", + "kind": 6, + "importPath": "src.gismo_core.configuration.bot_settings", + "description": "src.gismo_core.configuration.bot_settings", + "peekOfCode": "class BotSettings(ConfigurationModelABC):\n def __init__(self):\n ConfigurationModelABC.__init__(self)\n self._prefix: str = ''\n self._servers: List[ServerSettings] = List()\n @property\n def prefix(self) -> str:\n return self._prefix\n @property\n def servers(self) -> List[ServerSettings]:", + "detail": "src.gismo_core.configuration.bot_settings", + "documentation": {} + }, + { + "label": "DiscordSettings", + "kind": 6, + "importPath": "src.gismo_core.configuration.discord_settings", + "description": "src.gismo_core.configuration.discord_settings", + "peekOfCode": "class DiscordSettings(ConfigurationModelABC):\n def __init__(self):\n ConfigurationModelABC.__init__(self)\n self._token: str = ''\n @property\n def token(self) -> str:\n return self._token\n def from_dict(self, settings: dict):\n try:\n self._token = settings['Token']", + "detail": "src.gismo_core.configuration.discord_settings", + "documentation": {} + }, + { + "label": "ServerSettings", + "kind": 6, + "importPath": "src.gismo_core.configuration.server_settings", + "description": "src.gismo_core.configuration.server_settings", + "peekOfCode": "class ServerSettings(ConfigurationModelABC):\n def __init__(self):\n ConfigurationModelABC.__init__(self)\n self._id: int = 0\n self._message_delete_timer: int = 0\n self._login_message_channel_id: int = 0\n self._login_message: str = ''\n @property\n def id(self) -> str:\n return self._id", + "detail": "src.gismo_core.configuration.server_settings", + "documentation": {} + }, + { + "label": "BotService", + "kind": 6, + "importPath": "src.gismo_core.service.bot_service", + "description": "src.gismo_core.service.bot_service", + "peekOfCode": "class BotService(BotServiceABC, commands.Bot):\n def __init__(self, config: ConfigurationABC, logger: LoggerABC, modules: ModuleServiceABC, discord_settings: DiscordSettings, bot_settings: BotSettings):\n # services\n self._config = config\n self._logger = logger\n self._modules = modules\n # settings\n self._discord_settings = discord_settings\n self._bot_settings: BotSettings = bot_settings\n # setup super", + "detail": "src.gismo_core.service.bot_service", + "documentation": {} + }, + { + "label": "MessageService", + "kind": 6, + "importPath": "src.gismo_core.service.message_service", + "description": "src.gismo_core.service.message_service", + "peekOfCode": "class MessageService(MessageServiceABC):\n def __init__(self, config: ConfigurationABC, logger: LoggerABC, bot: BotServiceABC):\n self._config = config\n self._logger = logger\n self._bot = bot\n async def delete_messages(self, messages: List[discord.Message]): \n self._logger.debug(__name__, f'Try to delete {messages.count()} messages')\n for message in messages:\n await self.delete_message(message)\n self._logger.debug(__name__, 'Deleting messages finished')", + "detail": "src.gismo_core.service.message_service", + "documentation": {} + }, + { + "label": "BootLog", + "kind": 6, + "importPath": "src.modules.boot_log.boot_log", + "description": "src.modules.boot_log.boot_log", + "peekOfCode": "class BootLog(ModuleABC):\n def __init__(\n self,\n config: ConfigurationABC,\n logging_st: LoggingSettings,\n logger: LoggerABC,\n bot: BotServiceABC,\n message_service: MessageServiceABC\n ):\n self._config = config", + "detail": "src.modules.boot_log.boot_log", + "documentation": {} + }, + { + "label": "BootLogExtension", + "kind": 6, + "importPath": "src.modules.boot_log.boot_log_extension", + "description": "src.modules.boot_log.boot_log_extension", + "peekOfCode": "class BootLogExtension(ApplicationExtensionABC):\n def __init__(self):\n pass\n async def run(self, config: ConfigurationABC, services: ServiceProviderABC):\n logger: LoggerABC = services.get_service(LoggerABC)\n logger.debug(__name__, 'BootLog extension started')\n config.add_configuration('Bot_StartTime', datetime.now())", + "detail": "src.modules.boot_log.boot_log_extension", + "documentation": {} + }, + { + "label": "ModuleABC", + "kind": 6, + "importPath": "src.modules_core.abc.module_abc", + "description": "src.modules_core.abc.module_abc", + "peekOfCode": "class ModuleABC(ABC):\n @abstractmethod\n def __init__(self): pass\n # @property\n # @abstractmethod\n # def events(self) -> List[EventsEnum]: pass", + "detail": "src.modules_core.abc.module_abc", + "documentation": {} + }, + { + "label": "ModuleServiceABC", + "kind": 6, + "importPath": "src.modules_core.abc.module_service_abc", + "description": "src.modules_core.abc.module_service_abc", + "peekOfCode": "class ModuleServiceABC(ABC):\n @abstractmethod\n def __init__(self): pass\n @abstractmethod\n async def on_ready(self): pass\n @abstractmethod\n async def on_message(self, message: discord.Message): pass", + "detail": "src.modules_core.abc.module_service_abc", + "documentation": {} + }, + { + "label": "ModuleService", + "kind": 6, + "importPath": "src.modules_core.service.module_service", + "description": "src.modules_core.service.module_service", + "peekOfCode": "class ModuleService(ModuleServiceABC):\n def __init__(self, logger: LoggerABC, services: ServiceProviderABC, env: ApplicationEnvironmentABC):\n self._logger = logger\n self._services = services\n self._env = env\n self._modules: List[ModuleABC] = List()\n self._modules.extend(ModuleABC.__subclasses__())\n async def on_ready(self):\n self._logger.debug(__name__, 'Start on_ready modules')\n modules = self._modules.where(lambda m: hasattr(m, EventsEnum.on_ready.value) and callable(m.on_ready))", + "detail": "src.modules_core.service.module_service", + "documentation": {} + }, + { + "label": "EventsEnum", + "kind": 6, + "importPath": "src.modules_core.events_enum", + "description": "src.modules_core.events_enum", + "peekOfCode": "class EventsEnum(Enum):\n on_ready = 'on_ready'", + "detail": "src.modules_core.events_enum", + "documentation": {} + }, + { + "label": "Application", + "kind": 6, + "importPath": "tools.level_generator.application", + "description": "tools.level_generator.application", + "peekOfCode": "class Application(ApplicationABC):\n def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):\n ApplicationABC.__init__(self, config, services)\n def configure(self):\n pass\n def main(self):\n f = open(\"./Levels.txt\", \"r\", encoding='utf-8')\n i = 0\n lines = f.readlines()\n json_list = []", + "detail": "tools.level_generator.application", + "documentation": {} + }, + { + "label": "main", + "kind": 2, + "importPath": "tools.level_generator.main", + "description": "tools.level_generator.main", + "peekOfCode": "def main():\n app_builder = ApplicationBuilder(Application)\n app_builder.use_startup(Startup)\n app_builder.build().run()\nif __name__ == '__main__':\n main()", + "detail": "tools.level_generator.main", + "documentation": {} + }, + { + "label": "Startup", + "kind": 6, + "importPath": "tools.level_generator.startup", + "description": "tools.level_generator.startup", + "peekOfCode": "class Startup(StartupABC):\n def __init__(self):\n StartupABC.__init__(self)\n def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:\n return configuration\n def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:\n return services.build_service_provider()", + "detail": "tools.level_generator.startup", + "documentation": {} + }, + { + "label": "Application", + "kind": 6, + "importPath": "tools.ontime_calculator.application", + "description": "tools.ontime_calculator.application", + "peekOfCode": "class Application(ApplicationABC):\n def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):\n ApplicationABC.__init__(self, config, services)\n def configure(self):\n pass\n def main(self):\n ontime = 0\n mc = 0\n for i in range(0, 31):\n Console.write_line(f'i: {i} {ontime} {mc}')", + "detail": "tools.ontime_calculator.application", + "documentation": {} + }, + { + "label": "main", + "kind": 2, + "importPath": "tools.ontime_calculator.main", + "description": "tools.ontime_calculator.main", + "peekOfCode": "def main():\n app_builder = ApplicationBuilder(Application)\n app_builder.use_startup(Startup)\n app_builder.build().run()\nif __name__ == '__main__':\n main()", + "detail": "tools.ontime_calculator.main", + "documentation": {} + }, + { + "label": "Startup", + "kind": 6, + "importPath": "tools.ontime_calculator.startup", + "description": "tools.ontime_calculator.startup", + "peekOfCode": "class Startup(StartupABC):\n def __init__(self):\n StartupABC.__init__(self)\n def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:\n return configuration\n def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:\n return services.build_service_provider()", + "detail": "tools.ontime_calculator.startup", + "documentation": {} + } +] \ No newline at end of file diff --git a/scripts/start.sh b/scripts/start.sh new file mode 100755 index 0000000..cc95535 --- /dev/null +++ b/scripts/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +export GISMO_ENVIRONMENT=development +cpl start \ No newline at end of file -- 2.45.2 From 5b61de0bf14db4da14f953710f7a2c523e51f121 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 17 Nov 2021 19:35:42 +0100 Subject: [PATCH 033/113] Added ctrl+c support --- src/gismo/application.py | 13 +++++++++++-- src/gismo/main.py | 26 +++++++++++++++++++------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/gismo/application.py b/src/gismo/application.py index 460d01a..c466271 100644 --- a/src/gismo/application.py +++ b/src/gismo/application.py @@ -1,8 +1,8 @@ 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 from cpl_core.logging import LoggerABC - from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.service.bot_service import BotService @@ -22,6 +22,15 @@ class Application(ApplicationABC): try: self._logger.trace(__name__, f'Try to start {BotService}') await self._bot.start_async() - self._logger.trace(__name__, f'Stopped {BotService}') except Exception as e: self._logger.error(__name__, 'Start failed', e) + + async def stop_async(self): + try: + self._logger.trace(__name__, f'Try to stop {BotService}') + await self._bot.close() + self._logger.trace(__name__, f'Stopped {BotService}') + except Exception as e: + self._logger.error(__name__, 'stop failed', e) + + Console.write_line() diff --git a/src/gismo/main.py b/src/gismo/main.py index 808b885..8b4d020 100644 --- a/src/gismo/main.py +++ b/src/gismo/main.py @@ -1,4 +1,5 @@ import asyncio +from typing import Optional from cpl_core.application import ApplicationABC, ApplicationBuilder @@ -6,14 +7,25 @@ from gismo.application import Application from gismo.startup import Startup from modules.boot_log.boot_log_extension import BootLogExtension +class Main: + + def __init__(self): + self._app: Optional[ApplicationABC] = None -async def main(): - app_builder = ApplicationBuilder(Application) - app_builder.use_extension(BootLogExtension) - app_builder.use_startup(Startup) - app: ApplicationABC = await app_builder.build_async() - await app.run_async() + async def main(self): + app_builder = ApplicationBuilder(Application) + app_builder.use_extension(BootLogExtension) + app_builder.use_startup(Startup) + self._app: ApplicationABC = await app_builder.build_async() + await self._app.run_async() + + async def stop(self): + await self._app.stop_async() if __name__ == '__main__': + main = Main() ml = asyncio.get_event_loop() - ml.run_until_complete(main()) + try: + ml.run_until_complete(main.main()) + except KeyboardInterrupt: + ml.run_until_complete(main.stop()) \ No newline at end of file -- 2.45.2 From 6509f628ca39b22a6a130d36df1c3bcf8457e998 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 17 Nov 2021 19:43:00 +0100 Subject: [PATCH 034/113] Added on_message handling --- src/gismo/appsettings.development.json | 2 +- src/modules/boot_log/boot_log.py | 8 +++++--- src/modules_core/abc/module_abc.py | 7 +------ src/modules_core/abc/on_message_abc.py | 11 +++++++++++ src/modules_core/abc/on_ready_abc.py | 10 ++++++++++ src/modules_core/service/module_service.py | 21 +++++++++++++++++---- 6 files changed, 45 insertions(+), 14 deletions(-) create mode 100644 src/modules_core/abc/on_message_abc.py create mode 100644 src/modules_core/abc/on_ready_abc.py diff --git a/src/gismo/appsettings.development.json b/src/gismo/appsettings.development.json index 19d2377..1bacb79 100644 --- a/src/gismo/appsettings.development.json +++ b/src/gismo/appsettings.development.json @@ -8,7 +8,7 @@ "LoggingSettings": { "Path": "logs/", - "Filename": "log_$start_time.log", + "Filename": "log_dev.log", "ConsoleLogLevel": "TRACE", "FileLogLevel": "TRACE" }, diff --git a/src/modules/boot_log/boot_log.py b/src/modules/boot_log/boot_log.py index 42ea00f..df54145 100644 --- a/src/modules/boot_log/boot_log.py +++ b/src/modules/boot_log/boot_log.py @@ -1,17 +1,19 @@ from datetime import datetime +import discord +from discord import guild +from async_timeout import asyncio from cpl_core.configuration import ConfigurationABC from cpl_core.console import Console from cpl_core.logging import LoggerABC, LoggingLevelEnum, LoggingSettings -from discord import guild - from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.abc.message_service_abc import MessageServiceABC from gismo_core.configuration.server_settings import ServerSettings from modules_core.abc.module_abc import ModuleABC +from modules_core.abc.on_ready_abc import OnReadyABC -class BootLog(ModuleABC): +class BootLog(ModuleABC, OnReadyABC): def __init__( self, diff --git a/src/modules_core/abc/module_abc.py b/src/modules_core/abc/module_abc.py index 836c29a..a9645a7 100644 --- a/src/modules_core/abc/module_abc.py +++ b/src/modules_core/abc/module_abc.py @@ -1,13 +1,8 @@ from abc import ABC, abstractmethod -from cpl_query.extension import List -from modules_core.events_enum import EventsEnum +import discord class ModuleABC(ABC): @abstractmethod def __init__(self): pass - - # @property - # @abstractmethod - # def events(self) -> List[EventsEnum]: pass diff --git a/src/modules_core/abc/on_message_abc.py b/src/modules_core/abc/on_message_abc.py new file mode 100644 index 0000000..08e3816 --- /dev/null +++ b/src/modules_core/abc/on_message_abc.py @@ -0,0 +1,11 @@ +from abc import ABC, abstractmethod +import discord + + +class OnMessageABC(ABC): + + @abstractmethod + def __init__(self): pass + + @abstractmethod + async def on_message(self, message: discord.Message): pass diff --git a/src/modules_core/abc/on_ready_abc.py b/src/modules_core/abc/on_ready_abc.py new file mode 100644 index 0000000..053bf79 --- /dev/null +++ b/src/modules_core/abc/on_ready_abc.py @@ -0,0 +1,10 @@ +from abc import ABC, abstractmethod + + +class OnReadyABC(ABC): + + @abstractmethod + def __init__(self): pass + + @abstractmethod + async def on_ready(self): pass diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index 94a4e17..6e41724 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -1,3 +1,4 @@ +from async_timeout import asyncio import discord from discord.ext import commands @@ -7,7 +8,8 @@ from cpl_core.logging import LoggerABC from cpl_query.extension import List from modules_core.abc.module_abc import ModuleABC from modules_core.abc.module_service_abc import ModuleServiceABC -from modules_core.events_enum import EventsEnum +from modules_core.abc.on_message_abc import OnMessageABC +from modules_core.abc.on_ready_abc import OnReadyABC class ModuleService(ModuleServiceABC): @@ -21,10 +23,21 @@ class ModuleService(ModuleServiceABC): async def on_ready(self): self._logger.debug(__name__, 'Start on_ready modules') - modules = self._modules.where(lambda m: hasattr(m, EventsEnum.on_ready.value) and callable(m.on_ready)) + modules = self._modules.where(lambda m: issubclass(m, OnReadyABC)) for module_type in modules: - module = self._services.get_service(module_type) + module_type = module_type + module: OnReadyABC = self._services.get_service(module_type) await module.on_ready() + + self._logger.debug(__name__, 'Stopped on_ready modules') async def on_message(self, message: discord.Message): - pass \ No newline at end of file + self._logger.debug(__name__, 'Start on_message modules') + modules = self._modules.where(lambda m: issubclass(m, OnMessageABC)) + + for module_type in modules: + module_type = module_type + module: OnMessageABC = self._services.get_service(module_type) + await module.on_message(message) + + self._logger.debug(__name__, f'Stopped on_message modules') \ No newline at end of file -- 2.45.2 From d6b65c42cc96961a35a08e2d0fb5555fcdfd4800 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 17 Nov 2021 19:44:23 +0100 Subject: [PATCH 035/113] Removed vs code file --- .gitignore | 4 +- .vscode/PythonImportHelper-v2-Completion.json | 185 +++++++++++++----- 2 files changed, 140 insertions(+), 49 deletions(-) diff --git a/.gitignore b/.gitignore index c337315..287718c 100644 --- a/.gitignore +++ b/.gitignore @@ -138,6 +138,6 @@ dmypy.json # Cython debug symbols cython_debug/ -# gismo -g-env/ +# custom vs code +.vscode/PythonImportHelper-v2-Completion.json diff --git a/.vscode/PythonImportHelper-v2-Completion.json b/.vscode/PythonImportHelper-v2-Completion.json index 3911507..30d844b 100644 --- a/.vscode/PythonImportHelper-v2-Completion.json +++ b/.vscode/PythonImportHelper-v2-Completion.json @@ -335,6 +335,14 @@ "detail": "cpl_core.console", "documentation": {} }, + { + "label": "Console", + "importPath": "cpl_core.console", + "description": "cpl_core.console", + "isExtraImport": true, + "detail": "cpl_core.console", + "documentation": {} + }, { "label": "ServiceProviderABC", "importPath": "cpl_core.dependency_injection", @@ -704,6 +712,38 @@ "detail": "gismo_core.service.bot_service", "documentation": {} }, + { + "label": "Optional", + "importPath": "typing", + "description": "typing", + "isExtraImport": true, + "detail": "typing", + "documentation": {} + }, + { + "label": "Optional", + "importPath": "typing", + "description": "typing", + "isExtraImport": true, + "detail": "typing", + "documentation": {} + }, + { + "label": "Union", + "importPath": "typing", + "description": "typing", + "isExtraImport": true, + "detail": "typing", + "documentation": {} + }, + { + "label": "Union", + "importPath": "typing", + "description": "typing", + "isExtraImport": true, + "detail": "typing", + "documentation": {} + }, { "label": "BootLogExtension", "importPath": "modules.boot_log.boot_log_extension", @@ -736,30 +776,6 @@ "detail": "datetime", "documentation": {} }, - { - "label": "Optional", - "importPath": "typing", - "description": "typing", - "isExtraImport": true, - "detail": "typing", - "documentation": {} - }, - { - "label": "Union", - "importPath": "typing", - "description": "typing", - "isExtraImport": true, - "detail": "typing", - "documentation": {} - }, - { - "label": "Union", - "importPath": "typing", - "description": "typing", - "isExtraImport": true, - "detail": "typing", - "documentation": {} - }, { "label": "MessageServiceABC", "importPath": "gismo_core.abc.message_service_abc", @@ -936,6 +952,38 @@ "detail": "abc", "documentation": {} }, + { + "label": "ABC", + "importPath": "abc", + "description": "abc", + "isExtraImport": true, + "detail": "abc", + "documentation": {} + }, + { + "label": "abstractmethod", + "importPath": "abc", + "description": "abc", + "isExtraImport": true, + "detail": "abc", + "documentation": {} + }, + { + "label": "ABC", + "importPath": "abc", + "description": "abc", + "isExtraImport": true, + "detail": "abc", + "documentation": {} + }, + { + "label": "abstractmethod", + "importPath": "abc", + "description": "abc", + "isExtraImport": true, + "detail": "abc", + "documentation": {} + }, { "label": "discord", "kind": 6, @@ -1009,14 +1057,6 @@ "detail": "cpl_query.extension", "documentation": {} }, - { - "label": "List", - "importPath": "cpl_query.extension", - "description": "cpl_query.extension", - "isExtraImport": true, - "detail": "cpl_query.extension", - "documentation": {} - }, { "label": "Context", "importPath": "discord.ext.commands", @@ -1106,6 +1146,38 @@ "detail": "cpl_core.configuration.configuration_abc", "documentation": {} }, + { + "label": "asyncio", + "importPath": "async_timeout", + "description": "async_timeout", + "isExtraImport": true, + "detail": "async_timeout", + "documentation": {} + }, + { + "label": "asyncio", + "importPath": "async_timeout", + "description": "async_timeout", + "isExtraImport": true, + "detail": "async_timeout", + "documentation": {} + }, + { + "label": "OnReadyABC", + "importPath": "modules_core.abc.on_ready_abc", + "description": "modules_core.abc.on_ready_abc", + "isExtraImport": true, + "detail": "modules_core.abc.on_ready_abc", + "documentation": {} + }, + { + "label": "OnReadyABC", + "importPath": "modules_core.abc.on_ready_abc", + "description": "modules_core.abc.on_ready_abc", + "isExtraImport": true, + "detail": "modules_core.abc.on_ready_abc", + "documentation": {} + }, { "label": "ApplicationExtensionABC", "importPath": "cpl_core.application.application_extension_abc", @@ -1115,19 +1187,11 @@ "documentation": {} }, { - "label": "EventsEnum", - "importPath": "modules_core.events_enum", - "description": "modules_core.events_enum", + "label": "OnMessageABC", + "importPath": "modules_core.abc.on_message_abc", + "description": "modules_core.abc.on_message_abc", "isExtraImport": true, - "detail": "modules_core.events_enum", - "documentation": {} - }, - { - "label": "EventsEnum", - "importPath": "modules_core.events_enum", - "description": "modules_core.events_enum", - "isExtraImport": true, - "detail": "modules_core.events_enum", + "detail": "modules_core.abc.on_message_abc", "documentation": {} }, { @@ -1233,6 +1297,15 @@ "detail": "src.gismo.application", "documentation": {} }, + { + "label": "Main", + "kind": 6, + "importPath": "src.gismo.main", + "description": "src.gismo.main", + "peekOfCode": "class Main:\n def __init__(self):\n self._app: Optional[ApplicationABC] = None\n async def main(self):\n app_builder = ApplicationBuilder(Application)\n app_builder.use_extension(BootLogExtension)\n app_builder.use_startup(Startup)\n self._app: ApplicationABC = await app_builder.build_async()\n await self._app.run_async()\n async def stop(self):", + "detail": "src.gismo.main", + "documentation": {} + }, { "label": "Startup", "kind": 6, @@ -1328,7 +1401,7 @@ "kind": 6, "importPath": "src.modules.boot_log.boot_log", "description": "src.modules.boot_log.boot_log", - "peekOfCode": "class BootLog(ModuleABC):\n def __init__(\n self,\n config: ConfigurationABC,\n logging_st: LoggingSettings,\n logger: LoggerABC,\n bot: BotServiceABC,\n message_service: MessageServiceABC\n ):\n self._config = config", + "peekOfCode": "class BootLog(ModuleABC, OnReadyABC):\n def __init__(\n self,\n config: ConfigurationABC,\n logging_st: LoggingSettings,\n logger: LoggerABC,\n bot: BotServiceABC,\n message_service: MessageServiceABC\n ):\n self._config = config", "detail": "src.modules.boot_log.boot_log", "documentation": {} }, @@ -1346,7 +1419,7 @@ "kind": 6, "importPath": "src.modules_core.abc.module_abc", "description": "src.modules_core.abc.module_abc", - "peekOfCode": "class ModuleABC(ABC):\n @abstractmethod\n def __init__(self): pass\n # @property\n # @abstractmethod\n # def events(self) -> List[EventsEnum]: pass", + "peekOfCode": "class ModuleABC(ABC):\n @abstractmethod\n def __init__(self): pass", "detail": "src.modules_core.abc.module_abc", "documentation": {} }, @@ -1359,12 +1432,30 @@ "detail": "src.modules_core.abc.module_service_abc", "documentation": {} }, + { + "label": "OnMessageABC", + "kind": 6, + "importPath": "src.modules_core.abc.on_message_abc", + "description": "src.modules_core.abc.on_message_abc", + "peekOfCode": "class OnMessageABC(ABC):\n @abstractmethod\n def __init__(self): pass\n @abstractmethod\n async def on_message(self, message: discord.Message): pass", + "detail": "src.modules_core.abc.on_message_abc", + "documentation": {} + }, + { + "label": "OnReadyABC", + "kind": 6, + "importPath": "src.modules_core.abc.on_ready_abc", + "description": "src.modules_core.abc.on_ready_abc", + "peekOfCode": "class OnReadyABC(ABC):\n @abstractmethod\n def __init__(self): pass\n @abstractmethod\n async def on_ready(self): pass", + "detail": "src.modules_core.abc.on_ready_abc", + "documentation": {} + }, { "label": "ModuleService", "kind": 6, "importPath": "src.modules_core.service.module_service", "description": "src.modules_core.service.module_service", - "peekOfCode": "class ModuleService(ModuleServiceABC):\n def __init__(self, logger: LoggerABC, services: ServiceProviderABC, env: ApplicationEnvironmentABC):\n self._logger = logger\n self._services = services\n self._env = env\n self._modules: List[ModuleABC] = List()\n self._modules.extend(ModuleABC.__subclasses__())\n async def on_ready(self):\n self._logger.debug(__name__, 'Start on_ready modules')\n modules = self._modules.where(lambda m: hasattr(m, EventsEnum.on_ready.value) and callable(m.on_ready))", + "peekOfCode": "class ModuleService(ModuleServiceABC):\n def __init__(self, logger: LoggerABC, services: ServiceProviderABC, env: ApplicationEnvironmentABC):\n self._logger = logger\n self._services = services\n self._env = env\n self._modules: List[ModuleABC] = List()\n self._modules.extend(ModuleABC.__subclasses__())\n async def on_ready(self):\n self._logger.debug(__name__, 'Start on_ready modules')\n modules = self._modules.where(lambda m: issubclass(m, OnReadyABC))", "detail": "src.modules_core.service.module_service", "documentation": {} }, -- 2.45.2 From 3832f9b8fcd7f749dc58276231e9fca44d528ba9 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 18 Nov 2021 08:46:19 +0100 Subject: [PATCH 036/113] Added events to ModuleServiceABC --- .gitignore | 2 +- .vscode/PythonImportHelper-v2-Completion.json | 1525 ----------------- src/modules_core/abc/module_service_abc.py | 137 ++ src/modules_core/service/module_service.py | 1 - 4 files changed, 138 insertions(+), 1527 deletions(-) delete mode 100644 .vscode/PythonImportHelper-v2-Completion.json diff --git a/.gitignore b/.gitignore index 287718c..6a660d8 100644 --- a/.gitignore +++ b/.gitignore @@ -139,5 +139,5 @@ dmypy.json cython_debug/ # custom vs code -.vscode/PythonImportHelper-v2-Completion.json +PythonImportHelper-v2-Completion.json diff --git a/.vscode/PythonImportHelper-v2-Completion.json b/.vscode/PythonImportHelper-v2-Completion.json deleted file mode 100644 index 30d844b..0000000 --- a/.vscode/PythonImportHelper-v2-Completion.json +++ /dev/null @@ -1,1525 +0,0 @@ -[ - { - "label": "ApplicationABC", - "importPath": "cpl_core.application", - "description": "cpl_core.application", - "isExtraImport": true, - "detail": "cpl_core.application", - "documentation": {} - }, - { - "label": "ApplicationBuilder", - "importPath": "cpl_core.application", - "description": "cpl_core.application", - "isExtraImport": true, - "detail": "cpl_core.application", - "documentation": {} - }, - { - "label": "StartupABC", - "importPath": "cpl_core.application", - "description": "cpl_core.application", - "isExtraImport": true, - "detail": "cpl_core.application", - "documentation": {} - }, - { - "label": "ApplicationABC", - "importPath": "cpl_core.application", - "description": "cpl_core.application", - "isExtraImport": true, - "detail": "cpl_core.application", - "documentation": {} - }, - { - "label": "ApplicationABC", - "importPath": "cpl_core.application", - "description": "cpl_core.application", - "isExtraImport": true, - "detail": "cpl_core.application", - "documentation": {} - }, - { - "label": "ApplicationBuilder", - "importPath": "cpl_core.application", - "description": "cpl_core.application", - "isExtraImport": true, - "detail": "cpl_core.application", - "documentation": {} - }, - { - "label": "StartupABC", - "importPath": "cpl_core.application", - "description": "cpl_core.application", - "isExtraImport": true, - "detail": "cpl_core.application", - "documentation": {} - }, - { - "label": "ApplicationABC", - "importPath": "cpl_core.application", - "description": "cpl_core.application", - "isExtraImport": true, - "detail": "cpl_core.application", - "documentation": {} - }, - { - "label": "ApplicationBuilder", - "importPath": "cpl_core.application", - "description": "cpl_core.application", - "isExtraImport": true, - "detail": "cpl_core.application", - "documentation": {} - }, - { - "label": "StartupABC", - "importPath": "cpl_core.application", - "description": "cpl_core.application", - "isExtraImport": true, - "detail": "cpl_core.application", - "documentation": {} - }, - { - "label": "ApplicationABC", - "importPath": "cpl_core.application", - "description": "cpl_core.application", - "isExtraImport": true, - "detail": "cpl_core.application", - "documentation": {} - }, - { - "label": "ApplicationBuilder", - "importPath": "cpl_core.application", - "description": "cpl_core.application", - "isExtraImport": true, - "detail": "cpl_core.application", - "documentation": {} - }, - { - "label": "StartupABC", - "importPath": "cpl_core.application", - "description": "cpl_core.application", - "isExtraImport": true, - "detail": "cpl_core.application", - "documentation": {} - }, - { - "label": "ApplicationABC", - "importPath": "cpl_core.application", - "description": "cpl_core.application", - "isExtraImport": true, - "detail": "cpl_core.application", - "documentation": {} - }, - { - "label": "ApplicationBuilder", - "importPath": "cpl_core.application", - "description": "cpl_core.application", - "isExtraImport": true, - "detail": "cpl_core.application", - "documentation": {} - }, - { - "label": "StartupABC", - "importPath": "cpl_core.application", - "description": "cpl_core.application", - "isExtraImport": true, - "detail": "cpl_core.application", - "documentation": {} - }, - { - "label": "ConfigurationABC", - "importPath": "cpl_core.configuration", - "description": "cpl_core.configuration", - "isExtraImport": true, - "detail": "cpl_core.configuration", - "documentation": {} - }, - { - "label": "ConfigurationABC", - "importPath": "cpl_core.configuration", - "description": "cpl_core.configuration", - "isExtraImport": true, - "detail": "cpl_core.configuration", - "documentation": {} - }, - { - "label": "Configuration", - "importPath": "cpl_core.configuration", - "description": "cpl_core.configuration", - "isExtraImport": true, - "detail": "cpl_core.configuration", - "documentation": {} - }, - { - "label": "ConfigurationABC", - "importPath": "cpl_core.configuration", - "description": "cpl_core.configuration", - "isExtraImport": true, - "detail": "cpl_core.configuration", - "documentation": {} - }, - { - "label": "ConfigurationABC", - "importPath": "cpl_core.configuration", - "description": "cpl_core.configuration", - "isExtraImport": true, - "detail": "cpl_core.configuration", - "documentation": {} - }, - { - "label": "ConfigurationABC", - "importPath": "cpl_core.configuration", - "description": "cpl_core.configuration", - "isExtraImport": true, - "detail": "cpl_core.configuration", - "documentation": {} - }, - { - "label": "ConfigurationABC", - "importPath": "cpl_core.configuration", - "description": "cpl_core.configuration", - "isExtraImport": true, - "detail": "cpl_core.configuration", - "documentation": {} - }, - { - "label": "ConfigurationABC", - "importPath": "cpl_core.configuration", - "description": "cpl_core.configuration", - "isExtraImport": true, - "detail": "cpl_core.configuration", - "documentation": {} - }, - { - "label": "ConfigurationModelABC", - "importPath": "cpl_core.configuration", - "description": "cpl_core.configuration", - "isExtraImport": true, - "detail": "cpl_core.configuration", - "documentation": {} - }, - { - "label": "ConfigurationModelABC", - "importPath": "cpl_core.configuration", - "description": "cpl_core.configuration", - "isExtraImport": true, - "detail": "cpl_core.configuration", - "documentation": {} - }, - { - "label": "ConfigurationABC", - "importPath": "cpl_core.configuration", - "description": "cpl_core.configuration", - "isExtraImport": true, - "detail": "cpl_core.configuration", - "documentation": {} - }, - { - "label": "ConfigurationABC", - "importPath": "cpl_core.configuration", - "description": "cpl_core.configuration", - "isExtraImport": true, - "detail": "cpl_core.configuration", - "documentation": {} - }, - { - "label": "ConfigurationABC", - "importPath": "cpl_core.configuration", - "description": "cpl_core.configuration", - "isExtraImport": true, - "detail": "cpl_core.configuration", - "documentation": {} - }, - { - "label": "ConfigurationABC", - "importPath": "cpl_core.configuration", - "description": "cpl_core.configuration", - "isExtraImport": true, - "detail": "cpl_core.configuration", - "documentation": {} - }, - { - "label": "ConfigurationABC", - "importPath": "cpl_core.configuration", - "description": "cpl_core.configuration", - "isExtraImport": true, - "detail": "cpl_core.configuration", - "documentation": {} - }, - { - "label": "ConfigurationABC", - "importPath": "cpl_core.configuration", - "description": "cpl_core.configuration", - "isExtraImport": true, - "detail": "cpl_core.configuration", - "documentation": {} - }, - { - "label": "ConfigurationABC", - "importPath": "cpl_core.configuration", - "description": "cpl_core.configuration", - "isExtraImport": true, - "detail": "cpl_core.configuration", - "documentation": {} - }, - { - "label": "Console", - "importPath": "cpl_core.console", - "description": "cpl_core.console", - "isExtraImport": true, - "detail": "cpl_core.console", - "documentation": {} - }, - { - "label": "Console", - "importPath": "cpl_core.console", - "description": "cpl_core.console", - "isExtraImport": true, - "detail": "cpl_core.console", - "documentation": {} - }, - { - "label": "Console", - "importPath": "cpl_core.console", - "description": "cpl_core.console", - "isExtraImport": true, - "detail": "cpl_core.console", - "documentation": {} - }, - { - "label": "Console", - "importPath": "cpl_core.console", - "description": "cpl_core.console", - "isExtraImport": true, - "detail": "cpl_core.console", - "documentation": {} - }, - { - "label": "Console", - "importPath": "cpl_core.console", - "description": "cpl_core.console", - "isExtraImport": true, - "detail": "cpl_core.console", - "documentation": {} - }, - { - "label": "Console", - "importPath": "cpl_core.console", - "description": "cpl_core.console", - "isExtraImport": true, - "detail": "cpl_core.console", - "documentation": {} - }, - { - "label": "Console", - "importPath": "cpl_core.console", - "description": "cpl_core.console", - "isExtraImport": true, - "detail": "cpl_core.console", - "documentation": {} - }, - { - "label": "Console", - "importPath": "cpl_core.console", - "description": "cpl_core.console", - "isExtraImport": true, - "detail": "cpl_core.console", - "documentation": {} - }, - { - "label": "Console", - "importPath": "cpl_core.console", - "description": "cpl_core.console", - "isExtraImport": true, - "detail": "cpl_core.console", - "documentation": {} - }, - { - "label": "Console", - "importPath": "cpl_core.console", - "description": "cpl_core.console", - "isExtraImport": true, - "detail": "cpl_core.console", - "documentation": {} - }, - { - "label": "ServiceProviderABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceProviderABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceCollectionABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceCollection", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceProviderABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceProviderABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceCollectionABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceProviderABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceProviderABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceProviderABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceCollectionABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceProviderABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceProviderABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceProviderABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceProviderABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceCollectionABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceProviderABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceProviderABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "ServiceCollectionABC", - "importPath": "cpl_core.dependency_injection", - "description": "cpl_core.dependency_injection", - "isExtraImport": true, - "detail": "cpl_core.dependency_injection", - "documentation": {} - }, - { - "label": "asyncio", - "kind": 6, - "isExtraImport": true, - "importPath": "asyncio", - "description": "asyncio", - "detail": "asyncio", - "documentation": {} - }, - { - "label": "Application", - "importPath": "gismo.application", - "description": "gismo.application", - "isExtraImport": true, - "detail": "gismo.application", - "documentation": {} - }, - { - "label": "Application", - "importPath": "gismo.application", - "description": "gismo.application", - "isExtraImport": true, - "detail": "gismo.application", - "documentation": {} - }, - { - "label": "Startup", - "importPath": "gismo.startup", - "description": "gismo.startup", - "isExtraImport": true, - "detail": "gismo.startup", - "documentation": {} - }, - { - "label": "Startup", - "importPath": "gismo.startup", - "description": "gismo.startup", - "isExtraImport": true, - "detail": "gismo.startup", - "documentation": {} - }, - { - "label": "ApplicationEnvironment", - "importPath": "cpl_core.environment", - "description": "cpl_core.environment", - "isExtraImport": true, - "detail": "cpl_core.environment", - "documentation": {} - }, - { - "label": "ApplicationEnvironment", - "importPath": "cpl_core.environment", - "description": "cpl_core.environment", - "isExtraImport": true, - "detail": "cpl_core.environment", - "documentation": {} - }, - { - "label": "ApplicationEnvironment", - "importPath": "cpl_core.environment", - "description": "cpl_core.environment", - "isExtraImport": true, - "detail": "cpl_core.environment", - "documentation": {} - }, - { - "label": "ApplicationEnvironmentABC", - "importPath": "cpl_core.environment", - "description": "cpl_core.environment", - "isExtraImport": true, - "detail": "cpl_core.environment", - "documentation": {} - }, - { - "label": "ApplicationEnvironment", - "importPath": "cpl_core.environment", - "description": "cpl_core.environment", - "isExtraImport": true, - "detail": "cpl_core.environment", - "documentation": {} - }, - { - "label": "ApplicationEnvironment", - "importPath": "cpl_core.environment", - "description": "cpl_core.environment", - "isExtraImport": true, - "detail": "cpl_core.environment", - "documentation": {} - }, - { - "label": "LoggerABC", - "importPath": "cpl_core.logging", - "description": "cpl_core.logging", - "isExtraImport": true, - "detail": "cpl_core.logging", - "documentation": {} - }, - { - "label": "LoggerABC", - "importPath": "cpl_core.logging", - "description": "cpl_core.logging", - "isExtraImport": true, - "detail": "cpl_core.logging", - "documentation": {} - }, - { - "label": "LoggerABC", - "importPath": "cpl_core.logging", - "description": "cpl_core.logging", - "isExtraImport": true, - "detail": "cpl_core.logging", - "documentation": {} - }, - { - "label": "LoggerABC", - "importPath": "cpl_core.logging", - "description": "cpl_core.logging", - "isExtraImport": true, - "detail": "cpl_core.logging", - "documentation": {} - }, - { - "label": "LoggerABC", - "importPath": "cpl_core.logging", - "description": "cpl_core.logging", - "isExtraImport": true, - "detail": "cpl_core.logging", - "documentation": {} - }, - { - "label": "LoggingLevelEnum", - "importPath": "cpl_core.logging", - "description": "cpl_core.logging", - "isExtraImport": true, - "detail": "cpl_core.logging", - "documentation": {} - }, - { - "label": "LoggingSettings", - "importPath": "cpl_core.logging", - "description": "cpl_core.logging", - "isExtraImport": true, - "detail": "cpl_core.logging", - "documentation": {} - }, - { - "label": "LoggerABC", - "importPath": "cpl_core.logging", - "description": "cpl_core.logging", - "isExtraImport": true, - "detail": "cpl_core.logging", - "documentation": {} - }, - { - "label": "LoggerABC", - "importPath": "cpl_core.logging", - "description": "cpl_core.logging", - "isExtraImport": true, - "detail": "cpl_core.logging", - "documentation": {} - }, - { - "label": "BotServiceABC", - "importPath": "gismo_core.abc.bot_service_abc", - "description": "gismo_core.abc.bot_service_abc", - "isExtraImport": true, - "detail": "gismo_core.abc.bot_service_abc", - "documentation": {} - }, - { - "label": "BotServiceABC", - "importPath": "gismo_core.abc.bot_service_abc", - "description": "gismo_core.abc.bot_service_abc", - "isExtraImport": true, - "detail": "gismo_core.abc.bot_service_abc", - "documentation": {} - }, - { - "label": "BotServiceABC", - "importPath": "gismo_core.abc.bot_service_abc", - "description": "gismo_core.abc.bot_service_abc", - "isExtraImport": true, - "detail": "gismo_core.abc.bot_service_abc", - "documentation": {} - }, - { - "label": "BotServiceABC", - "importPath": "gismo_core.abc.bot_service_abc", - "description": "gismo_core.abc.bot_service_abc", - "isExtraImport": true, - "detail": "gismo_core.abc.bot_service_abc", - "documentation": {} - }, - { - "label": "BotServiceABC", - "importPath": "gismo_core.abc.bot_service_abc", - "description": "gismo_core.abc.bot_service_abc", - "isExtraImport": true, - "detail": "gismo_core.abc.bot_service_abc", - "documentation": {} - }, - { - "label": "BotService", - "importPath": "gismo_core.service.bot_service", - "description": "gismo_core.service.bot_service", - "isExtraImport": true, - "detail": "gismo_core.service.bot_service", - "documentation": {} - }, - { - "label": "BotService", - "importPath": "gismo_core.service.bot_service", - "description": "gismo_core.service.bot_service", - "isExtraImport": true, - "detail": "gismo_core.service.bot_service", - "documentation": {} - }, - { - "label": "Optional", - "importPath": "typing", - "description": "typing", - "isExtraImport": true, - "detail": "typing", - "documentation": {} - }, - { - "label": "Optional", - "importPath": "typing", - "description": "typing", - "isExtraImport": true, - "detail": "typing", - "documentation": {} - }, - { - "label": "Union", - "importPath": "typing", - "description": "typing", - "isExtraImport": true, - "detail": "typing", - "documentation": {} - }, - { - "label": "Union", - "importPath": "typing", - "description": "typing", - "isExtraImport": true, - "detail": "typing", - "documentation": {} - }, - { - "label": "BootLogExtension", - "importPath": "modules.boot_log.boot_log_extension", - "description": "modules.boot_log.boot_log_extension", - "isExtraImport": true, - "detail": "modules.boot_log.boot_log_extension", - "documentation": {} - }, - { - "label": "datetime", - "importPath": "datetime", - "description": "datetime", - "isExtraImport": true, - "detail": "datetime", - "documentation": {} - }, - { - "label": "datetime", - "importPath": "datetime", - "description": "datetime", - "isExtraImport": true, - "detail": "datetime", - "documentation": {} - }, - { - "label": "datetime", - "importPath": "datetime", - "description": "datetime", - "isExtraImport": true, - "detail": "datetime", - "documentation": {} - }, - { - "label": "MessageServiceABC", - "importPath": "gismo_core.abc.message_service_abc", - "description": "gismo_core.abc.message_service_abc", - "isExtraImport": true, - "detail": "gismo_core.abc.message_service_abc", - "documentation": {} - }, - { - "label": "MessageServiceABC", - "importPath": "gismo_core.abc.message_service_abc", - "description": "gismo_core.abc.message_service_abc", - "isExtraImport": true, - "detail": "gismo_core.abc.message_service_abc", - "documentation": {} - }, - { - "label": "MessageServiceABC", - "importPath": "gismo_core.abc.message_service_abc", - "description": "gismo_core.abc.message_service_abc", - "isExtraImport": true, - "detail": "gismo_core.abc.message_service_abc", - "documentation": {} - }, - { - "label": "MessageService", - "importPath": "gismo_core.service.message_service", - "description": "gismo_core.service.message_service", - "isExtraImport": true, - "detail": "gismo_core.service.message_service", - "documentation": {} - }, - { - "label": "BootLog", - "importPath": "modules.boot_log.boot_log", - "description": "modules.boot_log.boot_log", - "isExtraImport": true, - "detail": "modules.boot_log.boot_log", - "documentation": {} - }, - { - "label": "ModuleABC", - "importPath": "modules_core.abc.module_abc", - "description": "modules_core.abc.module_abc", - "isExtraImport": true, - "detail": "modules_core.abc.module_abc", - "documentation": {} - }, - { - "label": "ModuleABC", - "importPath": "modules_core.abc.module_abc", - "description": "modules_core.abc.module_abc", - "isExtraImport": true, - "detail": "modules_core.abc.module_abc", - "documentation": {} - }, - { - "label": "ModuleABC", - "importPath": "modules_core.abc.module_abc", - "description": "modules_core.abc.module_abc", - "isExtraImport": true, - "detail": "modules_core.abc.module_abc", - "documentation": {} - }, - { - "label": "ModuleServiceABC", - "importPath": "modules_core.abc.module_service_abc", - "description": "modules_core.abc.module_service_abc", - "isExtraImport": true, - "detail": "modules_core.abc.module_service_abc", - "documentation": {} - }, - { - "label": "ModuleServiceABC", - "importPath": "modules_core.abc.module_service_abc", - "description": "modules_core.abc.module_service_abc", - "isExtraImport": true, - "detail": "modules_core.abc.module_service_abc", - "documentation": {} - }, - { - "label": "ModuleServiceABC", - "importPath": "modules_core.abc.module_service_abc", - "description": "modules_core.abc.module_service_abc", - "isExtraImport": true, - "detail": "modules_core.abc.module_service_abc", - "documentation": {} - }, - { - "label": "ModuleService", - "importPath": "modules_core.service.module_service", - "description": "modules_core.service.module_service", - "isExtraImport": true, - "detail": "modules_core.service.module_service", - "documentation": {} - }, - { - "label": "Application", - "importPath": "gismo_cli.application", - "description": "gismo_cli.application", - "isExtraImport": true, - "detail": "gismo_cli.application", - "documentation": {} - }, - { - "label": "Startup", - "importPath": "gismo_cli.startup", - "description": "gismo_cli.startup", - "isExtraImport": true, - "detail": "gismo_cli.startup", - "documentation": {} - }, - { - "label": "ABC", - "importPath": "abc", - "description": "abc", - "isExtraImport": true, - "detail": "abc", - "documentation": {} - }, - { - "label": "abstractmethod", - "importPath": "abc", - "description": "abc", - "isExtraImport": true, - "detail": "abc", - "documentation": {} - }, - { - "label": "ABC", - "importPath": "abc", - "description": "abc", - "isExtraImport": true, - "detail": "abc", - "documentation": {} - }, - { - "label": "abstractmethod", - "importPath": "abc", - "description": "abc", - "isExtraImport": true, - "detail": "abc", - "documentation": {} - }, - { - "label": "ABC", - "importPath": "abc", - "description": "abc", - "isExtraImport": true, - "detail": "abc", - "documentation": {} - }, - { - "label": "abstractmethod", - "importPath": "abc", - "description": "abc", - "isExtraImport": true, - "detail": "abc", - "documentation": {} - }, - { - "label": "ABC", - "importPath": "abc", - "description": "abc", - "isExtraImport": true, - "detail": "abc", - "documentation": {} - }, - { - "label": "abstractmethod", - "importPath": "abc", - "description": "abc", - "isExtraImport": true, - "detail": "abc", - "documentation": {} - }, - { - "label": "ABC", - "importPath": "abc", - "description": "abc", - "isExtraImport": true, - "detail": "abc", - "documentation": {} - }, - { - "label": "abstractmethod", - "importPath": "abc", - "description": "abc", - "isExtraImport": true, - "detail": "abc", - "documentation": {} - }, - { - "label": "ABC", - "importPath": "abc", - "description": "abc", - "isExtraImport": true, - "detail": "abc", - "documentation": {} - }, - { - "label": "abstractmethod", - "importPath": "abc", - "description": "abc", - "isExtraImport": true, - "detail": "abc", - "documentation": {} - }, - { - "label": "discord", - "kind": 6, - "isExtraImport": true, - "importPath": "discord", - "description": "discord", - "detail": "discord", - "documentation": {} - }, - { - "label": "guild", - "importPath": "discord", - "description": "discord", - "isExtraImport": true, - "detail": "discord", - "documentation": {} - }, - { - "label": "commands", - "importPath": "discord.ext", - "description": "discord.ext", - "isExtraImport": true, - "detail": "discord.ext", - "documentation": {} - }, - { - "label": "commands", - "importPath": "discord.ext", - "description": "discord.ext", - "isExtraImport": true, - "detail": "discord.ext", - "documentation": {} - }, - { - "label": "commands", - "importPath": "discord.ext", - "description": "discord.ext", - "isExtraImport": true, - "detail": "discord.ext", - "documentation": {} - }, - { - "label": "List", - "importPath": "cpl_query.extension", - "description": "cpl_query.extension", - "isExtraImport": true, - "detail": "cpl_query.extension", - "documentation": {} - }, - { - "label": "List", - "importPath": "cpl_query.extension", - "description": "cpl_query.extension", - "isExtraImport": true, - "detail": "cpl_query.extension", - "documentation": {} - }, - { - "label": "List", - "importPath": "cpl_query.extension", - "description": "cpl_query.extension", - "isExtraImport": true, - "detail": "cpl_query.extension", - "documentation": {} - }, - { - "label": "List", - "importPath": "cpl_query.extension", - "description": "cpl_query.extension", - "isExtraImport": true, - "detail": "cpl_query.extension", - "documentation": {} - }, - { - "label": "Context", - "importPath": "discord.ext.commands", - "description": "discord.ext.commands", - "isExtraImport": true, - "detail": "discord.ext.commands", - "documentation": {} - }, - { - "label": "Context", - "importPath": "discord.ext.commands", - "description": "discord.ext.commands", - "isExtraImport": true, - "detail": "discord.ext.commands", - "documentation": {} - }, - { - "label": "traceback", - "kind": 6, - "isExtraImport": true, - "importPath": "traceback", - "description": "traceback", - "detail": "traceback", - "documentation": {} - }, - { - "label": "ServerSettings", - "importPath": "gismo_core.configuration.server_settings", - "description": "gismo_core.configuration.server_settings", - "isExtraImport": true, - "detail": "gismo_core.configuration.server_settings", - "documentation": {} - }, - { - "label": "ServerSettings", - "importPath": "gismo_core.configuration.server_settings", - "description": "gismo_core.configuration.server_settings", - "isExtraImport": true, - "detail": "gismo_core.configuration.server_settings", - "documentation": {} - }, - { - "label": "ServerSettings", - "importPath": "gismo_core.configuration.server_settings", - "description": "gismo_core.configuration.server_settings", - "isExtraImport": true, - "detail": "gismo_core.configuration.server_settings", - "documentation": {} - }, - { - "label": "ServerSettings", - "importPath": "gismo_core.configuration.server_settings", - "description": "gismo_core.configuration.server_settings", - "isExtraImport": true, - "detail": "gismo_core.configuration.server_settings", - "documentation": {} - }, - { - "label": "ConfigurationModelABC", - "importPath": "cpl_core.configuration.configuration_model_abc", - "description": "cpl_core.configuration.configuration_model_abc", - "isExtraImport": true, - "detail": "cpl_core.configuration.configuration_model_abc", - "documentation": {} - }, - { - "label": "BotSettings", - "importPath": "gismo_core.configuration.bot_settings", - "description": "gismo_core.configuration.bot_settings", - "isExtraImport": true, - "detail": "gismo_core.configuration.bot_settings", - "documentation": {} - }, - { - "label": "DiscordSettings", - "importPath": "gismo_core.configuration.discord_settings", - "description": "gismo_core.configuration.discord_settings", - "isExtraImport": true, - "detail": "gismo_core.configuration.discord_settings", - "documentation": {} - }, - { - "label": "ConfigurationABC", - "importPath": "cpl_core.configuration.configuration_abc", - "description": "cpl_core.configuration.configuration_abc", - "isExtraImport": true, - "detail": "cpl_core.configuration.configuration_abc", - "documentation": {} - }, - { - "label": "asyncio", - "importPath": "async_timeout", - "description": "async_timeout", - "isExtraImport": true, - "detail": "async_timeout", - "documentation": {} - }, - { - "label": "asyncio", - "importPath": "async_timeout", - "description": "async_timeout", - "isExtraImport": true, - "detail": "async_timeout", - "documentation": {} - }, - { - "label": "OnReadyABC", - "importPath": "modules_core.abc.on_ready_abc", - "description": "modules_core.abc.on_ready_abc", - "isExtraImport": true, - "detail": "modules_core.abc.on_ready_abc", - "documentation": {} - }, - { - "label": "OnReadyABC", - "importPath": "modules_core.abc.on_ready_abc", - "description": "modules_core.abc.on_ready_abc", - "isExtraImport": true, - "detail": "modules_core.abc.on_ready_abc", - "documentation": {} - }, - { - "label": "ApplicationExtensionABC", - "importPath": "cpl_core.application.application_extension_abc", - "description": "cpl_core.application.application_extension_abc", - "isExtraImport": true, - "detail": "cpl_core.application.application_extension_abc", - "documentation": {} - }, - { - "label": "OnMessageABC", - "importPath": "modules_core.abc.on_message_abc", - "description": "modules_core.abc.on_message_abc", - "isExtraImport": true, - "detail": "modules_core.abc.on_message_abc", - "documentation": {} - }, - { - "label": "Enum", - "importPath": "enum", - "description": "enum", - "isExtraImport": true, - "detail": "enum", - "documentation": {} - }, - { - "label": "json", - "kind": 6, - "isExtraImport": true, - "importPath": "json", - "description": "json", - "detail": "json", - "documentation": {} - }, - { - "label": "Application", - "importPath": "level_generator.application", - "description": "level_generator.application", - "isExtraImport": true, - "detail": "level_generator.application", - "documentation": {} - }, - { - "label": "Startup", - "importPath": "level_generator.startup", - "description": "level_generator.startup", - "isExtraImport": true, - "detail": "level_generator.startup", - "documentation": {} - }, - { - "label": "Application", - "importPath": "ontime_calculator.application", - "description": "ontime_calculator.application", - "isExtraImport": true, - "detail": "ontime_calculator.application", - "documentation": {} - }, - { - "label": "Startup", - "importPath": "ontime_calculator.startup", - "description": "ontime_calculator.startup", - "isExtraImport": true, - "detail": "ontime_calculator.startup", - "documentation": {} - }, - { - "label": "Application", - "kind": 6, - "importPath": "dist.gismo.build.gismo.application", - "description": "dist.gismo.build.gismo.application", - "peekOfCode": "class Application(ApplicationABC):\n def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):\n ApplicationABC.__init__(self, config, services)\n async def configure(self):\n pass\n async def main(self):\n Console.write_line('Hello World')", - "detail": "dist.gismo.build.gismo.application", - "documentation": {} - }, - { - "label": "Startup", - "kind": 6, - "importPath": "dist.gismo.build.gismo.startup", - "description": "dist.gismo.build.gismo.startup", - "peekOfCode": "class Startup(StartupABC):\n def __init__(self):\n StartupABC.__init__(self)\n async def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:\n return configuration\n async def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:\n return services.build_service_provider()", - "detail": "dist.gismo.build.gismo.startup", - "documentation": {} - }, - { - "label": "configure_configuration", - "kind": 2, - "importPath": "dist.gismo.build.modules.boot_log.main", - "description": "dist.gismo.build.modules.boot_log.main", - "peekOfCode": "def configure_configuration() -> ConfigurationABC:\n config = Configuration()\n return config\ndef configure_services(config: ConfigurationABC) -> ServiceProviderABC:\n services = ServiceCollection(config)\n return services.build_service_provider()\ndef main():\n config = configure_configuration()\n provider = configure_services(config)\n Console.write_line('Hello World')", - "detail": "dist.gismo.build.modules.boot_log.main", - "documentation": {} - }, - { - "label": "configure_services", - "kind": 2, - "importPath": "dist.gismo.build.modules.boot_log.main", - "description": "dist.gismo.build.modules.boot_log.main", - "peekOfCode": "def configure_services(config: ConfigurationABC) -> ServiceProviderABC:\n services = ServiceCollection(config)\n return services.build_service_provider()\ndef main():\n config = configure_configuration()\n provider = configure_services(config)\n Console.write_line('Hello World')\nif __name__ == '__main__':\n main()", - "detail": "dist.gismo.build.modules.boot_log.main", - "documentation": {} - }, - { - "label": "main", - "kind": 2, - "importPath": "dist.gismo.build.modules.boot_log.main", - "description": "dist.gismo.build.modules.boot_log.main", - "peekOfCode": "def main():\n config = configure_configuration()\n provider = configure_services(config)\n Console.write_line('Hello World')\nif __name__ == '__main__':\n main()", - "detail": "dist.gismo.build.modules.boot_log.main", - "documentation": {} - }, - { - "label": "Application", - "kind": 6, - "importPath": "src.gismo.application", - "description": "src.gismo.application", - "peekOfCode": "class Application(ApplicationABC):\n def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):\n ApplicationABC.__init__(self, config, services)\n self._bot: BotService = services.get_service(BotServiceABC)\n self._logger: LoggerABC = services.get_service(LoggerABC)\n async def configure(self):\n pass\n async def main(self):\n try:\n self._logger.trace(__name__, f'Try to start {BotService}')", - "detail": "src.gismo.application", - "documentation": {} - }, - { - "label": "Main", - "kind": 6, - "importPath": "src.gismo.main", - "description": "src.gismo.main", - "peekOfCode": "class Main:\n def __init__(self):\n self._app: Optional[ApplicationABC] = None\n async def main(self):\n app_builder = ApplicationBuilder(Application)\n app_builder.use_extension(BootLogExtension)\n app_builder.use_startup(Startup)\n self._app: ApplicationABC = await app_builder.build_async()\n await self._app.run_async()\n async def stop(self):", - "detail": "src.gismo.main", - "documentation": {} - }, - { - "label": "Startup", - "kind": 6, - "importPath": "src.gismo.startup", - "description": "src.gismo.startup", - "peekOfCode": "class Startup(StartupABC):\n def __init__(self):\n StartupABC.__init__(self)\n self._start_time = datetime.now()\n self._config: Optional[ConfigurationABC] = None\n async def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:\n configuration.add_environment_variables('GISMO_')\n configuration.add_json_file(f'appsettings.json', optional=False)\n configuration.add_json_file(f'appsettings.{environment.environment_name}.json', optional=True)\n configuration.add_json_file(f'appsettings.{environment.host_name}.json', optional=True)", - "detail": "src.gismo.startup", - "documentation": {} - }, - { - "label": "Application", - "kind": 6, - "importPath": "src.gismo_cli.application", - "description": "src.gismo_cli.application", - "peekOfCode": "class Application(ApplicationABC):\n def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):\n ApplicationABC.__init__(self, config, services)\n async def configure(self):\n pass\n async def main(self):\n Console.write_line('Hello World')", - "detail": "src.gismo_cli.application", - "documentation": {} - }, - { - "label": "Startup", - "kind": 6, - "importPath": "src.gismo_cli.startup", - "description": "src.gismo_cli.startup", - "peekOfCode": "class Startup(StartupABC):\n def __init__(self):\n StartupABC.__init__(self)\n async def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:\n return configuration\n async def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:\n return services.build_service_provider()", - "detail": "src.gismo_cli.startup", - "documentation": {} - }, - { - "label": "BotServiceABC", - "kind": 6, - "importPath": "src.gismo_core.abc.bot_service_abc", - "description": "src.gismo_core.abc.bot_service_abc", - "peekOfCode": "class BotServiceABC(ABC, commands.Bot):\n @abstractmethod\n def __init__(self): pass\n @abstractmethod\n async def start_async(self): pass\n @abstractmethod\n async def stop_async(self): pass\n @abstractmethod\n async def on_message(self, message: discord.Message): pass", - "detail": "src.gismo_core.abc.bot_service_abc", - "documentation": {} - }, - { - "label": "MessageServiceABC", - "kind": 6, - "importPath": "src.gismo_core.abc.message_service_abc", - "description": "src.gismo_core.abc.message_service_abc", - "peekOfCode": "class MessageServiceABC(ABC):\n @abstractmethod\n def __init__(self): pass\n @abstractmethod\n async def delete_messages(self, messages: List[discord.Message]): pass\n @abstractmethod\n async def delete_message(self, message: discord.Message): pass\n @abstractmethod\n async def send_channel_message(self, channel: discord.TextChannel, message: str): pass\n @abstractmethod", - "detail": "src.gismo_core.abc.message_service_abc", - "documentation": {} - }, - { - "label": "BotSettings", - "kind": 6, - "importPath": "src.gismo_core.configuration.bot_settings", - "description": "src.gismo_core.configuration.bot_settings", - "peekOfCode": "class BotSettings(ConfigurationModelABC):\n def __init__(self):\n ConfigurationModelABC.__init__(self)\n self._prefix: str = ''\n self._servers: List[ServerSettings] = List()\n @property\n def prefix(self) -> str:\n return self._prefix\n @property\n def servers(self) -> List[ServerSettings]:", - "detail": "src.gismo_core.configuration.bot_settings", - "documentation": {} - }, - { - "label": "DiscordSettings", - "kind": 6, - "importPath": "src.gismo_core.configuration.discord_settings", - "description": "src.gismo_core.configuration.discord_settings", - "peekOfCode": "class DiscordSettings(ConfigurationModelABC):\n def __init__(self):\n ConfigurationModelABC.__init__(self)\n self._token: str = ''\n @property\n def token(self) -> str:\n return self._token\n def from_dict(self, settings: dict):\n try:\n self._token = settings['Token']", - "detail": "src.gismo_core.configuration.discord_settings", - "documentation": {} - }, - { - "label": "ServerSettings", - "kind": 6, - "importPath": "src.gismo_core.configuration.server_settings", - "description": "src.gismo_core.configuration.server_settings", - "peekOfCode": "class ServerSettings(ConfigurationModelABC):\n def __init__(self):\n ConfigurationModelABC.__init__(self)\n self._id: int = 0\n self._message_delete_timer: int = 0\n self._login_message_channel_id: int = 0\n self._login_message: str = ''\n @property\n def id(self) -> str:\n return self._id", - "detail": "src.gismo_core.configuration.server_settings", - "documentation": {} - }, - { - "label": "BotService", - "kind": 6, - "importPath": "src.gismo_core.service.bot_service", - "description": "src.gismo_core.service.bot_service", - "peekOfCode": "class BotService(BotServiceABC, commands.Bot):\n def __init__(self, config: ConfigurationABC, logger: LoggerABC, modules: ModuleServiceABC, discord_settings: DiscordSettings, bot_settings: BotSettings):\n # services\n self._config = config\n self._logger = logger\n self._modules = modules\n # settings\n self._discord_settings = discord_settings\n self._bot_settings: BotSettings = bot_settings\n # setup super", - "detail": "src.gismo_core.service.bot_service", - "documentation": {} - }, - { - "label": "MessageService", - "kind": 6, - "importPath": "src.gismo_core.service.message_service", - "description": "src.gismo_core.service.message_service", - "peekOfCode": "class MessageService(MessageServiceABC):\n def __init__(self, config: ConfigurationABC, logger: LoggerABC, bot: BotServiceABC):\n self._config = config\n self._logger = logger\n self._bot = bot\n async def delete_messages(self, messages: List[discord.Message]): \n self._logger.debug(__name__, f'Try to delete {messages.count()} messages')\n for message in messages:\n await self.delete_message(message)\n self._logger.debug(__name__, 'Deleting messages finished')", - "detail": "src.gismo_core.service.message_service", - "documentation": {} - }, - { - "label": "BootLog", - "kind": 6, - "importPath": "src.modules.boot_log.boot_log", - "description": "src.modules.boot_log.boot_log", - "peekOfCode": "class BootLog(ModuleABC, OnReadyABC):\n def __init__(\n self,\n config: ConfigurationABC,\n logging_st: LoggingSettings,\n logger: LoggerABC,\n bot: BotServiceABC,\n message_service: MessageServiceABC\n ):\n self._config = config", - "detail": "src.modules.boot_log.boot_log", - "documentation": {} - }, - { - "label": "BootLogExtension", - "kind": 6, - "importPath": "src.modules.boot_log.boot_log_extension", - "description": "src.modules.boot_log.boot_log_extension", - "peekOfCode": "class BootLogExtension(ApplicationExtensionABC):\n def __init__(self):\n pass\n async def run(self, config: ConfigurationABC, services: ServiceProviderABC):\n logger: LoggerABC = services.get_service(LoggerABC)\n logger.debug(__name__, 'BootLog extension started')\n config.add_configuration('Bot_StartTime', datetime.now())", - "detail": "src.modules.boot_log.boot_log_extension", - "documentation": {} - }, - { - "label": "ModuleABC", - "kind": 6, - "importPath": "src.modules_core.abc.module_abc", - "description": "src.modules_core.abc.module_abc", - "peekOfCode": "class ModuleABC(ABC):\n @abstractmethod\n def __init__(self): pass", - "detail": "src.modules_core.abc.module_abc", - "documentation": {} - }, - { - "label": "ModuleServiceABC", - "kind": 6, - "importPath": "src.modules_core.abc.module_service_abc", - "description": "src.modules_core.abc.module_service_abc", - "peekOfCode": "class ModuleServiceABC(ABC):\n @abstractmethod\n def __init__(self): pass\n @abstractmethod\n async def on_ready(self): pass\n @abstractmethod\n async def on_message(self, message: discord.Message): pass", - "detail": "src.modules_core.abc.module_service_abc", - "documentation": {} - }, - { - "label": "OnMessageABC", - "kind": 6, - "importPath": "src.modules_core.abc.on_message_abc", - "description": "src.modules_core.abc.on_message_abc", - "peekOfCode": "class OnMessageABC(ABC):\n @abstractmethod\n def __init__(self): pass\n @abstractmethod\n async def on_message(self, message: discord.Message): pass", - "detail": "src.modules_core.abc.on_message_abc", - "documentation": {} - }, - { - "label": "OnReadyABC", - "kind": 6, - "importPath": "src.modules_core.abc.on_ready_abc", - "description": "src.modules_core.abc.on_ready_abc", - "peekOfCode": "class OnReadyABC(ABC):\n @abstractmethod\n def __init__(self): pass\n @abstractmethod\n async def on_ready(self): pass", - "detail": "src.modules_core.abc.on_ready_abc", - "documentation": {} - }, - { - "label": "ModuleService", - "kind": 6, - "importPath": "src.modules_core.service.module_service", - "description": "src.modules_core.service.module_service", - "peekOfCode": "class ModuleService(ModuleServiceABC):\n def __init__(self, logger: LoggerABC, services: ServiceProviderABC, env: ApplicationEnvironmentABC):\n self._logger = logger\n self._services = services\n self._env = env\n self._modules: List[ModuleABC] = List()\n self._modules.extend(ModuleABC.__subclasses__())\n async def on_ready(self):\n self._logger.debug(__name__, 'Start on_ready modules')\n modules = self._modules.where(lambda m: issubclass(m, OnReadyABC))", - "detail": "src.modules_core.service.module_service", - "documentation": {} - }, - { - "label": "EventsEnum", - "kind": 6, - "importPath": "src.modules_core.events_enum", - "description": "src.modules_core.events_enum", - "peekOfCode": "class EventsEnum(Enum):\n on_ready = 'on_ready'", - "detail": "src.modules_core.events_enum", - "documentation": {} - }, - { - "label": "Application", - "kind": 6, - "importPath": "tools.level_generator.application", - "description": "tools.level_generator.application", - "peekOfCode": "class Application(ApplicationABC):\n def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):\n ApplicationABC.__init__(self, config, services)\n def configure(self):\n pass\n def main(self):\n f = open(\"./Levels.txt\", \"r\", encoding='utf-8')\n i = 0\n lines = f.readlines()\n json_list = []", - "detail": "tools.level_generator.application", - "documentation": {} - }, - { - "label": "main", - "kind": 2, - "importPath": "tools.level_generator.main", - "description": "tools.level_generator.main", - "peekOfCode": "def main():\n app_builder = ApplicationBuilder(Application)\n app_builder.use_startup(Startup)\n app_builder.build().run()\nif __name__ == '__main__':\n main()", - "detail": "tools.level_generator.main", - "documentation": {} - }, - { - "label": "Startup", - "kind": 6, - "importPath": "tools.level_generator.startup", - "description": "tools.level_generator.startup", - "peekOfCode": "class Startup(StartupABC):\n def __init__(self):\n StartupABC.__init__(self)\n def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:\n return configuration\n def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:\n return services.build_service_provider()", - "detail": "tools.level_generator.startup", - "documentation": {} - }, - { - "label": "Application", - "kind": 6, - "importPath": "tools.ontime_calculator.application", - "description": "tools.ontime_calculator.application", - "peekOfCode": "class Application(ApplicationABC):\n def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):\n ApplicationABC.__init__(self, config, services)\n def configure(self):\n pass\n def main(self):\n ontime = 0\n mc = 0\n for i in range(0, 31):\n Console.write_line(f'i: {i} {ontime} {mc}')", - "detail": "tools.ontime_calculator.application", - "documentation": {} - }, - { - "label": "main", - "kind": 2, - "importPath": "tools.ontime_calculator.main", - "description": "tools.ontime_calculator.main", - "peekOfCode": "def main():\n app_builder = ApplicationBuilder(Application)\n app_builder.use_startup(Startup)\n app_builder.build().run()\nif __name__ == '__main__':\n main()", - "detail": "tools.ontime_calculator.main", - "documentation": {} - }, - { - "label": "Startup", - "kind": 6, - "importPath": "tools.ontime_calculator.startup", - "description": "tools.ontime_calculator.startup", - "peekOfCode": "class Startup(StartupABC):\n def __init__(self):\n StartupABC.__init__(self)\n def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:\n return configuration\n def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:\n return services.build_service_provider()", - "detail": "tools.ontime_calculator.startup", - "documentation": {} - } -] \ No newline at end of file diff --git a/src/modules_core/abc/module_service_abc.py b/src/modules_core/abc/module_service_abc.py index 51bc8a0..50432e2 100644 --- a/src/modules_core/abc/module_service_abc.py +++ b/src/modules_core/abc/module_service_abc.py @@ -1,4 +1,6 @@ from abc import ABC, abstractmethod +from datetime import datetime +from typing import Optional, Sequence, Union import discord @@ -7,9 +9,144 @@ class ModuleServiceABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_connect(self): pass + + @abstractmethod + async def on_disconnect(self): pass @abstractmethod async def on_ready(self): pass + @abstractmethod + async def on_resume(self): pass + + @abstractmethod + async def on_error(self, event: str, *args, **kwargs): pass + + @abstractmethod + async def on_typing(self, channel: discord.abc.Messageable, user: Union[discord.User, discord.Member], when: datetime): pass + @abstractmethod async def on_message(self, message: discord.Message): pass + + @abstractmethod + async def on_message_delete(self, message: discord.Message): pass + + @abstractmethod + async def on_bulk_message_delete(self, message: discord.Message): pass + + @abstractmethod + async def on_message_edit(self, before: discord.Message, after: discord.Message): pass + + @abstractmethod + async def on_reaction_add(self, reaction: discord.Reaction, user: discord.User): pass + + @abstractmethod + async def on_reaction_remove(self, reaction: discord.Reaction, user: discord.User): pass + + @abstractmethod + async def on_reaction_clear(self, message: discord.Message, reactions: list[discord.Reaction]): pass + + @abstractmethod + async def on_reaction_clear_emoji(self, reaction: discord.Reaction): pass + + @abstractmethod + async def on_private_channel_delete(self, channel: discord.abc.PrivateChannel): pass + + @abstractmethod + async def on_private_channel_create(self, channel: discord.abc.PrivateChannel): pass + + @abstractmethod + async def on_private_channel_update(self, before: discord.GroupChannel, after: discord.GroupChannel): pass + + @abstractmethod + async def on_private_channel_pins_update(self, channel: discord.abc.PrivateChannel, list_pin: Optional[datetime]): pass + + @abstractmethod + async def on_guild_channel_delete(self, channel: discord.abc.GuildChannel): pass + + @abstractmethod + async def on_guild_channel_create(self, channel: discord.abc.GuildChannel): pass + + @abstractmethod + async def on_guild_channel_update(self, before: discord.abc.GuildChannel, after: discord.abc.GuildChannel): pass + + @abstractmethod + async def on_guild_channel_pins_update(self, channel: discord.abc.GuildChannel, list_pin: Optional[datetime]): pass + + @abstractmethod + async def on_guild_integrations_update(self, guild: discord.Guild): pass + + @abstractmethod + async def on_webhooks_update(self, channel: discord.abc.GuildChannel): pass + + @abstractmethod + async def on_member_join(self, member: discord.Member): pass + + @abstractmethod + async def on_member_remove(self, member: discord.Member): pass + + @abstractmethod + async def on_member_update(self, before: discord.Member, after: discord.Member): pass + + @abstractmethod + async def on_user_update(self, before: discord.User, after: discord.User): pass + + @abstractmethod + async def on_guild_join(self, guild: discord.Guild): pass + + @abstractmethod + async def on_guild_remove(self, guild: discord.Guild): pass + + @abstractmethod + async def on_guild_update(self, before: discord.Guild, after: discord.Guild): pass + + @abstractmethod + async def on_guild_role_create(self, role: discord.Role): pass + + @abstractmethod + async def on_guild_role_delete(self, role: discord.Role): pass + + @abstractmethod + async def on_guild_role_update(self, before: discord.Role, after: discord.Role): pass + + @abstractmethod + async def on_guild_emojis_update(self, guild: discord.Guild, before: Sequence[discord.Emoji], after: Sequence[discord.Emoji]): pass + + @abstractmethod + async def on_guild_available(self, guild: discord.Guild): pass + + @abstractmethod + async def on_guild_unavailable(self, guild: discord.Guild): pass + + @abstractmethod + async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState,after: discord.VoiceState): pass + + @abstractmethod + async def on_member_ban(self, guild: discord.Guild, user: discord.User): pass + + @abstractmethod + async def on_member_unban(self, guild: discord.Guild, user: discord.User): pass + + @abstractmethod + async def on_invite_create(self, invite: discord.Invite): pass + + @abstractmethod + async def on_invite_delete(self, invite: discord.Invite): pass + + @abstractmethod + async def on_group_join(self, chhanel: discord.GroupChannel, user: discord.User): pass + + @abstractmethod + async def on_group_remove(self, chhanel: discord.GroupChannel, user: discord.User): pass + + @abstractmethod + async def on_relationship_add(self, relationship: discord.Relationship): pass + + @abstractmethod + async def on_relationship_remove(self, relationship: discord.Relationship): pass + + @abstractmethod + async def on_relationship_update(self, before: discord.Relationship, after: discord.Relationship): pass diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index 6e41724..e297f66 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -34,7 +34,6 @@ class ModuleService(ModuleServiceABC): async def on_message(self, message: discord.Message): self._logger.debug(__name__, 'Start on_message modules') modules = self._modules.where(lambda m: issubclass(m, OnMessageABC)) - for module_type in modules: module_type = module_type module: OnMessageABC = self._services.get_service(module_type) -- 2.45.2 From 5cbd40ec03e6b6259c655fe09b1ab89ed551488c Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 18 Nov 2021 08:51:15 +0100 Subject: [PATCH 037/113] Moved event abc & added event function (without content) to ModuleService --- src/modules/boot_log/boot_log.py | 2 +- .../abc/{ => events}/on_message_abc.py | 0 .../abc/{ => events}/on_ready_abc.py | 0 src/modules_core/service/module_service.py | 127 +++++++++++++++++- 4 files changed, 122 insertions(+), 7 deletions(-) rename src/modules_core/abc/{ => events}/on_message_abc.py (100%) rename src/modules_core/abc/{ => events}/on_ready_abc.py (100%) diff --git a/src/modules/boot_log/boot_log.py b/src/modules/boot_log/boot_log.py index df54145..e703255 100644 --- a/src/modules/boot_log/boot_log.py +++ b/src/modules/boot_log/boot_log.py @@ -10,7 +10,7 @@ from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.abc.message_service_abc import MessageServiceABC from gismo_core.configuration.server_settings import ServerSettings from modules_core.abc.module_abc import ModuleABC -from modules_core.abc.on_ready_abc import OnReadyABC +from modules_core.abc.events.on_ready_abc import OnReadyABC class BootLog(ModuleABC, OnReadyABC): diff --git a/src/modules_core/abc/on_message_abc.py b/src/modules_core/abc/events/on_message_abc.py similarity index 100% rename from src/modules_core/abc/on_message_abc.py rename to src/modules_core/abc/events/on_message_abc.py diff --git a/src/modules_core/abc/on_ready_abc.py b/src/modules_core/abc/events/on_ready_abc.py similarity index 100% rename from src/modules_core/abc/on_ready_abc.py rename to src/modules_core/abc/events/on_ready_abc.py diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index e297f66..abb1f76 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -1,4 +1,5 @@ -from async_timeout import asyncio +from datetime import datetime +from typing import Optional, Sequence, Union import discord from discord.ext import commands @@ -8,8 +9,8 @@ from cpl_core.logging import LoggerABC from cpl_query.extension import List from modules_core.abc.module_abc import ModuleABC from modules_core.abc.module_service_abc import ModuleServiceABC -from modules_core.abc.on_message_abc import OnMessageABC -from modules_core.abc.on_ready_abc import OnReadyABC +from modules_core.abc.events.on_message_abc import OnMessageABC +from modules_core.abc.events.on_ready_abc import OnReadyABC class ModuleService(ModuleServiceABC): @@ -21,6 +22,10 @@ class ModuleService(ModuleServiceABC): self._modules: List[ModuleABC] = List() self._modules.extend(ModuleABC.__subclasses__()) + async def on_connect(self): pass + + async def on_disconnect(self): pass + async def on_ready(self): self._logger.debug(__name__, 'Start on_ready modules') modules = self._modules.where(lambda m: issubclass(m, OnReadyABC)) @@ -28,9 +33,15 @@ class ModuleService(ModuleServiceABC): module_type = module_type module: OnReadyABC = self._services.get_service(module_type) await module.on_ready() - self._logger.debug(__name__, 'Stopped on_ready modules') + async def on_resume(self): pass + + async def on_error(self, event: str, *args, **kwargs): pass + + async def on_typing(self, channel: discord.abc.Messageable, + user: Union[discord.User, discord.Member], when: datetime): pass + async def on_message(self, message: discord.Message): self._logger.debug(__name__, 'Start on_message modules') modules = self._modules.where(lambda m: issubclass(m, OnMessageABC)) @@ -38,5 +49,109 @@ class ModuleService(ModuleServiceABC): module_type = module_type module: OnMessageABC = self._services.get_service(module_type) await module.on_message(message) - - self._logger.debug(__name__, f'Stopped on_message modules') \ No newline at end of file + self._logger.debug(__name__, f'Stopped on_message modules') + + async def on_message_delete(self, message: discord.Message): pass + + async def on_bulk_message_delete(self, message: discord.Message): pass + + async def on_message_edit( + self, before: discord.Message, after: discord.Message): pass + + async def on_reaction_add( + self, reaction: discord.Reaction, user: discord.User): pass + + async def on_reaction_remove( + self, reaction: discord.Reaction, user: discord.User): pass + + async def on_reaction_clear( + self, message: discord.Message, reactions: list[discord.Reaction]): pass + + async def on_reaction_clear_emoji(self, reaction: discord.Reaction): pass + + async def on_private_channel_delete( + self, channel: discord.abc.PrivateChannel): pass + + async def on_private_channel_create( + self, channel: discord.abc.PrivateChannel): pass + + async def on_private_channel_update( + self, before: discord.GroupChannel, after: discord.GroupChannel): pass + + async def on_private_channel_pins_update( + self, channel: discord.abc.PrivateChannel, list_pin: Optional[datetime]): pass + + async def on_guild_channel_delete( + self, channel: discord.abc.GuildChannel): pass + + async def on_guild_channel_create( + self, channel: discord.abc.GuildChannel): pass + + async def on_guild_channel_update( + self, before: discord.abc.GuildChannel, after: discord.abc.GuildChannel): pass + + async def on_guild_channel_pins_update( + self, channel: discord.abc.GuildChannel, list_pin: Optional[datetime]): pass + + async def on_guild_integrations_update(self, guild: discord.Guild): pass + + async def on_webhooks_update(self, channel: discord.abc.GuildChannel): pass + + async def on_member_join(self, member: discord.Member): pass + + async def on_member_remove(self, member: discord.Member): pass + + async def on_member_update( + self, before: discord.Member, after: discord.Member): pass + + async def on_user_update(self, before: discord.User, + after: discord.User): pass + + async def on_guild_join(self, guild: discord.Guild): pass + + async def on_guild_remove(self, guild: discord.Guild): pass + + async def on_guild_update( + self, before: discord.Guild, after: discord.Guild): pass + + async def on_guild_role_create(self, role: discord.Role): pass + + async def on_guild_role_delete(self, role: discord.Role): pass + + async def on_guild_role_update( + self, before: discord.Role, after: discord.Role): pass + + async def on_guild_emojis_update( + self, guild: discord.Guild, before: Sequence[discord.Emoji], after: Sequence[discord.Emoji]): pass + + async def on_guild_available(self, guild: discord.Guild): pass + + async def on_guild_unavailable(self, guild: discord.Guild): pass + + async def on_voice_state_update( + self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState): pass + + async def on_member_ban(self, guild: discord.Guild, + user: discord.User): pass + + async def on_member_unban( + self, guild: discord.Guild, user: discord.User): pass + + async def on_invite_create(self, invite: discord.Invite): pass + + async def on_invite_delete(self, invite: discord.Invite): pass + + async def on_group_join( + self, chhanel: discord.GroupChannel, user: discord.User): pass + + async def on_group_remove( + self, chhanel: discord.GroupChannel, user: discord.User): pass + + async def on_relationship_add( + self, relationship: discord.Relationship): pass + + async def on_relationship_remove( + self, relationship: discord.Relationship): pass + + async def on_relationship_update( + self, before: discord.Relationship, after: discord.Relationship): pass -- 2.45.2 From cb8c090ab3f7c9a62990055d9b7a8bfef913fc91 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 18 Nov 2021 09:05:10 +0100 Subject: [PATCH 038/113] Added event abc files --- src/modules_core/abc/events/on_bulk_message_delete_abc.py | 7 +++++++ src/modules_core/abc/events/on_connect_abc.py | 7 +++++++ src/modules_core/abc/events/on_disconnect_abc.py | 7 +++++++ src/modules_core/abc/events/on_error_abc.py | 7 +++++++ src/modules_core/abc/events/on_group_join_abc.py | 7 +++++++ src/modules_core/abc/events/on_group_remove_abc.py | 7 +++++++ src/modules_core/abc/events/on_guild_available_abc.py | 7 +++++++ src/modules_core/abc/events/on_guild_channel_create_abc.py | 7 +++++++ src/modules_core/abc/events/on_guild_channel_delete_abc.py | 7 +++++++ .../abc/events/on_guild_channel_pins_update_abc.py | 7 +++++++ src/modules_core/abc/events/on_guild_channel_update_abc.py | 7 +++++++ .../abc/events/on_guild_integrations_update_abc.py | 7 +++++++ src/modules_core/abc/events/on_guild_join_abc.py | 7 +++++++ src/modules_core/abc/events/on_guild_remove_abc.py | 7 +++++++ src/modules_core/abc/events/on_guild_role_create_abc.py | 7 +++++++ src/modules_core/abc/events/on_guild_role_delete_abc.py | 7 +++++++ src/modules_core/abc/events/on_guild_role_update_abc.py | 7 +++++++ src/modules_core/abc/events/on_guild_unavailable_abc.py | 7 +++++++ src/modules_core/abc/events/on_guild_update_abc.py | 7 +++++++ src/modules_core/abc/events/on_guildemojis_update_abc.py | 7 +++++++ src/modules_core/abc/events/on_invite_create_abc.py | 7 +++++++ src/modules_core/abc/events/on_invite_delete_abc.py | 7 +++++++ src/modules_core/abc/events/on_member_ban_abc.py | 7 +++++++ src/modules_core/abc/events/on_member_join_abc.py | 7 +++++++ src/modules_core/abc/events/on_member_remove_abc.py | 7 +++++++ src/modules_core/abc/events/on_member_unban_abc.py | 7 +++++++ src/modules_core/abc/events/on_member_update_abc.py | 7 +++++++ src/modules_core/abc/events/on_message_delete_abc.py | 7 +++++++ src/modules_core/abc/events/on_message_edit_abc.py | 7 +++++++ .../abc/events/on_private_channel_create_abc.py | 7 +++++++ .../abc/events/on_private_channel_delete_abc.py | 7 +++++++ .../abc/events/on_private_channel_pins_update_abc.py | 7 +++++++ .../abc/events/on_private_channel_update_abc.py | 7 +++++++ src/modules_core/abc/events/on_reaction_add_abc.py | 7 +++++++ src/modules_core/abc/events/on_reaction_clear_abc.py | 7 +++++++ src/modules_core/abc/events/on_reaction_clear_emoji_abc.py | 7 +++++++ src/modules_core/abc/events/on_reaction_remove_abc.py | 7 +++++++ src/modules_core/abc/events/on_relationship_add_abc.py | 7 +++++++ src/modules_core/abc/events/on_relationship_remove_abc.py | 7 +++++++ src/modules_core/abc/events/on_relationship_update_abc.py | 7 +++++++ src/modules_core/abc/events/on_resume_abc.py | 7 +++++++ src/modules_core/abc/events/on_typing_abc.py | 7 +++++++ src/modules_core/abc/events/on_user_update_abc.py | 7 +++++++ src/modules_core/abc/events/onvoice_state_update_abc.py | 7 +++++++ src/modules_core/abc/events/onwebhooks_update_abc.py | 7 +++++++ 45 files changed, 315 insertions(+) create mode 100644 src/modules_core/abc/events/on_bulk_message_delete_abc.py create mode 100644 src/modules_core/abc/events/on_connect_abc.py create mode 100644 src/modules_core/abc/events/on_disconnect_abc.py create mode 100644 src/modules_core/abc/events/on_error_abc.py create mode 100644 src/modules_core/abc/events/on_group_join_abc.py create mode 100644 src/modules_core/abc/events/on_group_remove_abc.py create mode 100644 src/modules_core/abc/events/on_guild_available_abc.py create mode 100644 src/modules_core/abc/events/on_guild_channel_create_abc.py create mode 100644 src/modules_core/abc/events/on_guild_channel_delete_abc.py create mode 100644 src/modules_core/abc/events/on_guild_channel_pins_update_abc.py create mode 100644 src/modules_core/abc/events/on_guild_channel_update_abc.py create mode 100644 src/modules_core/abc/events/on_guild_integrations_update_abc.py create mode 100644 src/modules_core/abc/events/on_guild_join_abc.py create mode 100644 src/modules_core/abc/events/on_guild_remove_abc.py create mode 100644 src/modules_core/abc/events/on_guild_role_create_abc.py create mode 100644 src/modules_core/abc/events/on_guild_role_delete_abc.py create mode 100644 src/modules_core/abc/events/on_guild_role_update_abc.py create mode 100644 src/modules_core/abc/events/on_guild_unavailable_abc.py create mode 100644 src/modules_core/abc/events/on_guild_update_abc.py create mode 100644 src/modules_core/abc/events/on_guildemojis_update_abc.py create mode 100644 src/modules_core/abc/events/on_invite_create_abc.py create mode 100644 src/modules_core/abc/events/on_invite_delete_abc.py create mode 100644 src/modules_core/abc/events/on_member_ban_abc.py create mode 100644 src/modules_core/abc/events/on_member_join_abc.py create mode 100644 src/modules_core/abc/events/on_member_remove_abc.py create mode 100644 src/modules_core/abc/events/on_member_unban_abc.py create mode 100644 src/modules_core/abc/events/on_member_update_abc.py create mode 100644 src/modules_core/abc/events/on_message_delete_abc.py create mode 100644 src/modules_core/abc/events/on_message_edit_abc.py create mode 100644 src/modules_core/abc/events/on_private_channel_create_abc.py create mode 100644 src/modules_core/abc/events/on_private_channel_delete_abc.py create mode 100644 src/modules_core/abc/events/on_private_channel_pins_update_abc.py create mode 100644 src/modules_core/abc/events/on_private_channel_update_abc.py create mode 100644 src/modules_core/abc/events/on_reaction_add_abc.py create mode 100644 src/modules_core/abc/events/on_reaction_clear_abc.py create mode 100644 src/modules_core/abc/events/on_reaction_clear_emoji_abc.py create mode 100644 src/modules_core/abc/events/on_reaction_remove_abc.py create mode 100644 src/modules_core/abc/events/on_relationship_add_abc.py create mode 100644 src/modules_core/abc/events/on_relationship_remove_abc.py create mode 100644 src/modules_core/abc/events/on_relationship_update_abc.py create mode 100644 src/modules_core/abc/events/on_resume_abc.py create mode 100644 src/modules_core/abc/events/on_typing_abc.py create mode 100644 src/modules_core/abc/events/on_user_update_abc.py create mode 100644 src/modules_core/abc/events/onvoice_state_update_abc.py create mode 100644 src/modules_core/abc/events/onwebhooks_update_abc.py diff --git a/src/modules_core/abc/events/on_bulk_message_delete_abc.py b/src/modules_core/abc/events/on_bulk_message_delete_abc.py new file mode 100644 index 0000000..c9bbc75 --- /dev/null +++ b/src/modules_core/abc/events/on_bulk_message_delete_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnBulkMessageDeleteABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_connect_abc.py b/src/modules_core/abc/events/on_connect_abc.py new file mode 100644 index 0000000..0210c46 --- /dev/null +++ b/src/modules_core/abc/events/on_connect_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnConnectABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_disconnect_abc.py b/src/modules_core/abc/events/on_disconnect_abc.py new file mode 100644 index 0000000..00a1af9 --- /dev/null +++ b/src/modules_core/abc/events/on_disconnect_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnDisconnectABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_error_abc.py b/src/modules_core/abc/events/on_error_abc.py new file mode 100644 index 0000000..26350f4 --- /dev/null +++ b/src/modules_core/abc/events/on_error_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnErrorABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_group_join_abc.py b/src/modules_core/abc/events/on_group_join_abc.py new file mode 100644 index 0000000..0ab53db --- /dev/null +++ b/src/modules_core/abc/events/on_group_join_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnGroupJoinABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_group_remove_abc.py b/src/modules_core/abc/events/on_group_remove_abc.py new file mode 100644 index 0000000..b4dd22b --- /dev/null +++ b/src/modules_core/abc/events/on_group_remove_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnGroupRemoveABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_guild_available_abc.py b/src/modules_core/abc/events/on_guild_available_abc.py new file mode 100644 index 0000000..35ef0d8 --- /dev/null +++ b/src/modules_core/abc/events/on_guild_available_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnGuildAvailableABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_guild_channel_create_abc.py b/src/modules_core/abc/events/on_guild_channel_create_abc.py new file mode 100644 index 0000000..c04bef7 --- /dev/null +++ b/src/modules_core/abc/events/on_guild_channel_create_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnGuildChannelCreateABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_guild_channel_delete_abc.py b/src/modules_core/abc/events/on_guild_channel_delete_abc.py new file mode 100644 index 0000000..73dd145 --- /dev/null +++ b/src/modules_core/abc/events/on_guild_channel_delete_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnGuildChannelDeleteABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_guild_channel_pins_update_abc.py b/src/modules_core/abc/events/on_guild_channel_pins_update_abc.py new file mode 100644 index 0000000..4dcbcb3 --- /dev/null +++ b/src/modules_core/abc/events/on_guild_channel_pins_update_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnGuildChannelPinsUpdateABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_guild_channel_update_abc.py b/src/modules_core/abc/events/on_guild_channel_update_abc.py new file mode 100644 index 0000000..fb3be1a --- /dev/null +++ b/src/modules_core/abc/events/on_guild_channel_update_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnGuildChannelUpdateABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_guild_integrations_update_abc.py b/src/modules_core/abc/events/on_guild_integrations_update_abc.py new file mode 100644 index 0000000..b385d32 --- /dev/null +++ b/src/modules_core/abc/events/on_guild_integrations_update_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnGuildIntegrationsUpdateABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_guild_join_abc.py b/src/modules_core/abc/events/on_guild_join_abc.py new file mode 100644 index 0000000..b979ec5 --- /dev/null +++ b/src/modules_core/abc/events/on_guild_join_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnGuildJoinABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_guild_remove_abc.py b/src/modules_core/abc/events/on_guild_remove_abc.py new file mode 100644 index 0000000..770304e --- /dev/null +++ b/src/modules_core/abc/events/on_guild_remove_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnGuildRemoveABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_guild_role_create_abc.py b/src/modules_core/abc/events/on_guild_role_create_abc.py new file mode 100644 index 0000000..9a54e26 --- /dev/null +++ b/src/modules_core/abc/events/on_guild_role_create_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnGuildRoleCreateABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_guild_role_delete_abc.py b/src/modules_core/abc/events/on_guild_role_delete_abc.py new file mode 100644 index 0000000..844223b --- /dev/null +++ b/src/modules_core/abc/events/on_guild_role_delete_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnGuildRoleDeleteABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_guild_role_update_abc.py b/src/modules_core/abc/events/on_guild_role_update_abc.py new file mode 100644 index 0000000..d5678ac --- /dev/null +++ b/src/modules_core/abc/events/on_guild_role_update_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnGuildRoleUpdateABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_guild_unavailable_abc.py b/src/modules_core/abc/events/on_guild_unavailable_abc.py new file mode 100644 index 0000000..0064fdf --- /dev/null +++ b/src/modules_core/abc/events/on_guild_unavailable_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnGuildUnavailableABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_guild_update_abc.py b/src/modules_core/abc/events/on_guild_update_abc.py new file mode 100644 index 0000000..5071094 --- /dev/null +++ b/src/modules_core/abc/events/on_guild_update_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnGuildUpdateABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_guildemojis_update_abc.py b/src/modules_core/abc/events/on_guildemojis_update_abc.py new file mode 100644 index 0000000..f86d109 --- /dev/null +++ b/src/modules_core/abc/events/on_guildemojis_update_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnGuildemojisUpdateABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_invite_create_abc.py b/src/modules_core/abc/events/on_invite_create_abc.py new file mode 100644 index 0000000..ba227a6 --- /dev/null +++ b/src/modules_core/abc/events/on_invite_create_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnInviteCreateABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_invite_delete_abc.py b/src/modules_core/abc/events/on_invite_delete_abc.py new file mode 100644 index 0000000..b72455b --- /dev/null +++ b/src/modules_core/abc/events/on_invite_delete_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnInviteDeleteABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_member_ban_abc.py b/src/modules_core/abc/events/on_member_ban_abc.py new file mode 100644 index 0000000..253e399 --- /dev/null +++ b/src/modules_core/abc/events/on_member_ban_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnMemberBanABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_member_join_abc.py b/src/modules_core/abc/events/on_member_join_abc.py new file mode 100644 index 0000000..6d45f7a --- /dev/null +++ b/src/modules_core/abc/events/on_member_join_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnMemberJoinABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_member_remove_abc.py b/src/modules_core/abc/events/on_member_remove_abc.py new file mode 100644 index 0000000..354f0d4 --- /dev/null +++ b/src/modules_core/abc/events/on_member_remove_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnMemberRemoveABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_member_unban_abc.py b/src/modules_core/abc/events/on_member_unban_abc.py new file mode 100644 index 0000000..f81359c --- /dev/null +++ b/src/modules_core/abc/events/on_member_unban_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnMemberUnbanABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_member_update_abc.py b/src/modules_core/abc/events/on_member_update_abc.py new file mode 100644 index 0000000..fc71ec5 --- /dev/null +++ b/src/modules_core/abc/events/on_member_update_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnMemberUpdateABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_message_delete_abc.py b/src/modules_core/abc/events/on_message_delete_abc.py new file mode 100644 index 0000000..aa95891 --- /dev/null +++ b/src/modules_core/abc/events/on_message_delete_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnMessageDeleteABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_message_edit_abc.py b/src/modules_core/abc/events/on_message_edit_abc.py new file mode 100644 index 0000000..c786869 --- /dev/null +++ b/src/modules_core/abc/events/on_message_edit_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnMessageEditABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_private_channel_create_abc.py b/src/modules_core/abc/events/on_private_channel_create_abc.py new file mode 100644 index 0000000..e4a0e71 --- /dev/null +++ b/src/modules_core/abc/events/on_private_channel_create_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnPrivateChannelCreateABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_private_channel_delete_abc.py b/src/modules_core/abc/events/on_private_channel_delete_abc.py new file mode 100644 index 0000000..7e7db5b --- /dev/null +++ b/src/modules_core/abc/events/on_private_channel_delete_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnPrivateChannelDeleteABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_private_channel_pins_update_abc.py b/src/modules_core/abc/events/on_private_channel_pins_update_abc.py new file mode 100644 index 0000000..c5a82da --- /dev/null +++ b/src/modules_core/abc/events/on_private_channel_pins_update_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnPrivateChannelPinsUpdateABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_private_channel_update_abc.py b/src/modules_core/abc/events/on_private_channel_update_abc.py new file mode 100644 index 0000000..9216695 --- /dev/null +++ b/src/modules_core/abc/events/on_private_channel_update_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnPrivateChannelUpdateABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_reaction_add_abc.py b/src/modules_core/abc/events/on_reaction_add_abc.py new file mode 100644 index 0000000..308721d --- /dev/null +++ b/src/modules_core/abc/events/on_reaction_add_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnReactionAddABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_reaction_clear_abc.py b/src/modules_core/abc/events/on_reaction_clear_abc.py new file mode 100644 index 0000000..a9baa16 --- /dev/null +++ b/src/modules_core/abc/events/on_reaction_clear_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnReactionClearABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_reaction_clear_emoji_abc.py b/src/modules_core/abc/events/on_reaction_clear_emoji_abc.py new file mode 100644 index 0000000..8734841 --- /dev/null +++ b/src/modules_core/abc/events/on_reaction_clear_emoji_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnReactionClearEmojiABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_reaction_remove_abc.py b/src/modules_core/abc/events/on_reaction_remove_abc.py new file mode 100644 index 0000000..fb9a0b3 --- /dev/null +++ b/src/modules_core/abc/events/on_reaction_remove_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnReactionRemoveABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_relationship_add_abc.py b/src/modules_core/abc/events/on_relationship_add_abc.py new file mode 100644 index 0000000..cfaa454 --- /dev/null +++ b/src/modules_core/abc/events/on_relationship_add_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnRelationshipAddABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_relationship_remove_abc.py b/src/modules_core/abc/events/on_relationship_remove_abc.py new file mode 100644 index 0000000..d77db3c --- /dev/null +++ b/src/modules_core/abc/events/on_relationship_remove_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnRelationshipRemoveABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_relationship_update_abc.py b/src/modules_core/abc/events/on_relationship_update_abc.py new file mode 100644 index 0000000..b631d7d --- /dev/null +++ b/src/modules_core/abc/events/on_relationship_update_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnRelationshipUpdateABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_resume_abc.py b/src/modules_core/abc/events/on_resume_abc.py new file mode 100644 index 0000000..5aa4466 --- /dev/null +++ b/src/modules_core/abc/events/on_resume_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnResumeABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_typing_abc.py b/src/modules_core/abc/events/on_typing_abc.py new file mode 100644 index 0000000..f2f41f3 --- /dev/null +++ b/src/modules_core/abc/events/on_typing_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnTypingABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/on_user_update_abc.py b/src/modules_core/abc/events/on_user_update_abc.py new file mode 100644 index 0000000..cda96d4 --- /dev/null +++ b/src/modules_core/abc/events/on_user_update_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnUserUpdateABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/onvoice_state_update_abc.py b/src/modules_core/abc/events/onvoice_state_update_abc.py new file mode 100644 index 0000000..eea0723 --- /dev/null +++ b/src/modules_core/abc/events/onvoice_state_update_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnvoiceStateUpdateABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/modules_core/abc/events/onwebhooks_update_abc.py b/src/modules_core/abc/events/onwebhooks_update_abc.py new file mode 100644 index 0000000..d5e3e66 --- /dev/null +++ b/src/modules_core/abc/events/onwebhooks_update_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class OnwebhooksUpdateABC(ABC): + + @abstractmethod + def __init__(self): pass -- 2.45.2 From 732d28e5dc2cfbfdd51eed4091d5c70cf5ef5b3b Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 18 Nov 2021 17:42:45 +0100 Subject: [PATCH 039/113] Fixed typos --- ...on_guildemojis_update_abc.py => on_guild_emojis_update_abc.py} | 0 .../{onvoice_state_update_abc.py => on_voice_state_update_abc.py} | 0 .../{onwebhooks_update_abc.py => on_webhooks_update_abc.py} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename src/modules_core/abc/events/{on_guildemojis_update_abc.py => on_guild_emojis_update_abc.py} (100%) rename src/modules_core/abc/events/{onvoice_state_update_abc.py => on_voice_state_update_abc.py} (100%) rename src/modules_core/abc/events/{onwebhooks_update_abc.py => on_webhooks_update_abc.py} (100%) diff --git a/src/modules_core/abc/events/on_guildemojis_update_abc.py b/src/modules_core/abc/events/on_guild_emojis_update_abc.py similarity index 100% rename from src/modules_core/abc/events/on_guildemojis_update_abc.py rename to src/modules_core/abc/events/on_guild_emojis_update_abc.py diff --git a/src/modules_core/abc/events/onvoice_state_update_abc.py b/src/modules_core/abc/events/on_voice_state_update_abc.py similarity index 100% rename from src/modules_core/abc/events/onvoice_state_update_abc.py rename to src/modules_core/abc/events/on_voice_state_update_abc.py diff --git a/src/modules_core/abc/events/onwebhooks_update_abc.py b/src/modules_core/abc/events/on_webhooks_update_abc.py similarity index 100% rename from src/modules_core/abc/events/onwebhooks_update_abc.py rename to src/modules_core/abc/events/on_webhooks_update_abc.py -- 2.45.2 From 2914308d65b11804ab7c1f573017cf1360ff6de7 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 19 Nov 2021 08:55:42 +0100 Subject: [PATCH 040/113] Fixed typos --- src/modules_core/abc/events/on_guild_emojis_update_abc.py | 2 +- src/modules_core/abc/events/on_voice_state_update_abc.py | 2 +- src/modules_core/abc/events/on_webhooks_update_abc.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules_core/abc/events/on_guild_emojis_update_abc.py b/src/modules_core/abc/events/on_guild_emojis_update_abc.py index f86d109..fe716ac 100644 --- a/src/modules_core/abc/events/on_guild_emojis_update_abc.py +++ b/src/modules_core/abc/events/on_guild_emojis_update_abc.py @@ -1,7 +1,7 @@ from abc import ABC, abstractmethod -class OnGuildemojisUpdateABC(ABC): +class OnGuildEmojisUpdateABC(ABC): @abstractmethod def __init__(self): pass diff --git a/src/modules_core/abc/events/on_voice_state_update_abc.py b/src/modules_core/abc/events/on_voice_state_update_abc.py index eea0723..266f962 100644 --- a/src/modules_core/abc/events/on_voice_state_update_abc.py +++ b/src/modules_core/abc/events/on_voice_state_update_abc.py @@ -1,7 +1,7 @@ from abc import ABC, abstractmethod -class OnvoiceStateUpdateABC(ABC): +class OnVoiceStateUpdateABC(ABC): @abstractmethod def __init__(self): pass diff --git a/src/modules_core/abc/events/on_webhooks_update_abc.py b/src/modules_core/abc/events/on_webhooks_update_abc.py index d5e3e66..90f1e0e 100644 --- a/src/modules_core/abc/events/on_webhooks_update_abc.py +++ b/src/modules_core/abc/events/on_webhooks_update_abc.py @@ -1,7 +1,7 @@ from abc import ABC, abstractmethod -class OnwebhooksUpdateABC(ABC): +class OnWebhooksUpdateABC(ABC): @abstractmethod def __init__(self): pass -- 2.45.2 From 118ba99b925b7954d2d7dfcd590f609f204b78a1 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 19 Nov 2021 08:58:38 +0100 Subject: [PATCH 041/113] Renamed application class --- src/gismo/application.py | 2 +- src/gismo/main.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gismo/application.py b/src/gismo/application.py index c466271..9602da6 100644 --- a/src/gismo/application.py +++ b/src/gismo/application.py @@ -7,7 +7,7 @@ from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.service.bot_service import BotService -class Application(ApplicationABC): +class Gismo(ApplicationABC): def __init__(self, config: ConfigurationABC, services: ServiceProviderABC): ApplicationABC.__init__(self, config, services) diff --git a/src/gismo/main.py b/src/gismo/main.py index 8b4d020..e56e8a7 100644 --- a/src/gismo/main.py +++ b/src/gismo/main.py @@ -3,24 +3,24 @@ from typing import Optional from cpl_core.application import ApplicationABC, ApplicationBuilder -from gismo.application import Application +from gismo.application import Gismo from gismo.startup import Startup from modules.boot_log.boot_log_extension import BootLogExtension class Main: def __init__(self): - self._app: Optional[ApplicationABC] = None + self._gismo: Optional[Gismo] = None async def main(self): - app_builder = ApplicationBuilder(Application) + app_builder = ApplicationBuilder(Gismo) app_builder.use_extension(BootLogExtension) app_builder.use_startup(Startup) - self._app: ApplicationABC = await app_builder.build_async() - await self._app.run_async() + self._gismo: Gismo = await app_builder.build_async() + await self._gismo.run_async() async def stop(self): - await self._app.stop_async() + await self._gismo.stop_async() if __name__ == '__main__': main = Main() -- 2.45.2 From 7a9e127df36049c40191d22a9a8e3950bbd2a95f Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 19 Nov 2021 09:21:04 +0100 Subject: [PATCH 042/113] Improved package files --- src/gismo/main.py | 19 ++++++++++++++++--- src/gismo_core/__init__.py | 24 ++++++++++++++++++++++++ src/gismo_core/abc/__init__.py | 24 ++++++++++++++++++++++++ src/gismo_core/configuration/__init__.py | 24 ++++++++++++++++++++++++ src/gismo_core/service/__init__.py | 24 ++++++++++++++++++++++++ src/modules_core/__init__.py | 24 ++++++++++++++++++++++++ src/modules_core/abc/__init__.py | 24 ++++++++++++++++++++++++ src/modules_core/service/__init__.py | 24 ++++++++++++++++++++++++ 8 files changed, 184 insertions(+), 3 deletions(-) diff --git a/src/gismo/main.py b/src/gismo/main.py index e56e8a7..8cc06c0 100644 --- a/src/gismo/main.py +++ b/src/gismo/main.py @@ -7,8 +7,9 @@ from gismo.application import Gismo from gismo.startup import Startup from modules.boot_log.boot_log_extension import BootLogExtension + class Main: - + def __init__(self): self._gismo: Optional[Gismo] = None @@ -18,14 +19,26 @@ class Main: app_builder.use_startup(Startup) self._gismo: Gismo = await app_builder.build_async() await self._gismo.run_async() - + async def stop(self): await self._gismo.stop_async() + if __name__ == '__main__': main = Main() ml = asyncio.get_event_loop() try: ml.run_until_complete(main.main()) except KeyboardInterrupt: - ml.run_until_complete(main.stop()) \ No newline at end of file + ml.run_until_complete(main.stop()) + + +# (( +# ( `) +# ; / , +# / \/ +# / | +# / ~/ +# / ) ) ~ edraft +# ___// | / +# `--' \_~-, \ No newline at end of file diff --git a/src/gismo_core/__init__.py b/src/gismo_core/__init__.py index 425ab6c..2dcbf1d 100644 --- a/src/gismo_core/__init__.py +++ b/src/gismo_core/__init__.py @@ -1 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +gismo sh-edraft Gismo +~~~~~~~~~~~~~~~~~~~ + +sh-edraft Dicord bot Gismo + +:copyright: (c) 2021 - 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'gismo_core' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' +__version__ = '0.1.0' + +from collections import namedtuple + # imports + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='1', micro='0') diff --git a/src/gismo_core/abc/__init__.py b/src/gismo_core/abc/__init__.py index 425ab6c..79226e4 100644 --- a/src/gismo_core/abc/__init__.py +++ b/src/gismo_core/abc/__init__.py @@ -1 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +gismo sh-edraft Gismo +~~~~~~~~~~~~~~~~~~~ + +sh-edraft Dicord bot Gismo + +:copyright: (c) 2021 - 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'gismo_core.abc' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' +__version__ = '0.1.0' + +from collections import namedtuple + # imports + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='1', micro='0') diff --git a/src/gismo_core/configuration/__init__.py b/src/gismo_core/configuration/__init__.py index 425ab6c..a5a1baa 100644 --- a/src/gismo_core/configuration/__init__.py +++ b/src/gismo_core/configuration/__init__.py @@ -1 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +gismo sh-edraft Gismo +~~~~~~~~~~~~~~~~~~~ + +sh-edraft Dicord bot Gismo + +:copyright: (c) 2021 - 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'gismo_core.configuration' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' +__version__ = '0.1.0' + +from collections import namedtuple + # imports + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='1', micro='0') diff --git a/src/gismo_core/service/__init__.py b/src/gismo_core/service/__init__.py index 425ab6c..1947127 100644 --- a/src/gismo_core/service/__init__.py +++ b/src/gismo_core/service/__init__.py @@ -1 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +gismo sh-edraft Gismo +~~~~~~~~~~~~~~~~~~~ + +sh-edraft Dicord bot Gismo + +:copyright: (c) 2021 - 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'gismo_core.service' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' +__version__ = '0.1.0' + +from collections import namedtuple + # imports + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='1', micro='0') diff --git a/src/modules_core/__init__.py b/src/modules_core/__init__.py index 425ab6c..979887f 100644 --- a/src/modules_core/__init__.py +++ b/src/modules_core/__init__.py @@ -1 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +gismo sh-edraft Gismo +~~~~~~~~~~~~~~~~~~~ + +sh-edraft Dicord bot Gismo + +:copyright: (c) 2021 - 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'modules_core' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' +__version__ = '0.1.0' + +from collections import namedtuple + # imports + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='1', micro='0') diff --git a/src/modules_core/abc/__init__.py b/src/modules_core/abc/__init__.py index 425ab6c..a65a733 100644 --- a/src/modules_core/abc/__init__.py +++ b/src/modules_core/abc/__init__.py @@ -1 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +gismo sh-edraft Gismo +~~~~~~~~~~~~~~~~~~~ + +sh-edraft Dicord bot Gismo + +:copyright: (c) 2021 - 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'modules_core.abc' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' +__version__ = '0.1.0' + +from collections import namedtuple + # imports + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='1', micro='0') diff --git a/src/modules_core/service/__init__.py b/src/modules_core/service/__init__.py index 425ab6c..3f494a0 100644 --- a/src/modules_core/service/__init__.py +++ b/src/modules_core/service/__init__.py @@ -1 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +gismo sh-edraft Gismo +~~~~~~~~~~~~~~~~~~~ + +sh-edraft Dicord bot Gismo + +:copyright: (c) 2021 - 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'modules_core.service' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' +__version__ = '0.1.0' + +from collections import namedtuple + # imports + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='1', micro='0') -- 2.45.2 From 03d427b5209847ef7c45bbc3e83324a65b37fe18 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 12:13:14 +0100 Subject: [PATCH 043/113] Improved config --- src/gismo/appsettings.edrafts-lapi.json | 3 +++ src/gismo/appsettings.edrafts-pc.json | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/gismo/appsettings.edrafts-lapi.json b/src/gismo/appsettings.edrafts-lapi.json index 2c63c08..a8919a4 100644 --- a/src/gismo/appsettings.edrafts-lapi.json +++ b/src/gismo/appsettings.edrafts-lapi.json @@ -1,2 +1,5 @@ { + "Discord": { + "Token": "OTExNTc0NDQyMzMxNzM0MDI2.YZjX2w.9yhsrTfrmkoDUqRJVzV5FVEwF3U" + } } diff --git a/src/gismo/appsettings.edrafts-pc.json b/src/gismo/appsettings.edrafts-pc.json index 2c63c08..a8919a4 100644 --- a/src/gismo/appsettings.edrafts-pc.json +++ b/src/gismo/appsettings.edrafts-pc.json @@ -1,2 +1,5 @@ { + "Discord": { + "Token": "OTExNTc0NDQyMzMxNzM0MDI2.YZjX2w.9yhsrTfrmkoDUqRJVzV5FVEwF3U" + } } -- 2.45.2 From 652a3eeb47f7f92d6322b53f9b55a68e7e9e2c83 Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 15:57:46 +0100 Subject: [PATCH 044/113] Farbe geaendert --- .vscode/settings.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 10cee69..e8a8578 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,23 +1,23 @@ { "workbench.colorCustomizations": { - "activityBar.activeBackground": "#fbed80", - "activityBar.activeBorder": "#06b9a5", - "activityBar.background": "#fbed80", + "activityBar.activeBackground": "#93e6fc", + "activityBar.activeBorder": "#fa45d4", + "activityBar.background": "#93e6fc", "activityBar.foreground": "#15202b", "activityBar.inactiveForeground": "#15202b99", - "activityBarBadge.background": "#06b9a5", + "activityBarBadge.background": "#fa45d4", "activityBarBadge.foreground": "#15202b", - "sash.hoverBorder": "#fbed80", - "statusBar.background": "#f9e64f", + "sash.hoverBorder": "#93e6fc", + "statusBar.background": "#61dafb", "statusBar.foreground": "#15202b", - "statusBarItem.hoverBackground": "#f7df1e", - "statusBarItem.remoteBackground": "#f9e64f", + "statusBarItem.hoverBackground": "#2fcefa", + "statusBarItem.remoteBackground": "#61dafb", "statusBarItem.remoteForeground": "#15202b", - "titleBar.activeBackground": "#f9e64f", + "titleBar.activeBackground": "#61dafb", "titleBar.activeForeground": "#15202b", - "titleBar.inactiveBackground": "#f9e64f99", + "titleBar.inactiveBackground": "#61dafb99", "titleBar.inactiveForeground": "#15202b99" }, - "peacock.color": "#f9e64f", - "python.pythonPath": "${workspaceRoot}/venv/bin/python", + "peacock.color": "#61dafb", + "python.defaultInterpreterPath": "${workspaceRoot}/venv/bin/python", } \ No newline at end of file -- 2.45.2 From baa86b75e797971f3443c9594416b19649a79e9a Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 15:58:22 +0100 Subject: [PATCH 045/113] Rechtschreibfehler korregiert --- .vscode/launch.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 255ae11..dc382e7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -24,7 +24,7 @@ "env": { "CPL_NAME": "Gismo", "GISMO_ENVIRONMENT": "development", - "PYTHONPATH": "${workspaceFolder}/src/:$PATHONPATH" + "PYTHONPATH": "${workspaceFolder}/src/:$PYTHONPATH" } } ] -- 2.45.2 From 8461d793deffc8c1bb33bddff4db7a7c7eb34165 Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 16:19:18 +0100 Subject: [PATCH 046/113] Added on_connect ABC --- src/modules_core/abc/events/on_connect_abc.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules_core/abc/events/on_connect_abc.py b/src/modules_core/abc/events/on_connect_abc.py index 0210c46..96d1909 100644 --- a/src/modules_core/abc/events/on_connect_abc.py +++ b/src/modules_core/abc/events/on_connect_abc.py @@ -5,3 +5,6 @@ class OnConnectABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_connect(self): pass -- 2.45.2 From d99cec79b9d70c75a4af709ce715a039eed1d7f9 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 16:24:12 +0100 Subject: [PATCH 047/113] Added on_relationship_update event abc --- src/modules_core/abc/events/on_relationship_update_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_relationship_update_abc.py b/src/modules_core/abc/events/on_relationship_update_abc.py index b631d7d..4d97091 100644 --- a/src/modules_core/abc/events/on_relationship_update_abc.py +++ b/src/modules_core/abc/events/on_relationship_update_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnRelationshipUpdateABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_relationship_update( + self, before: discord.Relationship, after: discord.Relationship): pass -- 2.45.2 From 711819cdeaa46ba501985691c4ce3987834f39ee Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 16:31:31 +0100 Subject: [PATCH 048/113] Added config --- src/gismo/appsettings.coBIANYXra.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/gismo/appsettings.coBIANYXra.json diff --git a/src/gismo/appsettings.coBIANYXra.json b/src/gismo/appsettings.coBIANYXra.json new file mode 100644 index 0000000..eec0a76 --- /dev/null +++ b/src/gismo/appsettings.coBIANYXra.json @@ -0,0 +1,5 @@ +{ + "Discord": { + "Token": "OTExNjM5NjE2MTAzMjUyMDM4.YZkUjQ.MCqPkOTIMdvMYrmt47lfrZ0inhg" + } +} -- 2.45.2 From ae7f6543f3fcbc69b9ed59b132286fd2ecf3c9ee Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 16:35:21 +0100 Subject: [PATCH 049/113] Added on_disconnect update event ABC --- src/modules_core/abc/events/on_disconnect_abc.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules_core/abc/events/on_disconnect_abc.py b/src/modules_core/abc/events/on_disconnect_abc.py index 00a1af9..eb3be9a 100644 --- a/src/modules_core/abc/events/on_disconnect_abc.py +++ b/src/modules_core/abc/events/on_disconnect_abc.py @@ -5,3 +5,6 @@ class OnDisconnectABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_disconnect(self): pass \ No newline at end of file -- 2.45.2 From 0730c5f91539c82068867846ad664a313b51296d Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 16:35:56 +0100 Subject: [PATCH 050/113] Added on_relationship_remove event abc --- src/modules_core/abc/events/on_relationship_remove_abc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules_core/abc/events/on_relationship_remove_abc.py b/src/modules_core/abc/events/on_relationship_remove_abc.py index d77db3c..c842a4a 100644 --- a/src/modules_core/abc/events/on_relationship_remove_abc.py +++ b/src/modules_core/abc/events/on_relationship_remove_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod - +import discord class OnRelationshipRemoveABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_relationship_remove(self, relationship: discord.Relationship): pass + \ No newline at end of file -- 2.45.2 From 89c31c63929bb6e44647b6661d50bcbca88bf2e6 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 16:36:22 +0100 Subject: [PATCH 051/113] Added on_relationship_add event abc --- src/modules_core/abc/events/on_relationship_add_abc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules_core/abc/events/on_relationship_add_abc.py b/src/modules_core/abc/events/on_relationship_add_abc.py index cfaa454..5cba49a 100644 --- a/src/modules_core/abc/events/on_relationship_add_abc.py +++ b/src/modules_core/abc/events/on_relationship_add_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod - +import discord class OnRelationshipAddABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_relationship_add(self, relationship: discord.Relationship): pass + \ No newline at end of file -- 2.45.2 From a56bdf39f73902fca98187a15761c0ace3e61e25 Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 16:36:52 +0100 Subject: [PATCH 052/113] Added on_resume update event ABC --- src/modules_core/abc/events/on_resume_abc.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules_core/abc/events/on_resume_abc.py b/src/modules_core/abc/events/on_resume_abc.py index 5aa4466..28e63f9 100644 --- a/src/modules_core/abc/events/on_resume_abc.py +++ b/src/modules_core/abc/events/on_resume_abc.py @@ -5,3 +5,6 @@ class OnResumeABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_resume(self): pass \ No newline at end of file -- 2.45.2 From 31682f2b83212f164818c7011e380737bfa6e733 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 16:38:23 +0100 Subject: [PATCH 053/113] Added on_group_remove event abc --- src/modules_core/abc/events/on_group_remove_abc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules_core/abc/events/on_group_remove_abc.py b/src/modules_core/abc/events/on_group_remove_abc.py index b4dd22b..dc6fda8 100644 --- a/src/modules_core/abc/events/on_group_remove_abc.py +++ b/src/modules_core/abc/events/on_group_remove_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod - +import discord class OnGroupRemoveABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_group_remove( + self, chhanel: discord.GroupChannel, user: discord.User): pass -- 2.45.2 From c0d38817d48a7f2ad619ee7edfb889ae29d48a5b Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 16:38:46 +0100 Subject: [PATCH 054/113] Added on_error update event ABC --- src/modules_core/abc/events/on_error_abc.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules_core/abc/events/on_error_abc.py b/src/modules_core/abc/events/on_error_abc.py index 26350f4..ff4badb 100644 --- a/src/modules_core/abc/events/on_error_abc.py +++ b/src/modules_core/abc/events/on_error_abc.py @@ -5,3 +5,6 @@ class OnErrorABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_error(self, event: str, *args, **kwargs): pass \ No newline at end of file -- 2.45.2 From 49ec7ea9319220703ff01e7bbdbdd2332df2f59d Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 16:39:15 +0100 Subject: [PATCH 055/113] Added on_group_join event abc --- src/modules_core/abc/events/on_group_join_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_group_join_abc.py b/src/modules_core/abc/events/on_group_join_abc.py index 0ab53db..e0b3aaa 100644 --- a/src/modules_core/abc/events/on_group_join_abc.py +++ b/src/modules_core/abc/events/on_group_join_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnGroupJoinABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_group_join( + self, chhanel: discord.GroupChannel, user: discord.User): pass -- 2.45.2 From c3e1aaf40f47d5dc6f366334f86a5a86075cfb1f Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 16:39:36 +0100 Subject: [PATCH 056/113] Added on_typing update event ABC --- src/modules_core/abc/events/on_typing_abc.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules_core/abc/events/on_typing_abc.py b/src/modules_core/abc/events/on_typing_abc.py index f2f41f3..f430663 100644 --- a/src/modules_core/abc/events/on_typing_abc.py +++ b/src/modules_core/abc/events/on_typing_abc.py @@ -5,3 +5,6 @@ class OnTypingABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_typing(self, channel: discord.abc.Messageable, user: Union[discord.User, discord.Member], when: datetime): pass -- 2.45.2 From 04179ce906bc999a16359f18fc5b5a9b9eaac56b Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 16:39:55 +0100 Subject: [PATCH 057/113] Added on_invite_delete event abc --- src/modules_core/abc/events/on_invite_delete_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules_core/abc/events/on_invite_delete_abc.py b/src/modules_core/abc/events/on_invite_delete_abc.py index b72455b..bbd848c 100644 --- a/src/modules_core/abc/events/on_invite_delete_abc.py +++ b/src/modules_core/abc/events/on_invite_delete_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod +import discord class OnInviteDeleteABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_invite_delete(self, invite: discord.Invite): pass -- 2.45.2 From 426772910f1ea0c6885709700f0522ce097b6ec5 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 16:41:29 +0100 Subject: [PATCH 058/113] Added on_invite_create event abc --- src/modules_core/abc/events/on_invite_create_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_invite_create_abc.py b/src/modules_core/abc/events/on_invite_create_abc.py index ba227a6..ce4e2e0 100644 --- a/src/modules_core/abc/events/on_invite_create_abc.py +++ b/src/modules_core/abc/events/on_invite_create_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnInviteCreateABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_invite_create(self, invite: discord.Invite): pass + \ No newline at end of file -- 2.45.2 From 4d7c67a3b6550530499688531abc5aa4c3595314 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 16:42:12 +0100 Subject: [PATCH 059/113] Added on_member_unban event abc --- src/modules_core/abc/events/on_member_unban_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules_core/abc/events/on_member_unban_abc.py b/src/modules_core/abc/events/on_member_unban_abc.py index f81359c..c5bbb8c 100644 --- a/src/modules_core/abc/events/on_member_unban_abc.py +++ b/src/modules_core/abc/events/on_member_unban_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod +import discord class OnMemberUnbanABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_member_unban(self, guild: discord.Guild, user: discord.User): pass -- 2.45.2 From 7edef25617b002909ef41d8cdcc0afa6458c9afd Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 16:47:59 +0100 Subject: [PATCH 060/113] Added on_member_ban event abc --- src/modules_core/abc/events/on_member_ban_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_member_ban_abc.py b/src/modules_core/abc/events/on_member_ban_abc.py index 253e399..4410fad 100644 --- a/src/modules_core/abc/events/on_member_ban_abc.py +++ b/src/modules_core/abc/events/on_member_ban_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnMemberBanABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_member_ban(self, guild: discord.Guild, + user: discord.User): pass -- 2.45.2 From b429d60bcd64f7ee6855d97cda0e0c9467fe9c2b Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 16:53:54 +0100 Subject: [PATCH 061/113] Added on_message_delete event ABC --- src/modules_core/abc/events/on_message_delete_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules_core/abc/events/on_message_delete_abc.py b/src/modules_core/abc/events/on_message_delete_abc.py index aa95891..57cf30e 100644 --- a/src/modules_core/abc/events/on_message_delete_abc.py +++ b/src/modules_core/abc/events/on_message_delete_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod +import discord class OnMessageDeleteABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_message_delete(self, message: discord.Message): pass \ No newline at end of file -- 2.45.2 From 15af3b1f6351be0c39eff3caa8b4eb21dce8d120 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 16:58:30 +0100 Subject: [PATCH 062/113] Added import to on_typing event abc --- src/modules_core/abc/events/on_typing_abc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules_core/abc/events/on_typing_abc.py b/src/modules_core/abc/events/on_typing_abc.py index f430663..56fadbf 100644 --- a/src/modules_core/abc/events/on_typing_abc.py +++ b/src/modules_core/abc/events/on_typing_abc.py @@ -1,4 +1,5 @@ from abc import ABC, abstractmethod +import discord class OnTypingABC(ABC): -- 2.45.2 From 558b6628a32ab0771bc952db169cf1f4ad05326c Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 16:59:16 +0100 Subject: [PATCH 063/113] Added on_bulk_message_delete event abc --- src/modules_core/abc/events/on_bulk_message_delete_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_bulk_message_delete_abc.py b/src/modules_core/abc/events/on_bulk_message_delete_abc.py index c9bbc75..a838e06 100644 --- a/src/modules_core/abc/events/on_bulk_message_delete_abc.py +++ b/src/modules_core/abc/events/on_bulk_message_delete_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnBulkMessageDeleteABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_bulk_message_delete(self, message: discord.Message): pass + \ No newline at end of file -- 2.45.2 From bef8ea0a25dcda72eb374be31ce4a26d0a028977 Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 18:51:48 +0100 Subject: [PATCH 064/113] Added on_bulk_message_delete event abc --- src/modules_core/abc/events/on_bulk_message_delete_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules_core/abc/events/on_bulk_message_delete_abc.py b/src/modules_core/abc/events/on_bulk_message_delete_abc.py index c9bbc75..15e90bb 100644 --- a/src/modules_core/abc/events/on_bulk_message_delete_abc.py +++ b/src/modules_core/abc/events/on_bulk_message_delete_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod +import discord class OnBulkMessageDeleteABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_bulk_message_delete(self, message: discord.Message): pass -- 2.45.2 From b903ec54343fe81571323ccd82fbdf910fb8eb7e Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 18:54:59 +0100 Subject: [PATCH 065/113] Added on_message_edit event abc --- src/modules_core/abc/events/on_message_edit_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules_core/abc/events/on_message_edit_abc.py b/src/modules_core/abc/events/on_message_edit_abc.py index c786869..b8d4df8 100644 --- a/src/modules_core/abc/events/on_message_edit_abc.py +++ b/src/modules_core/abc/events/on_message_edit_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod +import discord class OnMessageEditABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_message_edit(self, before: discord.Message, after: discord.Message): pass -- 2.45.2 From c9f28ddc14140431c892984d0335a6ef5f7d05e4 Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 18:57:45 +0100 Subject: [PATCH 066/113] Added on_reaction_add event abc --- src/modules_core/abc/events/on_reaction_add_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_reaction_add_abc.py b/src/modules_core/abc/events/on_reaction_add_abc.py index 308721d..c168222 100644 --- a/src/modules_core/abc/events/on_reaction_add_abc.py +++ b/src/modules_core/abc/events/on_reaction_add_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnReactionAddABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_reaction_add(self, reaction: discord.Reaction, user: discord.User): pass + \ No newline at end of file -- 2.45.2 From 67696bc63c9afb7778f3fe254b57050e142c869b Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 18:57:55 +0100 Subject: [PATCH 067/113] Added on_webhooks_update event abc --- src/modules_core/abc/events/on_webhooks_update_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_webhooks_update_abc.py b/src/modules_core/abc/events/on_webhooks_update_abc.py index 90f1e0e..db92f58 100644 --- a/src/modules_core/abc/events/on_webhooks_update_abc.py +++ b/src/modules_core/abc/events/on_webhooks_update_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnWebhooksUpdateABC(ABC): @abstractmethod def __init__(self): pass + + + @abstractmethod + async def on_webhooks_update(self, channel: discord.abc.GuildChannel): pass -- 2.45.2 From acc106a5671fd60c259a22a379f75133ab459ecf Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 18:58:29 +0100 Subject: [PATCH 068/113] Added on_reaction_remove event abc --- src/modules_core/abc/events/on_reaction_remove_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_reaction_remove_abc.py b/src/modules_core/abc/events/on_reaction_remove_abc.py index fb9a0b3..6dc34d1 100644 --- a/src/modules_core/abc/events/on_reaction_remove_abc.py +++ b/src/modules_core/abc/events/on_reaction_remove_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnReactionRemoveABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_reaction_remove(self, reaction: discord.Reaction, user: discord.User): pass + \ No newline at end of file -- 2.45.2 From e83982fc2a245915ec95ba6e079fe4eb22d87be4 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 18:58:35 +0100 Subject: [PATCH 069/113] Added on_member_join event abc --- src/modules_core/abc/events/on_member_join_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_member_join_abc.py b/src/modules_core/abc/events/on_member_join_abc.py index 6d45f7a..51036e5 100644 --- a/src/modules_core/abc/events/on_member_join_abc.py +++ b/src/modules_core/abc/events/on_member_join_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnMemberJoinABC(ABC): @abstractmethod def __init__(self): pass + + + @abstractmethod + async def on_member_join(self, member: discord.Member): pass -- 2.45.2 From aeef7ed477b068ccc2ee865460cedbf8bfd7dd6c Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 18:59:02 +0100 Subject: [PATCH 070/113] Added on_member_remove event abc --- src/modules_core/abc/events/on_member_remove_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules_core/abc/events/on_member_remove_abc.py b/src/modules_core/abc/events/on_member_remove_abc.py index 354f0d4..b24f3d5 100644 --- a/src/modules_core/abc/events/on_member_remove_abc.py +++ b/src/modules_core/abc/events/on_member_remove_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod +import discord class OnMemberRemoveABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_member_remove(self, member: discord.Member): pass -- 2.45.2 From 2c7755310d0c0e8ed04680116fb65ef0b17287ce Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 18:59:35 +0100 Subject: [PATCH 071/113] Added on_member_update event abc --- src/modules_core/abc/events/on_member_update_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules_core/abc/events/on_member_update_abc.py b/src/modules_core/abc/events/on_member_update_abc.py index fc71ec5..6ca11df 100644 --- a/src/modules_core/abc/events/on_member_update_abc.py +++ b/src/modules_core/abc/events/on_member_update_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod +import discord class OnMemberUpdateABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_member_update(self, before: discord.Member, after: discord.Member): pass -- 2.45.2 From 1edcfe58d2b06ec19c96986c894ec78eeb329576 Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 18:59:56 +0100 Subject: [PATCH 072/113] Added on_reaction_clear event abc --- src/modules_core/abc/events/on_reaction_clear_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_reaction_clear_abc.py b/src/modules_core/abc/events/on_reaction_clear_abc.py index a9baa16..7d2ef66 100644 --- a/src/modules_core/abc/events/on_reaction_clear_abc.py +++ b/src/modules_core/abc/events/on_reaction_clear_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnReactionClearABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_reaction_clear(self, message: discord.Message, reactions: list[discord.Reaction]): pass + \ No newline at end of file -- 2.45.2 From d1740edda0e4dc8dd2a783a6c13195d083790333 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 19:00:04 +0100 Subject: [PATCH 073/113] Added on_user_update event abc --- src/modules_core/abc/events/on_user_update_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules_core/abc/events/on_user_update_abc.py b/src/modules_core/abc/events/on_user_update_abc.py index cda96d4..0a9b7c9 100644 --- a/src/modules_core/abc/events/on_user_update_abc.py +++ b/src/modules_core/abc/events/on_user_update_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod +import discord class OnUserUpdateABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_user_update(self, before: discord.User, after: discord.User): pass -- 2.45.2 From 14d543a5877207d269efd2741c7e08ce3822179e Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 19:00:35 +0100 Subject: [PATCH 074/113] Added on_guild_join event abc --- src/modules_core/abc/events/on_guild_join_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules_core/abc/events/on_guild_join_abc.py b/src/modules_core/abc/events/on_guild_join_abc.py index b979ec5..c6e82f1 100644 --- a/src/modules_core/abc/events/on_guild_join_abc.py +++ b/src/modules_core/abc/events/on_guild_join_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod +import discord class OnGuildJoinABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_guild_join(self, guild: discord.Guild): pass -- 2.45.2 From 4176db9f9172d12a131453883bca2750b728b0bd Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 19:01:20 +0100 Subject: [PATCH 075/113] Added on_guild_remove event abc --- src/modules_core/abc/events/on_guild_remove_abc.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules_core/abc/events/on_guild_remove_abc.py b/src/modules_core/abc/events/on_guild_remove_abc.py index 770304e..04f0e34 100644 --- a/src/modules_core/abc/events/on_guild_remove_abc.py +++ b/src/modules_core/abc/events/on_guild_remove_abc.py @@ -1,7 +1,10 @@ from abc import ABC, abstractmethod +import discord class OnGuildRemoveABC(ABC): @abstractmethod def __init__(self): pass + @abstractmethod + async def on_guild_remove(self, guild: discord.Guild): pass -- 2.45.2 From e81449031e0061562a1087d5994d3a579756c6d7 Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 19:01:32 +0100 Subject: [PATCH 076/113] Added on_reaction_clear_emoij event abc --- src/modules_core/abc/events/on_reaction_clear_emoji_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_reaction_clear_emoji_abc.py b/src/modules_core/abc/events/on_reaction_clear_emoji_abc.py index 8734841..1e683eb 100644 --- a/src/modules_core/abc/events/on_reaction_clear_emoji_abc.py +++ b/src/modules_core/abc/events/on_reaction_clear_emoji_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnReactionClearEmojiABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_reaction_clear_emoji(self, reaction: discord.Reaction): pass + -- 2.45.2 From b0c75fa651615622a7c70ecfba921fd96164db52 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 19:01:57 +0100 Subject: [PATCH 077/113] Added on_guild_update event abc --- src/modules_core/abc/events/on_guild_update_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules_core/abc/events/on_guild_update_abc.py b/src/modules_core/abc/events/on_guild_update_abc.py index 5071094..7ed4c1a 100644 --- a/src/modules_core/abc/events/on_guild_update_abc.py +++ b/src/modules_core/abc/events/on_guild_update_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod +import discord class OnGuildUpdateABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_guild_update(self, before: discord.Guild, after: discord.Guild): pass -- 2.45.2 From 276910c86d9ed4360f50016099675dd90dd84555 Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 19:02:25 +0100 Subject: [PATCH 078/113] Added on_private_channel_delete event abc --- src/modules_core/abc/events/on_private_channel_delete_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_private_channel_delete_abc.py b/src/modules_core/abc/events/on_private_channel_delete_abc.py index 7e7db5b..0e6f775 100644 --- a/src/modules_core/abc/events/on_private_channel_delete_abc.py +++ b/src/modules_core/abc/events/on_private_channel_delete_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnPrivateChannelDeleteABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_private_channel_delete(self, channel: discord.abc.PrivateChannel): pass + -- 2.45.2 From 4d69250342b58a1a9906126f7b009c245f91d6df Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 19:02:27 +0100 Subject: [PATCH 079/113] Added on_guild_role_create event abc --- src/modules_core/abc/events/on_guild_role_create_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules_core/abc/events/on_guild_role_create_abc.py b/src/modules_core/abc/events/on_guild_role_create_abc.py index 9a54e26..f828988 100644 --- a/src/modules_core/abc/events/on_guild_role_create_abc.py +++ b/src/modules_core/abc/events/on_guild_role_create_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod +import discord class OnGuildRoleCreateABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_guild_role_create(self, role: discord.Role): pass -- 2.45.2 From 463456711d573141f839b07e320eb4b0c476ce89 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 19:03:02 +0100 Subject: [PATCH 080/113] Added on_guild_role_delete event abc --- src/modules_core/abc/events/on_guild_role_delete_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules_core/abc/events/on_guild_role_delete_abc.py b/src/modules_core/abc/events/on_guild_role_delete_abc.py index 844223b..a26bdd2 100644 --- a/src/modules_core/abc/events/on_guild_role_delete_abc.py +++ b/src/modules_core/abc/events/on_guild_role_delete_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod +import discord class OnGuildRoleDeleteABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_guild_role_delete(self, role: discord.Role): pass -- 2.45.2 From a2e52e473c6e61da8fd0bcbdc121e694af8f02cd Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 19:03:31 +0100 Subject: [PATCH 081/113] Added on_guild_role_update event abc --- src/modules_core/abc/events/on_guild_role_update_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules_core/abc/events/on_guild_role_update_abc.py b/src/modules_core/abc/events/on_guild_role_update_abc.py index d5678ac..905efb5 100644 --- a/src/modules_core/abc/events/on_guild_role_update_abc.py +++ b/src/modules_core/abc/events/on_guild_role_update_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod +import discord class OnGuildRoleUpdateABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_guild_role_update(self, before: discord.Role, after: discord.Role): pass -- 2.45.2 From e351b98fe46df3e064ba73fd5eef9063eed5efd0 Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 19:04:17 +0100 Subject: [PATCH 082/113] Added on_guild_channel_create event abc --- src/modules_core/abc/events/on_guild_channel_create_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_guild_channel_create_abc.py b/src/modules_core/abc/events/on_guild_channel_create_abc.py index c04bef7..3d36777 100644 --- a/src/modules_core/abc/events/on_guild_channel_create_abc.py +++ b/src/modules_core/abc/events/on_guild_channel_create_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnGuildChannelCreateABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_guild_channel_create(self, channel: discord.abc.GuildChannel): pass + \ No newline at end of file -- 2.45.2 From 9cbc589d627a025957294baf0cf551be249ea280 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 19:04:21 +0100 Subject: [PATCH 083/113] Added on_guild_emojis_update event abc --- src/modules_core/abc/events/on_guild_emojis_update_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_guild_emojis_update_abc.py b/src/modules_core/abc/events/on_guild_emojis_update_abc.py index fe716ac..40a3247 100644 --- a/src/modules_core/abc/events/on_guild_emojis_update_abc.py +++ b/src/modules_core/abc/events/on_guild_emojis_update_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +from typing import Sequence +import discord class OnGuildEmojisUpdateABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_guild_emojis_update(self, guild: discord.Guild, before: Sequence[discord.Emoji], after: Sequence[discord.Emoji]): pass -- 2.45.2 From 3fc3b9548a7b3713da58b192c1d869b129b5c841 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 19:04:53 +0100 Subject: [PATCH 084/113] Added on_guild_available event abc --- src/modules_core/abc/events/on_guild_available_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules_core/abc/events/on_guild_available_abc.py b/src/modules_core/abc/events/on_guild_available_abc.py index 35ef0d8..8b6eaa9 100644 --- a/src/modules_core/abc/events/on_guild_available_abc.py +++ b/src/modules_core/abc/events/on_guild_available_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod +import discord class OnGuildAvailableABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_guild_available(self, guild: discord.Guild): pass -- 2.45.2 From 4e00da99b524386f0be060197496ffcd2042d351 Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 19:05:17 +0100 Subject: [PATCH 085/113] Added on_private_channel_create event abc --- src/modules_core/abc/events/on_private_channel_create_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_private_channel_create_abc.py b/src/modules_core/abc/events/on_private_channel_create_abc.py index e4a0e71..371ccaf 100644 --- a/src/modules_core/abc/events/on_private_channel_create_abc.py +++ b/src/modules_core/abc/events/on_private_channel_create_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnPrivateChannelCreateABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_private_channel_create(self, channel: discord.abc.PrivateChannel): pass + \ No newline at end of file -- 2.45.2 From 3b4b81eba0c6575d70a6f7d255ab692701387427 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 19:05:23 +0100 Subject: [PATCH 086/113] Added on_guild_unavailable event abc --- src/modules_core/abc/events/on_guild_unavailable_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules_core/abc/events/on_guild_unavailable_abc.py b/src/modules_core/abc/events/on_guild_unavailable_abc.py index 0064fdf..5666407 100644 --- a/src/modules_core/abc/events/on_guild_unavailable_abc.py +++ b/src/modules_core/abc/events/on_guild_unavailable_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod +import discord class OnGuildUnavailableABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_guild_unavailable(self, guild: discord.Guild): pass -- 2.45.2 From f033eeaf87e468f07922106c574d5a081d1379c7 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 19:05:50 +0100 Subject: [PATCH 087/113] Added on_voice_state_update event abc --- src/modules_core/abc/events/on_voice_state_update_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules_core/abc/events/on_voice_state_update_abc.py b/src/modules_core/abc/events/on_voice_state_update_abc.py index 266f962..60d586f 100644 --- a/src/modules_core/abc/events/on_voice_state_update_abc.py +++ b/src/modules_core/abc/events/on_voice_state_update_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod +import discord class OnVoiceStateUpdateABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState,after: discord.VoiceState): pass -- 2.45.2 From ffad565520c7b50ba26e0e7ebbe708d1b9c7199a Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 19:06:04 +0100 Subject: [PATCH 088/113] Added on_private_channel_update event abc --- src/modules_core/abc/events/on_private_channel_update_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_private_channel_update_abc.py b/src/modules_core/abc/events/on_private_channel_update_abc.py index 9216695..6c37031 100644 --- a/src/modules_core/abc/events/on_private_channel_update_abc.py +++ b/src/modules_core/abc/events/on_private_channel_update_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnPrivateChannelUpdateABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_private_channel_update(self, before: discord.GroupChannel, after: discord.GroupChannel): pass + \ No newline at end of file -- 2.45.2 From 7780b43e11362113918c18943dde2d7b261fcf42 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 20 Nov 2021 19:06:45 +0100 Subject: [PATCH 089/113] Removed line break --- src/modules_core/abc/events/on_member_ban_abc.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/modules_core/abc/events/on_member_ban_abc.py b/src/modules_core/abc/events/on_member_ban_abc.py index 4410fad..45e3f0d 100644 --- a/src/modules_core/abc/events/on_member_ban_abc.py +++ b/src/modules_core/abc/events/on_member_ban_abc.py @@ -8,5 +8,4 @@ class OnMemberBanABC(ABC): def __init__(self): pass @abstractmethod - async def on_member_ban(self, guild: discord.Guild, - user: discord.User): pass + async def on_member_ban(self, guild: discord.Guild, user: discord.User): pass -- 2.45.2 From 2ab2ef377608b77b0b9e2555ee38a1b2ef581ccb Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 19:07:00 +0100 Subject: [PATCH 090/113] Added on_private_channel_pins_update event abc --- .../abc/events/on_private_channel_pins_update_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_private_channel_pins_update_abc.py b/src/modules_core/abc/events/on_private_channel_pins_update_abc.py index c5a82da..7d9da09 100644 --- a/src/modules_core/abc/events/on_private_channel_pins_update_abc.py +++ b/src/modules_core/abc/events/on_private_channel_pins_update_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnPrivateChannelPinsUpdateABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_private_channel_pins_update(self, channel: discord.abc.PrivateChannel, list_pin: Optional[datetime]): pass + \ No newline at end of file -- 2.45.2 From 5e646d394b83df8828528b9eb3824f6191346de2 Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 19:08:36 +0100 Subject: [PATCH 091/113] Added on_guild_channel_delete event abc --- src/modules_core/abc/events/on_guild_channel_delete_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_guild_channel_delete_abc.py b/src/modules_core/abc/events/on_guild_channel_delete_abc.py index 73dd145..c34e7f1 100644 --- a/src/modules_core/abc/events/on_guild_channel_delete_abc.py +++ b/src/modules_core/abc/events/on_guild_channel_delete_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnGuildChannelDeleteABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_guild_channel_delete(self, channel: discord.abc.GuildChannel): pass + \ No newline at end of file -- 2.45.2 From 76642112ab8d3d13032b14ba2fe149ce8be8339e Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 19:09:40 +0100 Subject: [PATCH 092/113] Added on_guild_channel_update event abc --- src/modules_core/abc/events/on_guild_channel_update_abc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules_core/abc/events/on_guild_channel_update_abc.py b/src/modules_core/abc/events/on_guild_channel_update_abc.py index fb3be1a..17a8634 100644 --- a/src/modules_core/abc/events/on_guild_channel_update_abc.py +++ b/src/modules_core/abc/events/on_guild_channel_update_abc.py @@ -1,7 +1,11 @@ from abc import ABC, abstractmethod +import discord class OnGuildChannelUpdateABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_guild_channel_update(self, before: discord.abc.GuildChannel, after: discord.abc.GuildChannel): pass -- 2.45.2 From c9a5f648a2f318c880a590c70dc37c2d249375ab Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 19:10:41 +0100 Subject: [PATCH 093/113] Added on_guild_channel_pins_update event abc --- .../abc/events/on_guild_channel_pins_update_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_guild_channel_pins_update_abc.py b/src/modules_core/abc/events/on_guild_channel_pins_update_abc.py index 4dcbcb3..010e82f 100644 --- a/src/modules_core/abc/events/on_guild_channel_pins_update_abc.py +++ b/src/modules_core/abc/events/on_guild_channel_pins_update_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnGuildChannelPinsUpdateABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_guild_channel_pins_update(self, channel: discord.abc.GuildChannel, list_pin: Optional[datetime]): pass + -- 2.45.2 From 73fedd31dce779417131863ee85bf3e6865d6049 Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 19:12:09 +0100 Subject: [PATCH 094/113] Added on_guild_integration_update event abc --- .../abc/events/on_guild_integrations_update_abc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules_core/abc/events/on_guild_integrations_update_abc.py b/src/modules_core/abc/events/on_guild_integrations_update_abc.py index b385d32..9e5f4f0 100644 --- a/src/modules_core/abc/events/on_guild_integrations_update_abc.py +++ b/src/modules_core/abc/events/on_guild_integrations_update_abc.py @@ -1,7 +1,12 @@ from abc import ABC, abstractmethod +import discord class OnGuildIntegrationsUpdateABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + async def on_guild_integrations_update(self, guild: discord.Guild): pass + \ No newline at end of file -- 2.45.2 From 00a0c182bebd1e59dc2bf2723ded7f494f13323b Mon Sep 17 00:00:00 2001 From: Cora Cordes Date: Sat, 20 Nov 2021 19:42:06 +0100 Subject: [PATCH 095/113] Removed unused lines --- src/modules_core/service/module_service.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index abb1f76..0cc4241 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -30,7 +30,6 @@ class ModuleService(ModuleServiceABC): self._logger.debug(__name__, 'Start on_ready modules') modules = self._modules.where(lambda m: issubclass(m, OnReadyABC)) for module_type in modules: - module_type = module_type module: OnReadyABC = self._services.get_service(module_type) await module.on_ready() self._logger.debug(__name__, 'Stopped on_ready modules') @@ -46,7 +45,6 @@ class ModuleService(ModuleServiceABC): self._logger.debug(__name__, 'Start on_message modules') modules = self._modules.where(lambda m: issubclass(m, OnMessageABC)) for module_type in modules: - module_type = module_type module: OnMessageABC = self._services.get_service(module_type) await module.on_message(message) self._logger.debug(__name__, f'Stopped on_message modules') -- 2.45.2 From 0b5f47ab8aa8666400701e268febd8eb3a9b2099 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 22 Nov 2021 17:42:57 +0100 Subject: [PATCH 096/113] Improved bot banner --- src/modules/boot_log/boot_log.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/boot_log/boot_log.py b/src/modules/boot_log/boot_log.py index e703255..83e6feb 100644 --- a/src/modules/boot_log/boot_log.py +++ b/src/modules/boot_log/boot_log.py @@ -5,6 +5,7 @@ from discord import guild from async_timeout import asyncio from cpl_core.configuration import ConfigurationABC from cpl_core.console import Console +from cpl_core.environment import ApplicationEnvironmentABC from cpl_core.logging import LoggerABC, LoggingLevelEnum, LoggingSettings from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.abc.message_service_abc import MessageServiceABC @@ -18,12 +19,14 @@ class BootLog(ModuleABC, OnReadyABC): def __init__( self, config: ConfigurationABC, + env: ApplicationEnvironmentABC, logging_st: LoggingSettings, logger: LoggerABC, bot: BotServiceABC, message_service: MessageServiceABC ): self._config = config + self._env = env self._logging_st = logging_st self._logger = logger @@ -55,7 +58,7 @@ class BootLog(ModuleABC, OnReadyABC): self._logger.header(f'{self._bot.user.name}:') if self._logging_st.console.value >= LoggingLevelEnum.INFO.value: - Console.banner(self._bot.user.name) + Console.banner(self._env.application_name if self._env.application_name != '' else 'Gismo') for g in self._bot.guilds: g: guild = g -- 2.45.2 From 9ebbd7ccf795c626c5075233d0f5e0ab34204465 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 22 Nov 2021 17:48:32 +0100 Subject: [PATCH 097/113] Removed unused import --- src/gismo/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gismo/main.py b/src/gismo/main.py index 8cc06c0..4717405 100644 --- a/src/gismo/main.py +++ b/src/gismo/main.py @@ -1,7 +1,7 @@ import asyncio from typing import Optional -from cpl_core.application import ApplicationABC, ApplicationBuilder +from cpl_core.application import ApplicationBuilder from gismo.application import Gismo from gismo.startup import Startup -- 2.45.2 From be810a65334dfc7c48d1657736a7c8e704edf7cb Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 22 Nov 2021 20:08:46 +0100 Subject: [PATCH 098/113] Improved event handling with commands.Cog.listener --- src/gismo_core/abc/bot_service_abc.py | 3 - src/gismo_core/service/bot_service.py | 10 +-- src/modules/boot_log/boot_log.py | 2 +- src/modules_core/service/module_service.py | 80 +++++++++------------- 4 files changed, 37 insertions(+), 58 deletions(-) diff --git a/src/gismo_core/abc/bot_service_abc.py b/src/gismo_core/abc/bot_service_abc.py index c842923..c33aaf2 100644 --- a/src/gismo_core/abc/bot_service_abc.py +++ b/src/gismo_core/abc/bot_service_abc.py @@ -14,6 +14,3 @@ class BotServiceABC(ABC, commands.Bot): @abstractmethod async def stop_async(self): pass - - @abstractmethod - async def on_message(self, message: discord.Message): pass diff --git a/src/gismo_core/service/bot_service.py b/src/gismo_core/service/bot_service.py index 2f26e86..881743d 100644 --- a/src/gismo_core/service/bot_service.py +++ b/src/gismo_core/service/bot_service.py @@ -8,11 +8,12 @@ from gismo_core.configuration.bot_settings import BotSettings from gismo_core.configuration.discord_settings import DiscordSettings from gismo_core.configuration.server_settings import ServerSettings from modules_core.abc.module_service_abc import ModuleServiceABC +from modules_core.service.module_service import ModuleService class BotService(BotServiceABC, commands.Bot): - def __init__(self, config: ConfigurationABC, logger: LoggerABC, modules: ModuleServiceABC, discord_settings: DiscordSettings, bot_settings: BotSettings): + def __init__(self, config: ConfigurationABC, logger: LoggerABC, modules: ModuleService, discord_settings: DiscordSettings, bot_settings: BotSettings): # services self._config = config self._logger = logger @@ -27,6 +28,9 @@ class BotService(BotServiceABC, commands.Bot): async def start_async(self): self._logger.trace(__name__, 'Try to connect to discord') + + self.add_cog(self._modules) + await self.start(self._discord_settings.token) # continue at on_ready @@ -50,7 +54,3 @@ class BotService(BotServiceABC, commands.Bot): await self._modules.on_ready() - - async def on_message(self, message: discord.Message): - self._logger.debug(__name__, f'Received message:\n{message}:\n{message.content}') - await self._modules.on_message(message) diff --git a/src/modules/boot_log/boot_log.py b/src/modules/boot_log/boot_log.py index 83e6feb..141ae5d 100644 --- a/src/modules/boot_log/boot_log.py +++ b/src/modules/boot_log/boot_log.py @@ -33,7 +33,7 @@ class BootLog(ModuleABC, OnReadyABC): self._bot = bot self._message_service = message_service - ModuleABC.__init__(self) + # ModuleABC.__init__(self) self._logger.trace(__name__, f'Module {type(self)} loaded') async def on_ready(self): diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index 0cc4241..48b011a 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -1,3 +1,4 @@ +from abc import ABCMeta from datetime import datetime from typing import Optional, Sequence, Union import discord @@ -13,7 +14,10 @@ from modules_core.abc.events.on_message_abc import OnMessageABC from modules_core.abc.events.on_ready_abc import OnReadyABC -class ModuleService(ModuleServiceABC): +class _MetaCogABC(ABCMeta, commands.CogMeta): pass + + +class ModuleService(ModuleServiceABC, commands.Cog, metaclass=_MetaCogABC): def __init__(self, logger: LoggerABC, services: ServiceProviderABC, env: ApplicationEnvironmentABC): self._logger = logger @@ -38,10 +42,11 @@ class ModuleService(ModuleServiceABC): async def on_error(self, event: str, *args, **kwargs): pass - async def on_typing(self, channel: discord.abc.Messageable, - user: Union[discord.User, discord.Member], when: datetime): pass + async def on_typing(self, channel: discord.abc.Messageable, user: Union[discord.User, discord.Member], when: datetime): pass + @commands.Cog.listener() async def on_message(self, message: discord.Message): + self._logger.debug(__name__, f'Received message:\n{message}:\n{message.content}') self._logger.debug(__name__, 'Start on_message modules') modules = self._modules.where(lambda m: issubclass(m, OnMessageABC)) for module_type in modules: @@ -53,43 +58,31 @@ class ModuleService(ModuleServiceABC): async def on_bulk_message_delete(self, message: discord.Message): pass - async def on_message_edit( - self, before: discord.Message, after: discord.Message): pass + async def on_message_edit(self, before: discord.Message, after: discord.Message): pass - async def on_reaction_add( - self, reaction: discord.Reaction, user: discord.User): pass + async def on_reaction_add(self, reaction: discord.Reaction, user: discord.User): pass - async def on_reaction_remove( - self, reaction: discord.Reaction, user: discord.User): pass + async def on_reaction_remove(self, reaction: discord.Reaction, user: discord.User): pass - async def on_reaction_clear( - self, message: discord.Message, reactions: list[discord.Reaction]): pass + async def on_reaction_clear(self, message: discord.Message, reactions: list[discord.Reaction]): pass async def on_reaction_clear_emoji(self, reaction: discord.Reaction): pass - async def on_private_channel_delete( - self, channel: discord.abc.PrivateChannel): pass + async def on_private_channel_delete(self, channel: discord.abc.PrivateChannel): pass - async def on_private_channel_create( - self, channel: discord.abc.PrivateChannel): pass + async def on_private_channel_create(self, channel: discord.abc.PrivateChannel): pass - async def on_private_channel_update( - self, before: discord.GroupChannel, after: discord.GroupChannel): pass + async def on_private_channel_update(self, before: discord.GroupChannel, after: discord.GroupChannel): pass - async def on_private_channel_pins_update( - self, channel: discord.abc.PrivateChannel, list_pin: Optional[datetime]): pass + async def on_private_channel_pins_update(self, channel: discord.abc.PrivateChannel, list_pin: Optional[datetime]): pass - async def on_guild_channel_delete( - self, channel: discord.abc.GuildChannel): pass + async def on_guild_channel_delete(self, channel: discord.abc.GuildChannel): pass - async def on_guild_channel_create( - self, channel: discord.abc.GuildChannel): pass + async def on_guild_channel_create(self, channel: discord.abc.GuildChannel): pass - async def on_guild_channel_update( - self, before: discord.abc.GuildChannel, after: discord.abc.GuildChannel): pass + async def on_guild_channel_update(self, before: discord.abc.GuildChannel, after: discord.abc.GuildChannel): pass - async def on_guild_channel_pins_update( - self, channel: discord.abc.GuildChannel, list_pin: Optional[datetime]): pass + async def on_guild_channel_pins_update(self, channel: discord.abc.GuildChannel, list_pin: Optional[datetime]): pass async def on_guild_integrations_update(self, guild: discord.Guild): pass @@ -99,41 +92,33 @@ class ModuleService(ModuleServiceABC): async def on_member_remove(self, member: discord.Member): pass - async def on_member_update( - self, before: discord.Member, after: discord.Member): pass + async def on_member_update(self, before: discord.Member, after: discord.Member): pass - async def on_user_update(self, before: discord.User, - after: discord.User): pass + async def on_user_update(self, before: discord.User, after: discord.User): pass async def on_guild_join(self, guild: discord.Guild): pass async def on_guild_remove(self, guild: discord.Guild): pass - async def on_guild_update( - self, before: discord.Guild, after: discord.Guild): pass + async def on_guild_update(self, before: discord.Guild, after: discord.Guild): pass async def on_guild_role_create(self, role: discord.Role): pass async def on_guild_role_delete(self, role: discord.Role): pass - async def on_guild_role_update( - self, before: discord.Role, after: discord.Role): pass + async def on_guild_role_update(self, before: discord.Role, after: discord.Role): pass - async def on_guild_emojis_update( - self, guild: discord.Guild, before: Sequence[discord.Emoji], after: Sequence[discord.Emoji]): pass + async def on_guild_emojis_update(self, guild: discord.Guild, before: Sequence[discord.Emoji], after: Sequence[discord.Emoji]): pass async def on_guild_available(self, guild: discord.Guild): pass async def on_guild_unavailable(self, guild: discord.Guild): pass - async def on_voice_state_update( - self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState): pass + async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState): pass - async def on_member_ban(self, guild: discord.Guild, - user: discord.User): pass + async def on_member_ban(self, guild: discord.Guild, user: discord.User): pass - async def on_member_unban( - self, guild: discord.Guild, user: discord.User): pass + async def on_member_unban(self, guild: discord.Guild, user: discord.User): pass async def on_invite_create(self, invite: discord.Invite): pass @@ -142,14 +127,11 @@ class ModuleService(ModuleServiceABC): async def on_group_join( self, chhanel: discord.GroupChannel, user: discord.User): pass - async def on_group_remove( - self, chhanel: discord.GroupChannel, user: discord.User): pass + async def on_group_remove(self, chhanel: discord.GroupChannel, user: discord.User): pass async def on_relationship_add( self, relationship: discord.Relationship): pass - async def on_relationship_remove( - self, relationship: discord.Relationship): pass + async def on_relationship_remove(self, relationship: discord.Relationship): pass - async def on_relationship_update( - self, before: discord.Relationship, after: discord.Relationship): pass + async def on_relationship_update(self, before: discord.Relationship, after: discord.Relationship): pass -- 2.45.2 From 112b9d6208db79932df9cea1e4586a6d6ebf9f6f Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 22 Nov 2021 21:11:45 +0100 Subject: [PATCH 099/113] Added logic to handle event priority --- src/gismo/gismo.json | 3 +-- src/modules/boot_log/boot_log.py | 10 ++++++++-- src/modules_core/abc/module_abc.py | 3 +++ src/modules_core/service/module_service.py | 19 +++++++++++++------ 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/gismo/gismo.json b/src/gismo/gismo.json index 95a329a..b8a447a 100644 --- a/src/gismo/gismo.json +++ b/src/gismo/gismo.json @@ -18,8 +18,7 @@ "Dependencies": [ "sh_cpl-core>=2021.10.2", "sh_cpl-query>=2021.10.2", - "discord.py==1.7.3", - "nest-asyncio==1.5.1" + "discord.py==1.7.3" ], "PythonVersion": ">=3.9.2", "PythonPath": { diff --git a/src/modules/boot_log/boot_log.py b/src/modules/boot_log/boot_log.py index 141ae5d..b0b95b7 100644 --- a/src/modules/boot_log/boot_log.py +++ b/src/modules/boot_log/boot_log.py @@ -32,10 +32,16 @@ class BootLog(ModuleABC, OnReadyABC): self._logger = logger self._bot = bot self._message_service = message_service - - # ModuleABC.__init__(self) + + self._priorities = { + OnReadyABC: 10 + } + self._logger.trace(__name__, f'Module {type(self)} loaded') + def get_priority(self, t: type) -> int: + return self._priorities[t] + async def on_ready(self): self._logger.debug(__name__, f'Module {type(self)} started') try: diff --git a/src/modules_core/abc/module_abc.py b/src/modules_core/abc/module_abc.py index a9645a7..d377d4b 100644 --- a/src/modules_core/abc/module_abc.py +++ b/src/modules_core/abc/module_abc.py @@ -6,3 +6,6 @@ class ModuleABC(ABC): @abstractmethod def __init__(self): pass + + @abstractmethod + def get_priority(self, t: type) -> int: pass diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index 48b011a..57bd415 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -1,4 +1,4 @@ -from abc import ABCMeta +from abc import ABC, ABCMeta from datetime import datetime from typing import Optional, Sequence, Union import discord @@ -25,17 +25,24 @@ class ModuleService(ModuleServiceABC, commands.Cog, metaclass=_MetaCogABC): self._env = env self._modules: List[ModuleABC] = List() self._modules.extend(ModuleABC.__subclasses__()) - + + def _get_modules(self, t: type) -> List[ModuleABC]: + module_types = self._modules.where(lambda m: issubclass(m, t)) + modules = List(t) + for module_type in module_types: + modules.append(self._services.get_service(module_type)) + + return modules.order_by(lambda m: m.get_priority(t)) + async def on_connect(self): pass async def on_disconnect(self): pass async def on_ready(self): - self._logger.debug(__name__, 'Start on_ready modules') - modules = self._modules.where(lambda m: issubclass(m, OnReadyABC)) - for module_type in modules: - module: OnReadyABC = self._services.get_service(module_type) + self._logger.debug(__name__, f'Start on_ready modules') + for module in self._get_modules(OnReadyABC): await module.on_ready() + self._logger.debug(__name__, 'Stopped on_ready modules') async def on_resume(self): pass -- 2.45.2 From 5a91e31964682ff531947a162fc1337029a3fa16 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 22 Nov 2021 21:16:09 +0100 Subject: [PATCH 100/113] Improved event listeners --- src/modules_core/service/module_service.py | 75 +++++++++++++++++++--- 1 file changed, 65 insertions(+), 10 deletions(-) diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index 57bd415..ab4d816 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -1,17 +1,19 @@ from abc import ABC, ABCMeta from datetime import datetime from typing import Optional, Sequence, Union -import discord -from discord.ext import commands +import discord from cpl_core.dependency_injection import ServiceProviderABC from cpl_core.environment import ApplicationEnvironmentABC from cpl_core.logging import LoggerABC from cpl_query.extension import List -from modules_core.abc.module_abc import ModuleABC -from modules_core.abc.module_service_abc import ModuleServiceABC +from discord.ext import commands +from modules_core.abc.events.on_connect_abc import OnConnectABC +from modules_core.abc.events.on_disconnect_abc import OnDisconnectABC from modules_core.abc.events.on_message_abc import OnMessageABC from modules_core.abc.events.on_ready_abc import OnReadyABC +from modules_core.abc.module_abc import ModuleABC +from modules_core.abc.module_service_abc import ModuleServiceABC class _MetaCogABC(ABCMeta, commands.CogMeta): pass @@ -34,9 +36,21 @@ class ModuleService(ModuleServiceABC, commands.Cog, metaclass=_MetaCogABC): return modules.order_by(lambda m: m.get_priority(t)) - async def on_connect(self): pass + @commands.Cog.listener() + async def on_connect(self): + self._logger.debug(__name__, f'Start on_connect modules') + for module in self._get_modules(OnConnectABC): + await module.on_connect() + + self._logger.debug(__name__, 'Stopped on_connect modules') - async def on_disconnect(self): pass + @commands.Cog.listener() + async def on_disconnect(self): + self._logger.debug(__name__, f'Start on_disconnect modules') + for module in self._get_modules(OnDisconnectABC): + await module.on_disconnect() + + self._logger.debug(__name__, 'Stopped on_disconnect modules') async def on_ready(self): self._logger.debug(__name__, f'Start on_ready modules') @@ -45,10 +59,13 @@ class ModuleService(ModuleServiceABC, commands.Cog, metaclass=_MetaCogABC): self._logger.debug(__name__, 'Stopped on_ready modules') + @commands.Cog.listener() async def on_resume(self): pass + @commands.Cog.listener() async def on_error(self, event: str, *args, **kwargs): pass + @commands.Cog.listener() async def on_typing(self, channel: discord.abc.Messageable, user: Union[discord.User, discord.Member], when: datetime): pass @commands.Cog.listener() @@ -61,84 +78,122 @@ class ModuleService(ModuleServiceABC, commands.Cog, metaclass=_MetaCogABC): await module.on_message(message) self._logger.debug(__name__, f'Stopped on_message modules') + @commands.Cog.listener() async def on_message_delete(self, message: discord.Message): pass + @commands.Cog.listener() async def on_bulk_message_delete(self, message: discord.Message): pass + @commands.Cog.listener() async def on_message_edit(self, before: discord.Message, after: discord.Message): pass + @commands.Cog.listener() async def on_reaction_add(self, reaction: discord.Reaction, user: discord.User): pass + @commands.Cog.listener() async def on_reaction_remove(self, reaction: discord.Reaction, user: discord.User): pass + @commands.Cog.listener() async def on_reaction_clear(self, message: discord.Message, reactions: list[discord.Reaction]): pass + @commands.Cog.listener() async def on_reaction_clear_emoji(self, reaction: discord.Reaction): pass + @commands.Cog.listener() async def on_private_channel_delete(self, channel: discord.abc.PrivateChannel): pass + @commands.Cog.listener() async def on_private_channel_create(self, channel: discord.abc.PrivateChannel): pass + @commands.Cog.listener() async def on_private_channel_update(self, before: discord.GroupChannel, after: discord.GroupChannel): pass + @commands.Cog.listener() async def on_private_channel_pins_update(self, channel: discord.abc.PrivateChannel, list_pin: Optional[datetime]): pass + @commands.Cog.listener() async def on_guild_channel_delete(self, channel: discord.abc.GuildChannel): pass + @commands.Cog.listener() async def on_guild_channel_create(self, channel: discord.abc.GuildChannel): pass + @commands.Cog.listener() async def on_guild_channel_update(self, before: discord.abc.GuildChannel, after: discord.abc.GuildChannel): pass + @commands.Cog.listener() async def on_guild_channel_pins_update(self, channel: discord.abc.GuildChannel, list_pin: Optional[datetime]): pass + @commands.Cog.listener() async def on_guild_integrations_update(self, guild: discord.Guild): pass + @commands.Cog.listener() async def on_webhooks_update(self, channel: discord.abc.GuildChannel): pass + @commands.Cog.listener() async def on_member_join(self, member: discord.Member): pass + @commands.Cog.listener() async def on_member_remove(self, member: discord.Member): pass + @commands.Cog.listener() async def on_member_update(self, before: discord.Member, after: discord.Member): pass + @commands.Cog.listener() async def on_user_update(self, before: discord.User, after: discord.User): pass + @commands.Cog.listener() async def on_guild_join(self, guild: discord.Guild): pass + @commands.Cog.listener() async def on_guild_remove(self, guild: discord.Guild): pass + @commands.Cog.listener() async def on_guild_update(self, before: discord.Guild, after: discord.Guild): pass + @commands.Cog.listener() async def on_guild_role_create(self, role: discord.Role): pass + @commands.Cog.listener() async def on_guild_role_delete(self, role: discord.Role): pass + @commands.Cog.listener() async def on_guild_role_update(self, before: discord.Role, after: discord.Role): pass + @commands.Cog.listener() async def on_guild_emojis_update(self, guild: discord.Guild, before: Sequence[discord.Emoji], after: Sequence[discord.Emoji]): pass + @commands.Cog.listener() async def on_guild_available(self, guild: discord.Guild): pass + @commands.Cog.listener() async def on_guild_unavailable(self, guild: discord.Guild): pass + @commands.Cog.listener() async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState): pass + @commands.Cog.listener() async def on_member_ban(self, guild: discord.Guild, user: discord.User): pass + @commands.Cog.listener() async def on_member_unban(self, guild: discord.Guild, user: discord.User): pass + @commands.Cog.listener() async def on_invite_create(self, invite: discord.Invite): pass + @commands.Cog.listener() async def on_invite_delete(self, invite: discord.Invite): pass - async def on_group_join( - self, chhanel: discord.GroupChannel, user: discord.User): pass + @commands.Cog.listener() + async def on_group_join(self, chhanel: discord.GroupChannel, user: discord.User): pass + @commands.Cog.listener() async def on_group_remove(self, chhanel: discord.GroupChannel, user: discord.User): pass - async def on_relationship_add( - self, relationship: discord.Relationship): pass + @commands.Cog.listener() + async def on_relationship_add(self, relationship: discord.Relationship): pass + @commands.Cog.listener() async def on_relationship_remove(self, relationship: discord.Relationship): pass + @commands.Cog.listener() async def on_relationship_update(self, before: discord.Relationship, after: discord.Relationship): pass -- 2.45.2 From a5f710177e0cd72951fb2343a2b73e317028d0c8 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 23 Nov 2021 16:04:03 +0100 Subject: [PATCH 101/113] Changed banner --- src/gismo_core/service/bot_service.py | 23 +++++++++++++++++++---- src/modules/boot_log/boot_log.py | 18 +++--------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/gismo_core/service/bot_service.py b/src/gismo_core/service/bot_service.py index 881743d..becdab4 100644 --- a/src/gismo_core/service/bot_service.py +++ b/src/gismo_core/service/bot_service.py @@ -1,8 +1,9 @@ import discord -from discord.ext import commands - from cpl_core.configuration import ConfigurationABC -from cpl_core.logging import LoggerABC +from cpl_core.console import Console +from cpl_core.environment import ApplicationEnvironmentABC +from cpl_core.logging import LoggerABC, LoggingLevelEnum, LoggingSettings +from discord.ext import commands from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.configuration.bot_settings import BotSettings from gismo_core.configuration.discord_settings import DiscordSettings @@ -13,11 +14,22 @@ from modules_core.service.module_service import ModuleService class BotService(BotServiceABC, commands.Bot): - def __init__(self, config: ConfigurationABC, logger: LoggerABC, modules: ModuleService, discord_settings: DiscordSettings, bot_settings: BotSettings): + def __init__( + self, + config: ConfigurationABC, + logger: LoggerABC, + modules: ModuleService, + discord_settings: DiscordSettings, + bot_settings: BotSettings, + env: ApplicationEnvironmentABC, + logging_st: LoggingSettings, + ): # services self._config = config self._logger = logger self._modules = modules + self._env = env + self._logging_st = logging_st # settings self._discord_settings = discord_settings @@ -52,5 +64,8 @@ class BotService(BotServiceABC, commands.Bot): self._config.add_configuration(f'DSERVER_{server.id}', server) self._logger.trace(__name__, f'Loaded config for server: {server.id}') + self._logger.header(f'{self.user.name}:') + if self._logging_st.console.value >= LoggingLevelEnum.INFO.value: + Console.banner(self._env.application_name if self._env.application_name != '' else 'Gismo') await self._modules.on_ready() diff --git a/src/modules/boot_log/boot_log.py b/src/modules/boot_log/boot_log.py index b0b95b7..587c743 100644 --- a/src/modules/boot_log/boot_log.py +++ b/src/modules/boot_log/boot_log.py @@ -1,17 +1,13 @@ from datetime import datetime -import discord -from discord import guild -from async_timeout import asyncio from cpl_core.configuration import ConfigurationABC -from cpl_core.console import Console -from cpl_core.environment import ApplicationEnvironmentABC -from cpl_core.logging import LoggerABC, LoggingLevelEnum, LoggingSettings +from cpl_core.logging import LoggerABC +from discord import guild from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.abc.message_service_abc import MessageServiceABC from gismo_core.configuration.server_settings import ServerSettings -from modules_core.abc.module_abc import ModuleABC from modules_core.abc.events.on_ready_abc import OnReadyABC +from modules_core.abc.module_abc import ModuleABC class BootLog(ModuleABC, OnReadyABC): @@ -19,15 +15,11 @@ class BootLog(ModuleABC, OnReadyABC): def __init__( self, config: ConfigurationABC, - env: ApplicationEnvironmentABC, - logging_st: LoggingSettings, logger: LoggerABC, bot: BotServiceABC, message_service: MessageServiceABC ): self._config = config - self._env = env - self._logging_st = logging_st self._logger = logger self._bot = bot @@ -62,10 +54,6 @@ class BootLog(ModuleABC, OnReadyABC): self._logger.error(__name__, 'Init time calculation failed', e) return - self._logger.header(f'{self._bot.user.name}:') - if self._logging_st.console.value >= LoggingLevelEnum.INFO.value: - Console.banner(self._env.application_name if self._env.application_name != '' else 'Gismo') - for g in self._bot.guilds: g: guild = g self._logger.debug(__name__, f'Server detected: {g.id}') -- 2.45.2 From 3806c36571bcd4fb47a12d56ff287b86bdb1d2af Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 23 Nov 2021 16:46:20 +0100 Subject: [PATCH 102/113] Improved event handling --- .vscode/settings.json | 1 + src/modules/boot_log/boot_log.py | 4 ++- src/modules_core/service/module_service.py | 35 +++++++++------------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index e8a8578..4e78d7c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -19,5 +19,6 @@ "titleBar.inactiveForeground": "#15202b99" }, "peacock.color": "#61dafb", + "python.pythonPath": "${workspaceRoot}/venv/bin/python", "python.defaultInterpreterPath": "${workspaceRoot}/venv/bin/python", } \ No newline at end of file diff --git a/src/modules/boot_log/boot_log.py b/src/modules/boot_log/boot_log.py index 587c743..4d72b69 100644 --- a/src/modules/boot_log/boot_log.py +++ b/src/modules/boot_log/boot_log.py @@ -1,8 +1,10 @@ from datetime import datetime +import discord from cpl_core.configuration import ConfigurationABC from cpl_core.logging import LoggerABC from discord import guild + from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.abc.message_service_abc import MessageServiceABC from gismo_core.configuration.server_settings import ServerSettings @@ -72,4 +74,4 @@ class BootLog(ModuleABC, OnReadyABC): server_settings.login_message.format(init_time) ) - self._logger.trace(__name__, f'Module {type(self)} stopped') + self._logger.trace(__name__, f'Module {type(self)} stopped') \ No newline at end of file diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index ab4d816..5fa4b74 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -6,6 +6,7 @@ import discord from cpl_core.dependency_injection import ServiceProviderABC from cpl_core.environment import ApplicationEnvironmentABC from cpl_core.logging import LoggerABC +from cpl_core.utils import String from cpl_query.extension import List from discord.ext import commands from modules_core.abc.events.on_connect_abc import OnConnectABC @@ -36,28 +37,25 @@ class ModuleService(ModuleServiceABC, commands.Cog, metaclass=_MetaCogABC): return modules.order_by(lambda m: m.get_priority(t)) + async def _handle_event(self, event: type, *args): + self._logger.debug(__name__, f'Start {event} modules') + func_name = String.convert_to_snake_case(event.__name__.split('ABC')[0]) + for module in self._get_modules(event): + func = getattr(module, func_name) + await func(*args) + + self._logger.debug(__name__, f'Stopped {event} modules') + @commands.Cog.listener() async def on_connect(self): - self._logger.debug(__name__, f'Start on_connect modules') - for module in self._get_modules(OnConnectABC): - await module.on_connect() - - self._logger.debug(__name__, 'Stopped on_connect modules') + await self._handle_event(OnConnectABC) @commands.Cog.listener() async def on_disconnect(self): - self._logger.debug(__name__, f'Start on_disconnect modules') - for module in self._get_modules(OnDisconnectABC): - await module.on_disconnect() - - self._logger.debug(__name__, 'Stopped on_disconnect modules') + await self._handle_event(OnDisconnectABC) async def on_ready(self): - self._logger.debug(__name__, f'Start on_ready modules') - for module in self._get_modules(OnReadyABC): - await module.on_ready() - - self._logger.debug(__name__, 'Stopped on_ready modules') + await self._handle_event(OnReadyABC) @commands.Cog.listener() async def on_resume(self): pass @@ -71,12 +69,7 @@ class ModuleService(ModuleServiceABC, commands.Cog, metaclass=_MetaCogABC): @commands.Cog.listener() async def on_message(self, message: discord.Message): self._logger.debug(__name__, f'Received message:\n{message}:\n{message.content}') - self._logger.debug(__name__, 'Start on_message modules') - modules = self._modules.where(lambda m: issubclass(m, OnMessageABC)) - for module_type in modules: - module: OnMessageABC = self._services.get_service(module_type) - await module.on_message(message) - self._logger.debug(__name__, f'Stopped on_message modules') + await self._handle_event(OnMessageABC, message) @commands.Cog.listener() async def on_message_delete(self, message: discord.Message): pass -- 2.45.2 From a8551f2f95310671bb90ffbd1220c6781e41f4bd Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 23 Nov 2021 17:18:06 +0100 Subject: [PATCH 103/113] Added event redirect to modules --- .../abc/events/on_bulk_message_delete_abc.py | 2 +- src/modules_core/abc/module_service_abc.py | 2 +- src/modules_core/service/module_service.py | 227 ++++++++++++++---- 3 files changed, 184 insertions(+), 47 deletions(-) diff --git a/src/modules_core/abc/events/on_bulk_message_delete_abc.py b/src/modules_core/abc/events/on_bulk_message_delete_abc.py index 15e90bb..15a19c6 100644 --- a/src/modules_core/abc/events/on_bulk_message_delete_abc.py +++ b/src/modules_core/abc/events/on_bulk_message_delete_abc.py @@ -8,4 +8,4 @@ class OnBulkMessageDeleteABC(ABC): def __init__(self): pass @abstractmethod - async def on_bulk_message_delete(self, message: discord.Message): pass + async def on_bulk_message_delete(self, messages: list[discord.Message]): pass diff --git a/src/modules_core/abc/module_service_abc.py b/src/modules_core/abc/module_service_abc.py index 50432e2..407868a 100644 --- a/src/modules_core/abc/module_service_abc.py +++ b/src/modules_core/abc/module_service_abc.py @@ -35,7 +35,7 @@ class ModuleServiceABC(ABC): async def on_message_delete(self, message: discord.Message): pass @abstractmethod - async def on_bulk_message_delete(self, message: discord.Message): pass + async def on_bulk_message_delete(self, messages: list[discord.Message]): pass @abstractmethod async def on_message_edit(self, before: discord.Message, after: discord.Message): pass diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index 5fa4b74..05fda32 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -9,10 +9,52 @@ from cpl_core.logging import LoggerABC from cpl_core.utils import String from cpl_query.extension import List from discord.ext import commands +from modules_core.abc.events.on_bulk_message_delete_abc import OnBulkMessageDeleteABC from modules_core.abc.events.on_connect_abc import OnConnectABC from modules_core.abc.events.on_disconnect_abc import OnDisconnectABC +from modules_core.abc.events.on_group_join_abc import OnGroupJoinABC +from modules_core.abc.events.on_group_remove_abc import OnGroupRemoveABC +from modules_core.abc.events.on_guild_available_abc import OnGuildAvailableABC +from modules_core.abc.events.on_guild_channel_create_abc import OnGuildChannelCreateABC +from modules_core.abc.events.on_guild_channel_delete_abc import OnGuildChannelDeleteABC +from modules_core.abc.events.on_guild_channel_pins_update_abc import OnGuildChannelPinsUpdateABC +from modules_core.abc.events.on_guild_channel_update_abc import OnGuildChannelUpdateABC +from modules_core.abc.events.on_guild_emojis_update_abc import OnGuildEmojisUpdateABC +from modules_core.abc.events.on_guild_integrations_update_abc import OnGuildIntegrationsUpdateABC +from modules_core.abc.events.on_guild_join_abc import OnGuildJoinABC +from modules_core.abc.events.on_guild_remove_abc import OnGuildRemoveABC +from modules_core.abc.events.on_guild_role_create_abc import OnGuildRoleCreateABC +from modules_core.abc.events.on_guild_role_delete_abc import OnGuildRoleDeleteABC +from modules_core.abc.events.on_guild_role_update_abc import OnGuildRoleUpdateABC +from modules_core.abc.events.on_guild_unavailable_abc import OnGuildUnavailableABC +from modules_core.abc.events.on_guild_update_abc import OnGuildUpdateABC +from modules_core.abc.events.on_invite_create_abc import OnInviteCreateABC +from modules_core.abc.events.on_invite_delete_abc import OnInviteDeleteABC +from modules_core.abc.events.on_member_ban_abc import OnMemberBanABC +from modules_core.abc.events.on_member_join_abc import OnMemberJoinABC +from modules_core.abc.events.on_member_remove_abc import OnMemberRemoveABC +from modules_core.abc.events.on_member_unban_abc import OnMemberUnbanABC +from modules_core.abc.events.on_member_update_abc import OnMemberUpdateABC from modules_core.abc.events.on_message_abc import OnMessageABC +from modules_core.abc.events.on_message_delete_abc import OnMessageDeleteABC +from modules_core.abc.events.on_message_edit_abc import OnMessageEditABC +from modules_core.abc.events.on_private_channel_create_abc import OnPrivateChannelCreateABC +from modules_core.abc.events.on_private_channel_delete_abc import OnPrivateChannelDeleteABC +from modules_core.abc.events.on_private_channel_pins_update_abc import OnPrivateChannelPinsUpdateABC +from modules_core.abc.events.on_private_channel_update_abc import OnPrivateChannelUpdateABC +from modules_core.abc.events.on_reaction_add_abc import OnReactionAddABC +from modules_core.abc.events.on_reaction_clear_abc import OnReactionClearABC +from modules_core.abc.events.on_reaction_clear_emoji_abc import OnReactionClearEmojiABC +from modules_core.abc.events.on_reaction_remove_abc import OnReactionRemoveABC from modules_core.abc.events.on_ready_abc import OnReadyABC +from modules_core.abc.events.on_relationship_add_abc import OnRelationshipAddABC +from modules_core.abc.events.on_relationship_remove_abc import OnRelationshipRemoveABC +from modules_core.abc.events.on_relationship_update_abc import OnRelationshipUpdateABC +from modules_core.abc.events.on_resume_abc import OnResumeABC +from modules_core.abc.events.on_typing_abc import OnTypingABC +from modules_core.abc.events.on_user_update_abc import OnUserUpdateABC +from modules_core.abc.events.on_voice_state_update_abc import OnVoiceStateUpdateABC +from modules_core.abc.events.on_webhooks_update_abc import OnWebhooksUpdateABC from modules_core.abc.module_abc import ModuleABC from modules_core.abc.module_service_abc import ModuleServiceABC @@ -39,8 +81,14 @@ class ModuleService(ModuleServiceABC, commands.Cog, metaclass=_MetaCogABC): async def _handle_event(self, event: type, *args): self._logger.debug(__name__, f'Start {event} modules') + modules = self._get_modules(event) + + if modules.count() < 1: + self._logger.debug(__name__, f'Stopped {event} modules') + return + func_name = String.convert_to_snake_case(event.__name__.split('ABC')[0]) - for module in self._get_modules(event): + for module in modules: func = getattr(module, func_name) await func(*args) @@ -48,145 +96,234 @@ class ModuleService(ModuleServiceABC, commands.Cog, metaclass=_MetaCogABC): @commands.Cog.listener() async def on_connect(self): + self._logger.debug(__name__, f'Received on_connect') await self._handle_event(OnConnectABC) @commands.Cog.listener() async def on_disconnect(self): + self._logger.debug(__name__, f'Received on_disconnect') await self._handle_event(OnDisconnectABC) async def on_ready(self): + self._logger.debug(__name__, f'Received on_ready') await self._handle_event(OnReadyABC) @commands.Cog.listener() - async def on_resume(self): pass + async def on_resume(self): + self._logger.debug(__name__, f'Received on_resume') + await self._handle_event(OnResumeABC) @commands.Cog.listener() - async def on_error(self, event: str, *args, **kwargs): pass + async def on_error(self, event: str, *args, **kwargs): + self._logger.debug(__name__, f'Received on_error:\n\t{event}\n\t{args}\n\t{kwargs}') + await self._handle_event(OnReadyABC, event, *args, **kwargs) @commands.Cog.listener() - async def on_typing(self, channel: discord.abc.Messageable, user: Union[discord.User, discord.Member], when: datetime): pass + async def on_typing(self, channel: discord.abc.Messageable, user: Union[discord.User, discord.Member], when: datetime): + self._logger.debug(__name__, f'Received on_typing:\n\t{channel}\n\t{user}\n\t{when}') + await self._handle_event(OnTypingABC, channel, user, when) @commands.Cog.listener() async def on_message(self, message: discord.Message): - self._logger.debug(__name__, f'Received message:\n{message}:\n{message.content}') + self._logger.debug(__name__, f'Received on_message:\n\t{message}\n\t{message.content}') await self._handle_event(OnMessageABC, message) @commands.Cog.listener() - async def on_message_delete(self, message: discord.Message): pass + async def on_message_delete(self, message: discord.Message): + self._logger.debug(__name__, f'Received on_message_delete:\n\t{message}\n\t{message.content}') + await self._handle_event(OnMessageDeleteABC, message) @commands.Cog.listener() - async def on_bulk_message_delete(self, message: discord.Message): pass + async def on_bulk_message_delete(self, messages: list[discord.Message]): + self._logger.debug(__name__, f'Received on_bulk_message_delete:\n\t{len(messages)}') + await self._handle_event(OnBulkMessageDeleteABC, messages) @commands.Cog.listener() - async def on_message_edit(self, before: discord.Message, after: discord.Message): pass + async def on_message_edit(self, before: discord.Message, after: discord.Message): + self._logger.debug(__name__, f'Received on_message_edit:\n\t{before}\n\t{after}') + await self._handle_event(OnMessageEditABC, before, after) @commands.Cog.listener() - async def on_reaction_add(self, reaction: discord.Reaction, user: discord.User): pass + async def on_reaction_add(self, reaction: discord.Reaction, user: discord.User): + self._logger.debug(__name__, f'Received on_reaction_add:\n\t{reaction}\n\t{user}') + await self._handle_event(OnReactionAddABC, reaction, user) @commands.Cog.listener() - async def on_reaction_remove(self, reaction: discord.Reaction, user: discord.User): pass + async def on_reaction_remove(self, reaction: discord.Reaction, user: discord.User): + self._logger.debug(__name__, f'Received on_reaction_remove:\n\t{reaction}\n\t{user}') + await self._handle_event(OnReactionRemoveABC, reaction, user) @commands.Cog.listener() - async def on_reaction_clear(self, message: discord.Message, reactions: list[discord.Reaction]): pass + async def on_reaction_clear(self, message: discord.Message, reactions: list[discord.Reaction]): + self._logger.debug(__name__, f'Received on_reaction_reon_reaction_clearmove:\n\t{message}\n\t{len(reactions)}') + await self._handle_event(OnReactionClearABC, message, reactions) @commands.Cog.listener() - async def on_reaction_clear_emoji(self, reaction: discord.Reaction): pass + async def on_reaction_clear_emoji(self, reaction: discord.Reaction): + self._logger.debug(__name__, f'Received on_reaction_clear_emoji:\n\t{reaction}') + await self._handle_event(OnReactionClearEmojiABC, reaction) @commands.Cog.listener() - async def on_private_channel_delete(self, channel: discord.abc.PrivateChannel): pass + async def on_private_channel_delete(self, channel: discord.abc.PrivateChannel): + self._logger.debug(__name__, f'Received on_private_channel_delete:\n\t{channel}') + await self._handle_event(OnPrivateChannelDeleteABC, channel) @commands.Cog.listener() - async def on_private_channel_create(self, channel: discord.abc.PrivateChannel): pass + async def on_private_channel_create(self, channel: discord.abc.PrivateChannel): + self._logger.debug(__name__, f'Received on_private_channel_create:\n\t{channel}') + await self._handle_event(OnPrivateChannelCreateABC, channel) @commands.Cog.listener() - async def on_private_channel_update(self, before: discord.GroupChannel, after: discord.GroupChannel): pass + async def on_private_channel_update(self, before: discord.GroupChannel, after: discord.GroupChannel): + self._logger.debug(__name__, f'Received on_private_channel_update:\n\t{before}\n\t{after}') + await self._handle_event(OnPrivateChannelUpdateABC, before, after) @commands.Cog.listener() - async def on_private_channel_pins_update(self, channel: discord.abc.PrivateChannel, list_pin: Optional[datetime]): pass + async def on_private_channel_pins_update(self, channel: discord.abc.PrivateChannel, list_pin: Optional[datetime]): + self._logger.debug(__name__, f'Received on_private_channel_pins_update:\n\t{channel}\n\t{list_pin}') + await self._handle_event(OnPrivateChannelPinsUpdateABC, channel, list_pin) @commands.Cog.listener() - async def on_guild_channel_delete(self, channel: discord.abc.GuildChannel): pass + async def on_guild_channel_delete(self, channel: discord.abc.GuildChannel): + self._logger.debug(__name__, f'Received on_guild_channel_delete:\n\t{channel}') + await self._handle_event(OnGuildChannelDeleteABC, channel) @commands.Cog.listener() - async def on_guild_channel_create(self, channel: discord.abc.GuildChannel): pass + async def on_guild_channel_create(self, channel: discord.abc.GuildChannel): + self._logger.debug(__name__, f'Received on_guild_channel_create:\n\t{channel}') + await self._handle_event(OnGuildChannelCreateABC, channel) @commands.Cog.listener() - async def on_guild_channel_update(self, before: discord.abc.GuildChannel, after: discord.abc.GuildChannel): pass + async def on_guild_channel_update(self, before: discord.abc.GuildChannel, after: discord.abc.GuildChannel): + self._logger.debug(__name__, f'Received on_guild_channel_update:\n\t{before}\n\t{after}') + await self._handle_event(OnGuildChannelUpdateABC, before, after) @commands.Cog.listener() - async def on_guild_channel_pins_update(self, channel: discord.abc.GuildChannel, list_pin: Optional[datetime]): pass + async def on_guild_channel_pins_update(self, channel: discord.abc.GuildChannel, list_pin: Optional[datetime]): + self._logger.debug(__name__, f'Received on_guild_channel_pins_update:\n\t{channel}\n\t{list_pin}') + await self._handle_event(OnGuildChannelPinsUpdateABC, channel, list_pin) @commands.Cog.listener() - async def on_guild_integrations_update(self, guild: discord.Guild): pass + async def on_guild_integrations_update(self, guild: discord.Guild): + self._logger.debug(__name__, f'Received on_guild_integrations_update:\n\t{guild}') + await self._handle_event(OnGuildIntegrationsUpdateABC, guild) @commands.Cog.listener() - async def on_webhooks_update(self, channel: discord.abc.GuildChannel): pass + async def on_webhooks_update(self, channel: discord.abc.GuildChannel): + self._logger.debug(__name__, f'Received on_webhooks_update:\n\t{channel}') + await self._handle_event(OnWebhooksUpdateABC, channel) @commands.Cog.listener() - async def on_member_join(self, member: discord.Member): pass + async def on_member_join(self, member: discord.Member): + self._logger.debug(__name__, f'Received on_member_join:\n\t{member}') + await self._handle_event(OnMemberJoinABC, member) @commands.Cog.listener() - async def on_member_remove(self, member: discord.Member): pass + async def on_member_remove(self, member: discord.Member): + self._logger.debug(__name__, f'Received on_member_remove:\n\t{member}') + await self._handle_event(OnMemberRemoveABC, member) @commands.Cog.listener() - async def on_member_update(self, before: discord.Member, after: discord.Member): pass + async def on_member_update(self, before: discord.Member, after: discord.Member): + self._logger.debug(__name__, f'Received on_member_update:\n\t{before}\n\t{after}') + await self._handle_event(OnMemberUpdateABC, before, after) @commands.Cog.listener() - async def on_user_update(self, before: discord.User, after: discord.User): pass + async def on_user_update(self, before: discord.User, after: discord.User): + self._logger.debug(__name__, f'Received on_user_update:\n\t{before}\n\t{after}') + await self._handle_event(OnUserUpdateABC, before, after) @commands.Cog.listener() - async def on_guild_join(self, guild: discord.Guild): pass + async def on_guild_join(self, guild: discord.Guild): + self._logger.debug(__name__, f'Received on_guild_join:\n\t{guild}') + await self._handle_event(OnGuildJoinABC, guild) @commands.Cog.listener() - async def on_guild_remove(self, guild: discord.Guild): pass + async def on_guild_remove(self, guild: discord.Guild): + self._logger.debug(__name__, f'Received on_guild_remove:\n\t{guild}') + await self._handle_event(OnGuildRemoveABC, guild) @commands.Cog.listener() - async def on_guild_update(self, before: discord.Guild, after: discord.Guild): pass + async def on_guild_update(self, before: discord.Guild, after: discord.Guild): + self._logger.debug(__name__, f'Received on_guild_update:\n\t{before}\n\t{after}') + await self._handle_event(OnGuildUpdateABC, before, after) @commands.Cog.listener() - async def on_guild_role_create(self, role: discord.Role): pass + async def on_guild_role_create(self, role: discord.Role): + self._logger.debug(__name__, f'Received on_guild_role_create:\n\t{role}') + await self._handle_event(OnGuildRoleCreateABC, role) @commands.Cog.listener() - async def on_guild_role_delete(self, role: discord.Role): pass + async def on_guild_role_delete(self, role: discord.Role): + self._logger.debug(__name__, f'Received on_guild_role_delete:\n\t{role}') + await self._handle_event(OnGuildRoleDeleteABC, role) @commands.Cog.listener() - async def on_guild_role_update(self, before: discord.Role, after: discord.Role): pass + async def on_guild_role_update(self, before: discord.Role, after: discord.Role): + self._logger.debug(__name__, f'Received on_guild_role_update:\n\t{before}\n\t{after}') + await self._handle_event(OnGuildRoleUpdateABC, before, after) @commands.Cog.listener() - async def on_guild_emojis_update(self, guild: discord.Guild, before: Sequence[discord.Emoji], after: Sequence[discord.Emoji]): pass + async def on_guild_emojis_update(self, guild: discord.Guild, before: Sequence[discord.Emoji], after: Sequence[discord.Emoji]): + self._logger.debug(__name__, f'Received on_guild_emojis_update:\n\t{guild}\n\t{before}\n\t{after}') + await self._handle_event(OnGuildEmojisUpdateABC, guild, before, after) @commands.Cog.listener() - async def on_guild_available(self, guild: discord.Guild): pass + async def on_guild_available(self, guild: discord.Guild): + self._logger.debug(__name__, f'Received on_guild_available:\n\t{guild}') + await self._handle_event(OnGuildAvailableABC, guild) @commands.Cog.listener() - async def on_guild_unavailable(self, guild: discord.Guild): pass + async def on_guild_unavailable(self, guild: discord.Guild): + self._logger.debug(__name__, f'Received on_guild_unavailable:\n\t{guild}') + await self._handle_event(OnGuildUnavailableABC, guild) @commands.Cog.listener() - async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState): pass + async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState): + self._logger.debug(__name__, f'Received on_voice_state_update:\n\t{member}\n\t{before}\n\t{after}') + await self._handle_event(OnVoiceStateUpdateABC, member, before, after) @commands.Cog.listener() - async def on_member_ban(self, guild: discord.Guild, user: discord.User): pass + async def on_member_ban(self, guild: discord.Guild, user: discord.User): + self._logger.debug(__name__, f'Received on_member_ban:\n\t{guild}\n\t{user}') + await self._handle_event(OnMemberBanABC, guild, user) @commands.Cog.listener() - async def on_member_unban(self, guild: discord.Guild, user: discord.User): pass + async def on_member_unban(self, guild: discord.Guild, user: discord.User): + self._logger.debug(__name__, f'Received on_member_unban:\n\t{guild}\n\t{user}') + await self._handle_event(OnMemberUnbanABC, guild, user) @commands.Cog.listener() - async def on_invite_create(self, invite: discord.Invite): pass + async def on_invite_create(self, invite: discord.Invite): + self._logger.debug(__name__, f'Received on_invite_create:\n\t{invite}') + await self._handle_event(OnInviteCreateABC, invite) @commands.Cog.listener() - async def on_invite_delete(self, invite: discord.Invite): pass + async def on_invite_delete(self, invite: discord.Invite): + self._logger.debug(__name__, f'Received on_invite_create:\n\t{invite}') + await self._handle_event(OnInviteDeleteABC, invite) @commands.Cog.listener() - async def on_group_join(self, chhanel: discord.GroupChannel, user: discord.User): pass + async def on_group_join(self, channel: discord.GroupChannel, user: discord.User): + self._logger.debug(__name__, f'Received on_group_join:\n\t{channel}\n\t{user}') + await self._handle_event(OnGroupJoinABC, channel, user) @commands.Cog.listener() - async def on_group_remove(self, chhanel: discord.GroupChannel, user: discord.User): pass + async def on_group_remove(self, channel: discord.GroupChannel, user: discord.User): + self._logger.debug(__name__, f'Received on_group_remove:\n\t{channel}\n\t{user}') + await self._handle_event(OnGroupRemoveABC, channel, user) @commands.Cog.listener() - async def on_relationship_add(self, relationship: discord.Relationship): pass + async def on_relationship_add(self, relationship: discord.Relationship): + self._logger.debug(__name__, f'Received on_relationship_add:\n\t{relationship}') + await self._handle_event(OnRelationshipAddABC, relationship) @commands.Cog.listener() - async def on_relationship_remove(self, relationship: discord.Relationship): pass + async def on_relationship_remove(self, relationship: discord.Relationship): + self._logger.debug(__name__, f'Received on_relationship_remove:\n\t{relationship}') + await self._handle_event(OnRelationshipRemoveABC, relationship) @commands.Cog.listener() - async def on_relationship_update(self, before: discord.Relationship, after: discord.Relationship): pass + async def on_relationship_update(self, before: discord.Relationship, after: discord.Relationship): + self._logger.debug(__name__, f'Received on_relationship_update:\n\t{before}\n\t{after}') + await self._handle_event(OnRelationshipUpdateABC, before, after) -- 2.45.2 From 1f095c941551eb0b16e145a33979a387c4499d5d Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 23 Nov 2021 17:19:46 +0100 Subject: [PATCH 104/113] Added imports --- src/modules_core/abc/events/on_guild_channel_pins_update_abc.py | 2 ++ .../abc/events/on_private_channel_pins_update_abc.py | 2 ++ src/modules_core/abc/events/on_typing_abc.py | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/modules_core/abc/events/on_guild_channel_pins_update_abc.py b/src/modules_core/abc/events/on_guild_channel_pins_update_abc.py index 010e82f..3408e54 100644 --- a/src/modules_core/abc/events/on_guild_channel_pins_update_abc.py +++ b/src/modules_core/abc/events/on_guild_channel_pins_update_abc.py @@ -1,4 +1,6 @@ from abc import ABC, abstractmethod +from datetime import datetime +from typing import Optional import discord diff --git a/src/modules_core/abc/events/on_private_channel_pins_update_abc.py b/src/modules_core/abc/events/on_private_channel_pins_update_abc.py index 7d9da09..4634b87 100644 --- a/src/modules_core/abc/events/on_private_channel_pins_update_abc.py +++ b/src/modules_core/abc/events/on_private_channel_pins_update_abc.py @@ -1,4 +1,6 @@ from abc import ABC, abstractmethod +from datetime import datetime +from typing import Optional import discord diff --git a/src/modules_core/abc/events/on_typing_abc.py b/src/modules_core/abc/events/on_typing_abc.py index 56fadbf..76b89a0 100644 --- a/src/modules_core/abc/events/on_typing_abc.py +++ b/src/modules_core/abc/events/on_typing_abc.py @@ -1,4 +1,6 @@ from abc import ABC, abstractmethod +from datetime import datetime +from typing import Union import discord -- 2.45.2 From 2d261a6222d89daa4c97cd513b3975a7a629fb04 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 23 Nov 2021 17:23:11 +0100 Subject: [PATCH 105/113] Improved config & chnaged logging --- src/gismo/appsettings.development.json | 4 +- src/gismo/appsettings.staging.json | 6 +- src/modules_core/service/module_service.py | 94 +++++++++++----------- 3 files changed, 54 insertions(+), 50 deletions(-) diff --git a/src/gismo/appsettings.development.json b/src/gismo/appsettings.development.json index 1bacb79..f9e5f91 100644 --- a/src/gismo/appsettings.development.json +++ b/src/gismo/appsettings.development.json @@ -9,8 +9,8 @@ "LoggingSettings": { "Path": "logs/", "Filename": "log_dev.log", - "ConsoleLogLevel": "TRACE", - "FileLogLevel": "TRACE" + "ConsoleLogLevel": "DEBUG", + "FileLogLevel": "DEBUG" }, "Discord": { diff --git a/src/gismo/appsettings.staging.json b/src/gismo/appsettings.staging.json index 1fce9ac..e9ecafe 100644 --- a/src/gismo/appsettings.staging.json +++ b/src/gismo/appsettings.staging.json @@ -8,8 +8,12 @@ "LoggingSettings": { "Path": "logs/", - "Filename": "log_$start_time.log", + "Filename": "log_staging_$start_time.log", "ConsoleLogLevel": "DEBUG", "FileLogLevel": "DEBUG" + }, + + "Discord": { + "Token": "OTEwMjAxNjA1NDkwNjEwMjA3.YZPZTQ.kvMUuDUH_-qsllgkch8LYmXcKlo" } } diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index 05fda32..9760cf3 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -96,234 +96,234 @@ class ModuleService(ModuleServiceABC, commands.Cog, metaclass=_MetaCogABC): @commands.Cog.listener() async def on_connect(self): - self._logger.debug(__name__, f'Received on_connect') + self._logger.trace(__name__, f'Received on_connect') await self._handle_event(OnConnectABC) @commands.Cog.listener() async def on_disconnect(self): - self._logger.debug(__name__, f'Received on_disconnect') + self._logger.trace(__name__, f'Received on_disconnect') await self._handle_event(OnDisconnectABC) async def on_ready(self): - self._logger.debug(__name__, f'Received on_ready') + self._logger.trace(__name__, f'Received on_ready') await self._handle_event(OnReadyABC) @commands.Cog.listener() async def on_resume(self): - self._logger.debug(__name__, f'Received on_resume') + self._logger.trace(__name__, f'Received on_resume') await self._handle_event(OnResumeABC) @commands.Cog.listener() async def on_error(self, event: str, *args, **kwargs): - self._logger.debug(__name__, f'Received on_error:\n\t{event}\n\t{args}\n\t{kwargs}') + self._logger.trace(__name__, f'Received on_error:\n\t{event}\n\t{args}\n\t{kwargs}') await self._handle_event(OnReadyABC, event, *args, **kwargs) @commands.Cog.listener() async def on_typing(self, channel: discord.abc.Messageable, user: Union[discord.User, discord.Member], when: datetime): - self._logger.debug(__name__, f'Received on_typing:\n\t{channel}\n\t{user}\n\t{when}') + self._logger.trace(__name__, f'Received on_typing:\n\t{channel}\n\t{user}\n\t{when}') await self._handle_event(OnTypingABC, channel, user, when) @commands.Cog.listener() async def on_message(self, message: discord.Message): - self._logger.debug(__name__, f'Received on_message:\n\t{message}\n\t{message.content}') + self._logger.trace(__name__, f'Received on_message:\n\t{message}\n\t{message.content}') await self._handle_event(OnMessageABC, message) @commands.Cog.listener() async def on_message_delete(self, message: discord.Message): - self._logger.debug(__name__, f'Received on_message_delete:\n\t{message}\n\t{message.content}') + self._logger.trace(__name__, f'Received on_message_delete:\n\t{message}\n\t{message.content}') await self._handle_event(OnMessageDeleteABC, message) @commands.Cog.listener() async def on_bulk_message_delete(self, messages: list[discord.Message]): - self._logger.debug(__name__, f'Received on_bulk_message_delete:\n\t{len(messages)}') + self._logger.trace(__name__, f'Received on_bulk_message_delete:\n\t{len(messages)}') await self._handle_event(OnBulkMessageDeleteABC, messages) @commands.Cog.listener() async def on_message_edit(self, before: discord.Message, after: discord.Message): - self._logger.debug(__name__, f'Received on_message_edit:\n\t{before}\n\t{after}') + self._logger.trace(__name__, f'Received on_message_edit:\n\t{before}\n\t{after}') await self._handle_event(OnMessageEditABC, before, after) @commands.Cog.listener() async def on_reaction_add(self, reaction: discord.Reaction, user: discord.User): - self._logger.debug(__name__, f'Received on_reaction_add:\n\t{reaction}\n\t{user}') + self._logger.trace(__name__, f'Received on_reaction_add:\n\t{reaction}\n\t{user}') await self._handle_event(OnReactionAddABC, reaction, user) @commands.Cog.listener() async def on_reaction_remove(self, reaction: discord.Reaction, user: discord.User): - self._logger.debug(__name__, f'Received on_reaction_remove:\n\t{reaction}\n\t{user}') + self._logger.trace(__name__, f'Received on_reaction_remove:\n\t{reaction}\n\t{user}') await self._handle_event(OnReactionRemoveABC, reaction, user) @commands.Cog.listener() async def on_reaction_clear(self, message: discord.Message, reactions: list[discord.Reaction]): - self._logger.debug(__name__, f'Received on_reaction_reon_reaction_clearmove:\n\t{message}\n\t{len(reactions)}') + self._logger.trace(__name__, f'Received on_reaction_reon_reaction_clearmove:\n\t{message}\n\t{len(reactions)}') await self._handle_event(OnReactionClearABC, message, reactions) @commands.Cog.listener() async def on_reaction_clear_emoji(self, reaction: discord.Reaction): - self._logger.debug(__name__, f'Received on_reaction_clear_emoji:\n\t{reaction}') + self._logger.trace(__name__, f'Received on_reaction_clear_emoji:\n\t{reaction}') await self._handle_event(OnReactionClearEmojiABC, reaction) @commands.Cog.listener() async def on_private_channel_delete(self, channel: discord.abc.PrivateChannel): - self._logger.debug(__name__, f'Received on_private_channel_delete:\n\t{channel}') + self._logger.trace(__name__, f'Received on_private_channel_delete:\n\t{channel}') await self._handle_event(OnPrivateChannelDeleteABC, channel) @commands.Cog.listener() async def on_private_channel_create(self, channel: discord.abc.PrivateChannel): - self._logger.debug(__name__, f'Received on_private_channel_create:\n\t{channel}') + self._logger.trace(__name__, f'Received on_private_channel_create:\n\t{channel}') await self._handle_event(OnPrivateChannelCreateABC, channel) @commands.Cog.listener() async def on_private_channel_update(self, before: discord.GroupChannel, after: discord.GroupChannel): - self._logger.debug(__name__, f'Received on_private_channel_update:\n\t{before}\n\t{after}') + self._logger.trace(__name__, f'Received on_private_channel_update:\n\t{before}\n\t{after}') await self._handle_event(OnPrivateChannelUpdateABC, before, after) @commands.Cog.listener() async def on_private_channel_pins_update(self, channel: discord.abc.PrivateChannel, list_pin: Optional[datetime]): - self._logger.debug(__name__, f'Received on_private_channel_pins_update:\n\t{channel}\n\t{list_pin}') + self._logger.trace(__name__, f'Received on_private_channel_pins_update:\n\t{channel}\n\t{list_pin}') await self._handle_event(OnPrivateChannelPinsUpdateABC, channel, list_pin) @commands.Cog.listener() async def on_guild_channel_delete(self, channel: discord.abc.GuildChannel): - self._logger.debug(__name__, f'Received on_guild_channel_delete:\n\t{channel}') + self._logger.trace(__name__, f'Received on_guild_channel_delete:\n\t{channel}') await self._handle_event(OnGuildChannelDeleteABC, channel) @commands.Cog.listener() async def on_guild_channel_create(self, channel: discord.abc.GuildChannel): - self._logger.debug(__name__, f'Received on_guild_channel_create:\n\t{channel}') + self._logger.trace(__name__, f'Received on_guild_channel_create:\n\t{channel}') await self._handle_event(OnGuildChannelCreateABC, channel) @commands.Cog.listener() async def on_guild_channel_update(self, before: discord.abc.GuildChannel, after: discord.abc.GuildChannel): - self._logger.debug(__name__, f'Received on_guild_channel_update:\n\t{before}\n\t{after}') + self._logger.trace(__name__, f'Received on_guild_channel_update:\n\t{before}\n\t{after}') await self._handle_event(OnGuildChannelUpdateABC, before, after) @commands.Cog.listener() async def on_guild_channel_pins_update(self, channel: discord.abc.GuildChannel, list_pin: Optional[datetime]): - self._logger.debug(__name__, f'Received on_guild_channel_pins_update:\n\t{channel}\n\t{list_pin}') + self._logger.trace(__name__, f'Received on_guild_channel_pins_update:\n\t{channel}\n\t{list_pin}') await self._handle_event(OnGuildChannelPinsUpdateABC, channel, list_pin) @commands.Cog.listener() async def on_guild_integrations_update(self, guild: discord.Guild): - self._logger.debug(__name__, f'Received on_guild_integrations_update:\n\t{guild}') + self._logger.trace(__name__, f'Received on_guild_integrations_update:\n\t{guild}') await self._handle_event(OnGuildIntegrationsUpdateABC, guild) @commands.Cog.listener() async def on_webhooks_update(self, channel: discord.abc.GuildChannel): - self._logger.debug(__name__, f'Received on_webhooks_update:\n\t{channel}') + self._logger.trace(__name__, f'Received on_webhooks_update:\n\t{channel}') await self._handle_event(OnWebhooksUpdateABC, channel) @commands.Cog.listener() async def on_member_join(self, member: discord.Member): - self._logger.debug(__name__, f'Received on_member_join:\n\t{member}') + self._logger.trace(__name__, f'Received on_member_join:\n\t{member}') await self._handle_event(OnMemberJoinABC, member) @commands.Cog.listener() async def on_member_remove(self, member: discord.Member): - self._logger.debug(__name__, f'Received on_member_remove:\n\t{member}') + self._logger.trace(__name__, f'Received on_member_remove:\n\t{member}') await self._handle_event(OnMemberRemoveABC, member) @commands.Cog.listener() async def on_member_update(self, before: discord.Member, after: discord.Member): - self._logger.debug(__name__, f'Received on_member_update:\n\t{before}\n\t{after}') + self._logger.trace(__name__, f'Received on_member_update:\n\t{before}\n\t{after}') await self._handle_event(OnMemberUpdateABC, before, after) @commands.Cog.listener() async def on_user_update(self, before: discord.User, after: discord.User): - self._logger.debug(__name__, f'Received on_user_update:\n\t{before}\n\t{after}') + self._logger.trace(__name__, f'Received on_user_update:\n\t{before}\n\t{after}') await self._handle_event(OnUserUpdateABC, before, after) @commands.Cog.listener() async def on_guild_join(self, guild: discord.Guild): - self._logger.debug(__name__, f'Received on_guild_join:\n\t{guild}') + self._logger.trace(__name__, f'Received on_guild_join:\n\t{guild}') await self._handle_event(OnGuildJoinABC, guild) @commands.Cog.listener() async def on_guild_remove(self, guild: discord.Guild): - self._logger.debug(__name__, f'Received on_guild_remove:\n\t{guild}') + self._logger.trace(__name__, f'Received on_guild_remove:\n\t{guild}') await self._handle_event(OnGuildRemoveABC, guild) @commands.Cog.listener() async def on_guild_update(self, before: discord.Guild, after: discord.Guild): - self._logger.debug(__name__, f'Received on_guild_update:\n\t{before}\n\t{after}') + self._logger.trace(__name__, f'Received on_guild_update:\n\t{before}\n\t{after}') await self._handle_event(OnGuildUpdateABC, before, after) @commands.Cog.listener() async def on_guild_role_create(self, role: discord.Role): - self._logger.debug(__name__, f'Received on_guild_role_create:\n\t{role}') + self._logger.trace(__name__, f'Received on_guild_role_create:\n\t{role}') await self._handle_event(OnGuildRoleCreateABC, role) @commands.Cog.listener() async def on_guild_role_delete(self, role: discord.Role): - self._logger.debug(__name__, f'Received on_guild_role_delete:\n\t{role}') + self._logger.trace(__name__, f'Received on_guild_role_delete:\n\t{role}') await self._handle_event(OnGuildRoleDeleteABC, role) @commands.Cog.listener() async def on_guild_role_update(self, before: discord.Role, after: discord.Role): - self._logger.debug(__name__, f'Received on_guild_role_update:\n\t{before}\n\t{after}') + self._logger.trace(__name__, f'Received on_guild_role_update:\n\t{before}\n\t{after}') await self._handle_event(OnGuildRoleUpdateABC, before, after) @commands.Cog.listener() async def on_guild_emojis_update(self, guild: discord.Guild, before: Sequence[discord.Emoji], after: Sequence[discord.Emoji]): - self._logger.debug(__name__, f'Received on_guild_emojis_update:\n\t{guild}\n\t{before}\n\t{after}') + self._logger.trace(__name__, f'Received on_guild_emojis_update:\n\t{guild}\n\t{before}\n\t{after}') await self._handle_event(OnGuildEmojisUpdateABC, guild, before, after) @commands.Cog.listener() async def on_guild_available(self, guild: discord.Guild): - self._logger.debug(__name__, f'Received on_guild_available:\n\t{guild}') + self._logger.trace(__name__, f'Received on_guild_available:\n\t{guild}') await self._handle_event(OnGuildAvailableABC, guild) @commands.Cog.listener() async def on_guild_unavailable(self, guild: discord.Guild): - self._logger.debug(__name__, f'Received on_guild_unavailable:\n\t{guild}') + self._logger.trace(__name__, f'Received on_guild_unavailable:\n\t{guild}') await self._handle_event(OnGuildUnavailableABC, guild) @commands.Cog.listener() async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState): - self._logger.debug(__name__, f'Received on_voice_state_update:\n\t{member}\n\t{before}\n\t{after}') + self._logger.trace(__name__, f'Received on_voice_state_update:\n\t{member}\n\t{before}\n\t{after}') await self._handle_event(OnVoiceStateUpdateABC, member, before, after) @commands.Cog.listener() async def on_member_ban(self, guild: discord.Guild, user: discord.User): - self._logger.debug(__name__, f'Received on_member_ban:\n\t{guild}\n\t{user}') + self._logger.trace(__name__, f'Received on_member_ban:\n\t{guild}\n\t{user}') await self._handle_event(OnMemberBanABC, guild, user) @commands.Cog.listener() async def on_member_unban(self, guild: discord.Guild, user: discord.User): - self._logger.debug(__name__, f'Received on_member_unban:\n\t{guild}\n\t{user}') + self._logger.trace(__name__, f'Received on_member_unban:\n\t{guild}\n\t{user}') await self._handle_event(OnMemberUnbanABC, guild, user) @commands.Cog.listener() async def on_invite_create(self, invite: discord.Invite): - self._logger.debug(__name__, f'Received on_invite_create:\n\t{invite}') + self._logger.trace(__name__, f'Received on_invite_create:\n\t{invite}') await self._handle_event(OnInviteCreateABC, invite) @commands.Cog.listener() async def on_invite_delete(self, invite: discord.Invite): - self._logger.debug(__name__, f'Received on_invite_create:\n\t{invite}') + self._logger.trace(__name__, f'Received on_invite_create:\n\t{invite}') await self._handle_event(OnInviteDeleteABC, invite) @commands.Cog.listener() async def on_group_join(self, channel: discord.GroupChannel, user: discord.User): - self._logger.debug(__name__, f'Received on_group_join:\n\t{channel}\n\t{user}') + self._logger.trace(__name__, f'Received on_group_join:\n\t{channel}\n\t{user}') await self._handle_event(OnGroupJoinABC, channel, user) @commands.Cog.listener() async def on_group_remove(self, channel: discord.GroupChannel, user: discord.User): - self._logger.debug(__name__, f'Received on_group_remove:\n\t{channel}\n\t{user}') + self._logger.trace(__name__, f'Received on_group_remove:\n\t{channel}\n\t{user}') await self._handle_event(OnGroupRemoveABC, channel, user) @commands.Cog.listener() async def on_relationship_add(self, relationship: discord.Relationship): - self._logger.debug(__name__, f'Received on_relationship_add:\n\t{relationship}') + self._logger.trace(__name__, f'Received on_relationship_add:\n\t{relationship}') await self._handle_event(OnRelationshipAddABC, relationship) @commands.Cog.listener() async def on_relationship_remove(self, relationship: discord.Relationship): - self._logger.debug(__name__, f'Received on_relationship_remove:\n\t{relationship}') + self._logger.trace(__name__, f'Received on_relationship_remove:\n\t{relationship}') await self._handle_event(OnRelationshipRemoveABC, relationship) @commands.Cog.listener() async def on_relationship_update(self, before: discord.Relationship, after: discord.Relationship): - self._logger.debug(__name__, f'Received on_relationship_update:\n\t{before}\n\t{after}') + self._logger.trace(__name__, f'Received on_relationship_update:\n\t{before}\n\t{after}') await self._handle_event(OnRelationshipUpdateABC, before, after) -- 2.45.2 From e951baa35896ed5df278f75168ebe27c4aaf736e Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 23 Nov 2021 17:27:43 +0100 Subject: [PATCH 106/113] Improved configs --- src/gismo/appsettings.development.json | 13 ++----------- src/gismo/appsettings.edrafts-lapi.json | 19 ++++++++++++++++++- src/gismo/appsettings.edrafts-pc.json | 19 ++++++++++++++++++- src/gismo/appsettings.production.json | 15 ++++++++++----- src/gismo/appsettings.staging.json | 15 ++++++++++++--- 5 files changed, 60 insertions(+), 21 deletions(-) diff --git a/src/gismo/appsettings.development.json b/src/gismo/appsettings.development.json index f9e5f91..7b125c1 100644 --- a/src/gismo/appsettings.development.json +++ b/src/gismo/appsettings.development.json @@ -5,27 +5,18 @@ "DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f", "DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S" }, - "LoggingSettings": { "Path": "logs/", "Filename": "log_dev.log", "ConsoleLogLevel": "DEBUG", "FileLogLevel": "DEBUG" }, - "Discord": { "Token": "OTA5ODc4NDcyNzExNzU3ODQ1.YZKsXA.BXBszIF3z3wHpoe9s3pKfO3Yd5c" }, - "Bot": { - "Prefix": "!dev-g", + "Prefix": "!gd", "Servers": [ - { - "Id": "511824600884051979", - "LoginMessageChannelId": "521260270757347328", - "LoginMessage": "Ich bin on the line :D\nDer Start hat {} Sekunden gedauert", - "MessageDeleteTimer": 2 - }, { "Id": "910199451145076828", "LoginMessageChannelId": "910199452915093588", @@ -34,4 +25,4 @@ } ] } -} +} \ No newline at end of file diff --git a/src/gismo/appsettings.edrafts-lapi.json b/src/gismo/appsettings.edrafts-lapi.json index a8919a4..1a0300b 100644 --- a/src/gismo/appsettings.edrafts-lapi.json +++ b/src/gismo/appsettings.edrafts-lapi.json @@ -1,5 +1,22 @@ { + "LoggingSettings": { + "Path": "logs/", + "Filename": "log_dev.log", + "ConsoleLogLevel": "TRACE", + "FileLogLevel": "TRACE" + }, "Discord": { "Token": "OTExNTc0NDQyMzMxNzM0MDI2.YZjX2w.9yhsrTfrmkoDUqRJVzV5FVEwF3U" + }, + "Bot": { + "Prefix": "!gde", + "Servers": [ + { + "Id": "910199451145076828", + "LoginMessageChannelId": "910199452915093588", + "LoginMessage": "Ich bin on the line :D\nDer Start hat {} Sekunden gedauert", + "MessageDeleteTimer": 2 + } + ] } -} +} \ No newline at end of file diff --git a/src/gismo/appsettings.edrafts-pc.json b/src/gismo/appsettings.edrafts-pc.json index a8919a4..1a0300b 100644 --- a/src/gismo/appsettings.edrafts-pc.json +++ b/src/gismo/appsettings.edrafts-pc.json @@ -1,5 +1,22 @@ { + "LoggingSettings": { + "Path": "logs/", + "Filename": "log_dev.log", + "ConsoleLogLevel": "TRACE", + "FileLogLevel": "TRACE" + }, "Discord": { "Token": "OTExNTc0NDQyMzMxNzM0MDI2.YZjX2w.9yhsrTfrmkoDUqRJVzV5FVEwF3U" + }, + "Bot": { + "Prefix": "!gde", + "Servers": [ + { + "Id": "910199451145076828", + "LoginMessageChannelId": "910199452915093588", + "LoginMessage": "Ich bin on the line :D\nDer Start hat {} Sekunden gedauert", + "MessageDeleteTimer": 2 + } + ] } -} +} \ No newline at end of file diff --git a/src/gismo/appsettings.production.json b/src/gismo/appsettings.production.json index c31e974..8ddbe25 100644 --- a/src/gismo/appsettings.production.json +++ b/src/gismo/appsettings.production.json @@ -5,19 +5,24 @@ "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" }, - "Discord": { "Token": "OTA5ODc3NDg3MjEzODk5ODQ3.YZKrcQ.qwfDWBFdkOzxZZT10jUWG5fY2RA" }, - "Bot": { - "Prefix": "!g" + "Prefix": "!g", + "Servers": [ + { + "Id": "511824600884051979", + "LoginMessageChannelId": "521260270757347328", + "LoginMessage": "Ich bin on the line :D\nDer Start hat {} Sekunden gedauert", + "MessageDeleteTimer": 2 + } + ] } -} +} \ No newline at end of file diff --git a/src/gismo/appsettings.staging.json b/src/gismo/appsettings.staging.json index e9ecafe..31aaa85 100644 --- a/src/gismo/appsettings.staging.json +++ b/src/gismo/appsettings.staging.json @@ -5,15 +5,24 @@ "DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f", "DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S" }, - "LoggingSettings": { "Path": "logs/", "Filename": "log_staging_$start_time.log", "ConsoleLogLevel": "DEBUG", "FileLogLevel": "DEBUG" }, - "Discord": { "Token": "OTEwMjAxNjA1NDkwNjEwMjA3.YZPZTQ.kvMUuDUH_-qsllgkch8LYmXcKlo" + }, + "Bot": { + "Prefix": "!gt", + "Servers": [ + { + "Id": "511824600884051979", + "LoginMessageChannelId": "521260270757347328", + "LoginMessage": "Ich bin on the line :D\nDer Start hat {} Sekunden gedauert", + "MessageDeleteTimer": 2 + } + ] } -} +} \ No newline at end of file -- 2.45.2 From 4edda07ceedd09e43151fa06ccad5d5715f48f19 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 23 Nov 2021 17:32:03 +0100 Subject: [PATCH 107/113] Improved logging --- src/gismo_core/service/message_service.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gismo_core/service/message_service.py b/src/gismo_core/service/message_service.py index 6a90d79..32ae1c3 100644 --- a/src/gismo_core/service/message_service.py +++ b/src/gismo_core/service/message_service.py @@ -28,16 +28,16 @@ class MessageService(MessageServiceABC): async def delete_message(self, message: discord.Message): server_st: ServerSettings = self._config.get_configuration(f'DSERVER_{message.guild.id}') await asyncio.sleep(server_st.message_delete_timer) - self._logger.debug(__name__, f'Try to delete message: {message.content}') + self._logger.debug(__name__, f'Try to delete message:\n\t{message}\n\t{message.content}') try: await message.delete() except Exception as e: self._logger.error(__name__, f'Deleting message failed', e) else: - self._logger.info(__name__, f'Deleted message {message.content}') + self._logger.info(__name__, f'Deleted message {message}') async def send_channel_message(self, channel: discord.TextChannel, message: str): - self._logger.debug(__name__, f'Try to send message {message} to channel {channel.id}') + self._logger.debug(__name__, f'Try to send message\n\t{message}\n\tto: {channel}') msg = None try: msg = await channel.send(message) @@ -48,7 +48,7 @@ class MessageService(MessageServiceABC): await self.delete_message(msg) async def send_dm_message(self, message: str, receiver: Union[discord.User, discord.Member]): - self._logger.debug(__name__, f'Try to send message {message} to user {receiver.id}') + self._logger.debug(__name__, f'Try to send message\n\t{message}\n\tto: {receiver}') try: await receiver.send(message) except Exception as e: @@ -62,7 +62,7 @@ class MessageService(MessageServiceABC): self._logger.debug(__name__, f'Message: {message}') return - self._logger.debug(__name__, f'Try to send message {message} to channel {ctx.channel.id}') + self._logger.debug(__name__, f'Try to send message\t\t{message}\n\tto: {ctx.channel}') msg = None try: if isinstance(message, discord.File): -- 2.45.2 From f4c340796e5297503b1669ea207325b30de81aa7 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 23 Nov 2021 19:11:00 +0100 Subject: [PATCH 108/113] Improved workspace scripts --- cpl-workspace.json | 10 +++++++++- scripts/start.sh | 4 ---- 2 files changed, 9 insertions(+), 5 deletions(-) delete mode 100755 scripts/start.sh diff --git a/cpl-workspace.json b/cpl-workspace.json index 4c07f53..9c5fae6 100644 --- a/cpl-workspace.json +++ b/cpl-workspace.json @@ -12,6 +12,14 @@ "level-generator": "tools/level_generator/level-generator.json", "ontime-calculator": "tools/ontime_calculator/ontime-calculator.json" }, - "Scripts": {} + "Scripts": { + "pre-start": "echo '!WARNING! You should start with the right environment!\nRun cpl start-ENV\nSee workspace for more details.'; sleep 2", + "pre-start-dev": "echo 'development:'; ", + "start-dev": "export GISMO_ENVIRONMENT=development; export GISMO_NAME=Gismo-dev; cpl start", + "pre-start-stage": "echo 'staging:'; ", + "start-stage": "export GISMO_ENVIRONMENT=staging; export GISMO_NAME=Gismo-test; cpl start", + "pre-start-prod": "echo 'production:'; ", + "start-prod": "export GISMO_ENVIRONMENT=production; export GISMO_NAME=Gismo-prod; cpl start" + } } } \ No newline at end of file diff --git a/scripts/start.sh b/scripts/start.sh deleted file mode 100755 index cc95535..0000000 --- a/scripts/start.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -export GISMO_ENVIRONMENT=development -cpl start \ No newline at end of file -- 2.45.2 From 2e24a3b1f2df6093a6b4e3db04b3754f3c4a95a2 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 24 Nov 2021 16:51:36 +0100 Subject: [PATCH 109/113] Improved module priority handling --- src/modules/boot_log/boot_log.py | 9 ++------- src/modules_core/abc/module_abc.py | 11 +++++++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/modules/boot_log/boot_log.py b/src/modules/boot_log/boot_log.py index 4d72b69..4ee4834 100644 --- a/src/modules/boot_log/boot_log.py +++ b/src/modules/boot_log/boot_log.py @@ -27,14 +27,9 @@ class BootLog(ModuleABC, OnReadyABC): self._bot = bot self._message_service = message_service - self._priorities = { - OnReadyABC: 10 - } - + ModuleABC.__init__(self) + self._priorities[OnReadyABC] = 10 self._logger.trace(__name__, f'Module {type(self)} loaded') - - def get_priority(self, t: type) -> int: - return self._priorities[t] async def on_ready(self): self._logger.debug(__name__, f'Module {type(self)} started') diff --git a/src/modules_core/abc/module_abc.py b/src/modules_core/abc/module_abc.py index d377d4b..a970850 100644 --- a/src/modules_core/abc/module_abc.py +++ b/src/modules_core/abc/module_abc.py @@ -5,7 +5,10 @@ import discord class ModuleABC(ABC): @abstractmethod - def __init__(self): pass - - @abstractmethod - def get_priority(self, t: type) -> int: pass + def __init__(self): + self._priorities = {} + + def get_priority(self, t: type) -> int: + if t not in self._priorities: + raise Exception(f'Priority for {t} not found!') + return self._priorities[t] -- 2.45.2 From ed9a3bc90c3b86aea2223a7b7e86c906a29cd7a8 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 25 Nov 2021 17:29:31 +0100 Subject: [PATCH 110/113] Improved custom commands --- cpl-workspace.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cpl-workspace.json b/cpl-workspace.json index 9c5fae6..85ccd65 100644 --- a/cpl-workspace.json +++ b/cpl-workspace.json @@ -14,12 +14,12 @@ }, "Scripts": { "pre-start": "echo '!WARNING! You should start with the right environment!\nRun cpl start-ENV\nSee workspace for more details.'; sleep 2", - "pre-start-dev": "echo 'development:'; ", - "start-dev": "export GISMO_ENVIRONMENT=development; export GISMO_NAME=Gismo-dev; cpl start", - "pre-start-stage": "echo 'staging:'; ", - "start-stage": "export GISMO_ENVIRONMENT=staging; export GISMO_NAME=Gismo-test; cpl start", - "pre-start-prod": "echo 'production:'; ", - "start-prod": "export GISMO_ENVIRONMENT=production; export GISMO_NAME=Gismo-prod; cpl start" + "pre-dev-start": "echo 'development:'; ", + "dev-start": "export GISMO_ENVIRONMENT=development; export GISMO_NAME=Gismo-dev; cpl start", + "pre-stage-start": "echo 'staging:'; ", + "stage-start": "export GISMO_ENVIRONMENT=staging; export GISMO_NAME=Gismo-test; cpl start", + "pre-prod-start": "echo 'production:'; ", + "prod-start": "export GISMO_ENVIRONMENT=production; export GISMO_NAME=Gismo-prod; cpl start" } } } \ No newline at end of file -- 2.45.2 From 3390e09ef3e50093b6635c9f340979f542f38320 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 25 Nov 2021 17:43:43 +0100 Subject: [PATCH 111/113] Added logic to prevent further event redirects if needed --- src/modules_core/abc/module_abc.py | 9 ++++++++- src/modules_core/service/module_service.py | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/modules_core/abc/module_abc.py b/src/modules_core/abc/module_abc.py index a970850..d860319 100644 --- a/src/modules_core/abc/module_abc.py +++ b/src/modules_core/abc/module_abc.py @@ -1,14 +1,21 @@ from abc import ABC, abstractmethod -import discord class ModuleABC(ABC): @abstractmethod def __init__(self): self._priorities = {} + self._success = True def get_priority(self, t: type) -> int: if t not in self._priorities: raise Exception(f'Priority for {t} not found!') return self._priorities[t] + + def stop_propagation(self): + self._success = False + + @property + def success(self) -> bool: + return self._success diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index 9760cf3..ddcbf56 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -84,15 +84,18 @@ class ModuleService(ModuleServiceABC, commands.Cog, metaclass=_MetaCogABC): modules = self._get_modules(event) if modules.count() < 1: - self._logger.debug(__name__, f'Stopped {event} modules') + self._logger.debug(__name__, f'Stopped {event} modules') return func_name = String.convert_to_snake_case(event.__name__.split('ABC')[0]) for module in modules: func = getattr(module, func_name) await func(*args) + if not module.success: + self._logger.debug(__name__, f'Stopped progation for {event} from {type(module)}') + break - self._logger.debug(__name__, f'Stopped {event} modules') + self._logger.debug(__name__, f'Stopped {event} modules') @commands.Cog.listener() async def on_connect(self): -- 2.45.2 From c6f460c0ab40916b0e534d0e7b3dfb72cf38eb6c Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 25 Nov 2021 20:45:16 +0100 Subject: [PATCH 112/113] Build packages --- src/database/__init__.py | 24 ++++++++++++++++++++++++ src/gismo_cli/__init__.py | 24 ++++++++++++++++++++++++ src/gismo_core/__init__.py | 4 ++-- src/gismo_core/abc/__init__.py | 4 ++-- src/gismo_core/configuration/__init__.py | 4 ++-- src/gismo_core/service/__init__.py | 4 ++-- src/gismo_db/__init__.py | 4 ++-- src/modules/boot_log/__init__.py | 6 +++--- src/modules_core/__init__.py | 4 ++-- src/modules_core/abc/__init__.py | 4 ++-- src/modules_core/service/__init__.py | 4 ++-- 11 files changed, 67 insertions(+), 19 deletions(-) diff --git a/src/database/__init__.py b/src/database/__init__.py index ad5eca3..099bca2 100644 --- a/src/database/__init__.py +++ b/src/database/__init__.py @@ -1 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +database sh-edraft Gismo - database core +~~~~~~~~~~~~~~~~~~~ + +sh-edraft Dicord bot Gismo - database implementation of cpl.database + +:copyright: (c) 2021 - 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'database' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' +__version__ = '0.1.0' + +from collections import namedtuple + # imports: + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='1', micro='0') diff --git a/src/gismo_cli/__init__.py b/src/gismo_cli/__init__.py index ad5eca3..8318a61 100644 --- a/src/gismo_cli/__init__.py +++ b/src/gismo_cli/__init__.py @@ -1 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +gismo-cli sh-edraft Gismo - CLI +~~~~~~~~~~~~~~~~~~~ + +sh-edraft Dicord bot Gismo - command line interface + +:copyright: (c) 2021 - 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'gismo_cli' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' +__version__ = '0.1.0' + +from collections import namedtuple + # imports: + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='0', minor='1', micro='0') diff --git a/src/gismo_core/__init__.py b/src/gismo_core/__init__.py index 2dcbf1d..4ee4e9e 100644 --- a/src/gismo_core/__init__.py +++ b/src/gismo_core/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -gismo sh-edraft Gismo +gismo-core sh-edraft Gismo - core ~~~~~~~~~~~~~~~~~~~ -sh-edraft Dicord bot Gismo +sh-edraft Dicord bot Gismo - core library :copyright: (c) 2021 - 2022 sh-edraft.de :license: MIT, see LICENSE for more details. diff --git a/src/gismo_core/abc/__init__.py b/src/gismo_core/abc/__init__.py index 79226e4..58b8479 100644 --- a/src/gismo_core/abc/__init__.py +++ b/src/gismo_core/abc/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -gismo sh-edraft Gismo +gismo-core sh-edraft Gismo - core ~~~~~~~~~~~~~~~~~~~ -sh-edraft Dicord bot Gismo +sh-edraft Dicord bot Gismo - core library :copyright: (c) 2021 - 2022 sh-edraft.de :license: MIT, see LICENSE for more details. diff --git a/src/gismo_core/configuration/__init__.py b/src/gismo_core/configuration/__init__.py index a5a1baa..3ae8faa 100644 --- a/src/gismo_core/configuration/__init__.py +++ b/src/gismo_core/configuration/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -gismo sh-edraft Gismo +gismo-core sh-edraft Gismo - core ~~~~~~~~~~~~~~~~~~~ -sh-edraft Dicord bot Gismo +sh-edraft Dicord bot Gismo - core library :copyright: (c) 2021 - 2022 sh-edraft.de :license: MIT, see LICENSE for more details. diff --git a/src/gismo_core/service/__init__.py b/src/gismo_core/service/__init__.py index 1947127..2eae97b 100644 --- a/src/gismo_core/service/__init__.py +++ b/src/gismo_core/service/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -gismo sh-edraft Gismo +gismo-core sh-edraft Gismo - core ~~~~~~~~~~~~~~~~~~~ -sh-edraft Dicord bot Gismo +sh-edraft Dicord bot Gismo - core library :copyright: (c) 2021 - 2022 sh-edraft.de :license: MIT, see LICENSE for more details. diff --git a/src/gismo_db/__init__.py b/src/gismo_db/__init__.py index 4265bbc..d9d752f 100644 --- a/src/gismo_db/__init__.py +++ b/src/gismo_db/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -gismo sh-edraft Gismo +gismo-db sh-edraft Gismo - Database ~~~~~~~~~~~~~~~~~~~ -sh-edraft Dicord bot Gismo +sh-edraft Dicord bot Gismo - Database :copyright: (c) 2021 - 2022 sh-edraft.de :license: MIT, see LICENSE for more details. diff --git a/src/modules/boot_log/__init__.py b/src/modules/boot_log/__init__.py index 3354a8e..78e0aa2 100644 --- a/src/modules/boot_log/__init__.py +++ b/src/modules/boot_log/__init__.py @@ -1,17 +1,17 @@ # -*- coding: utf-8 -*- """ -gismo sh-edraft Gismo +modules/boot-log sh-edraft Gismo - Boot log ~~~~~~~~~~~~~~~~~~~ -sh-edraft Dicord bot Gismo +sh-edraft Dicord bot Gismo - Boot log :copyright: (c) 2021 - 2022 sh-edraft.de :license: MIT, see LICENSE for more details. """ -__title__ = 'modules.boot_log' +__title__ = 'boot_log' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' diff --git a/src/modules_core/__init__.py b/src/modules_core/__init__.py index 979887f..9086fbb 100644 --- a/src/modules_core/__init__.py +++ b/src/modules_core/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -gismo sh-edraft Gismo +modules-core sh-edraft Gismo - Modules core ~~~~~~~~~~~~~~~~~~~ -sh-edraft Dicord bot Gismo +sh-edraft Dicord bot Gismo - Modules core :copyright: (c) 2021 - 2022 sh-edraft.de :license: MIT, see LICENSE for more details. diff --git a/src/modules_core/abc/__init__.py b/src/modules_core/abc/__init__.py index a65a733..c345cc5 100644 --- a/src/modules_core/abc/__init__.py +++ b/src/modules_core/abc/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -gismo sh-edraft Gismo +modules-core sh-edraft Gismo - Modules core ~~~~~~~~~~~~~~~~~~~ -sh-edraft Dicord bot Gismo +sh-edraft Dicord bot Gismo - Modules core :copyright: (c) 2021 - 2022 sh-edraft.de :license: MIT, see LICENSE for more details. diff --git a/src/modules_core/service/__init__.py b/src/modules_core/service/__init__.py index 3f494a0..6d10b94 100644 --- a/src/modules_core/service/__init__.py +++ b/src/modules_core/service/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -gismo sh-edraft Gismo +modules-core sh-edraft Gismo - Modules core ~~~~~~~~~~~~~~~~~~~ -sh-edraft Dicord bot Gismo +sh-edraft Dicord bot Gismo - Modules core :copyright: (c) 2021 - 2022 sh-edraft.de :license: MIT, see LICENSE for more details. -- 2.45.2 From df26a66562e081f53037c86c65930e3a27134e48 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 25 Nov 2021 20:55:59 +0100 Subject: [PATCH 113/113] Fixed typo --- src/modules_core/service/module_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules_core/service/module_service.py b/src/modules_core/service/module_service.py index ddcbf56..db61fbc 100644 --- a/src/modules_core/service/module_service.py +++ b/src/modules_core/service/module_service.py @@ -92,7 +92,7 @@ class ModuleService(ModuleServiceABC, commands.Cog, metaclass=_MetaCogABC): func = getattr(module, func_name) await func(*args) if not module.success: - self._logger.debug(__name__, f'Stopped progation for {event} from {type(module)}') + self._logger.debug(__name__, f'Stopped propagation for {event} from {type(module)}') break self._logger.debug(__name__, f'Stopped {event} modules') -- 2.45.2