From 558d134bd75557b73e36c3ab85bd856b5dff1543 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 8 Jan 2022 19:35:14 +0100 Subject: [PATCH] Bugfixes for last changes --- .idea/sh_gismo.iml | 1 + src/gismo/startup.py | 2 +- src/gismo_core/service/message_service.py | 8 ++++---- src/modules/boot_log/boot_log.py | 2 +- src/modules/database/database.py | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.idea/sh_gismo.iml b/.idea/sh_gismo.iml index 755c55c..5c3e694 100644 --- a/.idea/sh_gismo.iml +++ b/.idea/sh_gismo.iml @@ -3,6 +3,7 @@ + diff --git a/src/gismo/startup.py b/src/gismo/startup.py index a9378a2..5f64d5e 100644 --- a/src/gismo/startup.py +++ b/src/gismo/startup.py @@ -106,7 +106,7 @@ class Startup(StartupABC): provider: ServiceProviderABC = services.build_service_provider() - startup_init_time = round((datetime.now() - self._config.get_configuration('Startup_StartTime')).total_seconds(), 2) + startup_init_time = round((datetime.now() - datetime.strptime(self._config.get_configuration('Startup_StartTime'), '%Y-%m-%d %H:%M:%S.%f')).total_seconds(), 2) self._config.add_configuration('Startup_InitTime', str(startup_init_time)) logger: LoggerABC = provider.get_service(LoggerABC) logger.debug(__name__, f'Startup Init time: {startup_init_time}s') diff --git a/src/gismo_core/service/message_service.py b/src/gismo_core/service/message_service.py index 75df1fd..78e113e 100644 --- a/src/gismo_core/service/message_service.py +++ b/src/gismo_core/service/message_service.py @@ -42,7 +42,7 @@ class MessageService(MessageServiceABC): except Exception as e: self._logger.error(__name__, f'Deleting message failed', e) else: - self._clients.apppend_deleted_message_count(self._bot.user.id, guild_id, 1) + self._clients.append_deleted_message_count(self._bot.user.id, guild_id, 1) self._db.save_changes() self._logger.info(__name__, f'Deleted message {message}') @@ -55,7 +55,7 @@ class MessageService(MessageServiceABC): 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}') - self._clients.apppend_sent_message_count(self._bot.user.id, channel.guild.id, 1) + self._clients.append_sent_message_count(self._bot.user.id, channel.guild.id, 1) self._db.save_changes() await self.delete_message(msg) @@ -66,7 +66,7 @@ class MessageService(MessageServiceABC): except Exception as e: self._logger.error(__name__, f'Send message to user {receiver.id} failed', e) else: - self._clients.apppend_sent_message_count(self._bot.user.id, receiver.guild.id, 1) + self._clients.append_sent_message_count(self._bot.user.id, receiver.guild.id, 1) self._db.save_changes() self._logger.info(__name__, f'Sent message to user {receiver.id}') @@ -87,6 +87,6 @@ class MessageService(MessageServiceABC): 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}') - self._clients.apppend_sent_message_count(self._bot.user.id, ctx.guild.id, 1) + self._clients.append_sent_message_count(self._bot.user.id, ctx.guild.id, 1) self._db.save_changes() await self.delete_messages(List(discord.Message, [msg, ctx.message])) diff --git a/src/modules/boot_log/boot_log.py b/src/modules/boot_log/boot_log.py index dd9261f..0b03ffd 100644 --- a/src/modules/boot_log/boot_log.py +++ b/src/modules/boot_log/boot_log.py @@ -41,7 +41,7 @@ class BootLog(ModuleABC, OnReadyABC): self._logger.debug(__name__, f'Module {type(self)} started') try: start_time = self._config.get_configuration('Bot_StartTime') - init_time = round((datetime.now() - start_time).total_seconds(), 2) + init_time = round((datetime.now() - datetime.strptime(start_time, '%Y-%m-%d %H:%M:%S.%f')).total_seconds(), 2) self._config.add_configuration('InitTime', str(init_time)) self._logger.debug(__name__, f'Bot Init time: {init_time}s') # print warning if initialisation took too long diff --git a/src/modules/database/database.py b/src/modules/database/database.py index 65ea8a8..0fd7daf 100644 --- a/src/modules/database/database.py +++ b/src/modules/database/database.py @@ -63,7 +63,7 @@ class Database(ModuleABC, OnReadyABC): def _validate_init_time(self): try: start_time = self._config.get_configuration('Database_StartTime') - init_time = round((datetime.now() - start_time).total_seconds(), 2) + init_time = round((datetime.now() - datetime.strptime(start_time, '%Y-%m-%d %H:%M:%S.%f')).total_seconds(), 2) self._config.add_configuration('Database_InitTime', str(init_time)) self._logger.debug(__name__, f'Database Init time: {init_time}s') # print warning if initialisation took too long