From 3abaee3e71a0ca72aab6c5d68e55ec23a5a01a7f Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 11 Jan 2023 17:25:51 +0100 Subject: [PATCH 1/3] Added logic to save vc_state_update when changing channel #165 --- kdb-bot/docker | 2 +- kdb-bot/src/bot/config | 2 +- .../src/modules/base/events/base_on_voice_state_update_event.py | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kdb-bot/docker b/kdb-bot/docker index 48c26839..6b25cc87 160000 --- a/kdb-bot/docker +++ b/kdb-bot/docker @@ -1 +1 @@ -Subproject commit 48c2683965611c9a96ebbb908f8dcb4d0d7d71f2 +Subproject commit 6b25cc87fced30b5846505d95f20285a3e4d7adf diff --git a/kdb-bot/src/bot/config b/kdb-bot/src/bot/config index e6faabbd..9262f4f8 160000 --- a/kdb-bot/src/bot/config +++ b/kdb-bot/src/bot/config @@ -1 +1 @@ -Subproject commit e6faabbd8b9fe0dbd00533ea1647e7094ea8b19e +Subproject commit 9262f4f88f68f8461cfbc0a5ef3f4d89edf78c7b diff --git a/kdb-bot/src/modules/base/events/base_on_voice_state_update_event.py b/kdb-bot/src/modules/base/events/base_on_voice_state_update_event.py index 176977a9..83794725 100644 --- a/kdb-bot/src/modules/base/events/base_on_voice_state_update_event.py +++ b/kdb-bot/src/modules/base/events/base_on_voice_state_update_event.py @@ -116,5 +116,7 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): else: self._logger.trace(__name__, f'User {member.id} switched to {after.channel}') + self._update_voice_state(False, member.id, before.channel.id, server) + self._update_voice_state(True, member.id, after.channel.id, server) except Exception as e: self._logger.error(__name__, f'Cannot handle voice state for user {member.id}', e) From d10c33c6c29bb2045074ac10393cf25335b823b4 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 11 Jan 2023 17:53:21 +0100 Subject: [PATCH 2/3] Added logic to log reactions #169 --- .../modules/base/helper/base_reaction_handler.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/kdb-bot/src/modules/base/helper/base_reaction_handler.py b/kdb-bot/src/modules/base/helper/base_reaction_handler.py index eb75a54a..a5fd0099 100644 --- a/kdb-bot/src/modules/base/helper/base_reaction_handler.py +++ b/kdb-bot/src/modules/base/helper/base_reaction_handler.py @@ -3,6 +3,7 @@ from cpl_core.logging import LoggerABC from cpl_discord.service import DiscordBotServiceABC from discord import RawReactionActionEvent +from bot_core.helper.log_message_helper import LogMessageHelper from bot_data.abc.server_repository_abc import ServerRepositoryABC from bot_data.abc.user_repository_abc import UserRepositoryABC from modules.base.abc.base_helper_abc import BaseHelperABC @@ -36,6 +37,20 @@ class BaseReactionHandler: self._logger.warn(__name__, f'User {payload.user_id} in {guild.name} not found - skipping') return + try: + log_msg = f'{member.name} reacted' + if payload.emoji.name is not None: + log_msg += f' with {payload.emoji.name}' + try: + channel = guild.get_channel(payload.channel_id) + message = await channel.fetch_message(payload.message_id) + self._logger.info(__name__, f'{log_msg} to message {LogMessageHelper.get_log_string(message)}') + except Exception as e: + self._logger.error(__name__, f'Getting message for reaction logging failed', e) + self._logger.info(__name__, f'{log_msg} to message {payload.message_id}') + except Exception as e: + self._logger.error(__name__, f'Reaction logging failed', e) + if member.bot: return From 09fbc27981641bb0f830fb9bf2cd68a59084959b Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 11 Jan 2023 22:16:13 +0100 Subject: [PATCH 3/3] Added optional feature-flag files --- kdb-bot/src/bot/config | 2 +- kdb-bot/src/bot/startup_settings_extension.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/kdb-bot/src/bot/config b/kdb-bot/src/bot/config index 9262f4f8..28bd879d 160000 --- a/kdb-bot/src/bot/config +++ b/kdb-bot/src/bot/config @@ -1 +1 @@ -Subproject commit 9262f4f88f68f8461cfbc0a5ef3f4d89edf78c7b +Subproject commit 28bd879dab2e5ea6ca8bb38e44c7786eb67cb7a2 diff --git a/kdb-bot/src/bot/startup_settings_extension.py b/kdb-bot/src/bot/startup_settings_extension.py index 655ccd7b..71896c69 100644 --- a/kdb-bot/src/bot/startup_settings_extension.py +++ b/kdb-bot/src/bot/startup_settings_extension.py @@ -31,6 +31,8 @@ class StartupSettingsExtension(StartupExtensionABC): configuration.add_json_file(f'config/appsettings.{environment.host_name}.json', optional=True) # load feature-flags configuration.add_json_file(f'config/feature-flags.json', optional=False) + configuration.add_json_file(f'config/feature-flags.{environment.environment_name}.json', optional=True) + configuration.add_json_file(f'config/feature-flags.{environment.host_name}.json', optional=True) configuration.add_configuration('Startup_StartTime', str(self._start_time)) self._configure_settings_with_sub_settings(configuration, BotSettings, lambda x: x.servers, lambda x: x.id)