Merge pull request '#293_complaints' (#326) from #293_complaints into 1.1.0

Reviewed-on: sh-edraft.de/kd_discord_bot#326
Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de>
This commit is contained in:
Sven Heidemann 2023-08-14 09:37:08 +02:00
commit a869ee4780
6 changed files with 161 additions and 0 deletions

View File

@ -151,6 +151,18 @@
} }
}, },
"base": { "base": {
"complaints": {
"title": "Beschwerde einreichen",
"label": "Beschwerde",
"message": "{} hat eine Beschwerde eingereicht:\n{}",
"response": "Danke für deine Beschwerde"
},
"bug": {
"title": "Bug melden",
"label": "Bug",
"message": "{} meldet einen Bug:\n{}",
"response": "Danke für dein Feedback :D"
},
"afk_command_channel_missing_message": "Zu unfähig einem Sprachkanal beizutreten?", "afk_command_channel_missing_message": "Zu unfähig einem Sprachkanal beizutreten?",
"afk_command_move_message": "Ich verschiebe dich ja schon... (◔_◔)", "afk_command_move_message": "Ich verschiebe dich ja schon... (◔_◔)",
"game_server": { "game_server": {

View File

@ -16,6 +16,7 @@ from modules.base.command.ping_command import PingCommand
from modules.base.command.presence_command import PresenceCommand from modules.base.command.presence_command import PresenceCommand
from modules.base.command.purge_command import PurgeCommand from modules.base.command.purge_command import PurgeCommand
from modules.base.command.register_group import RegisterGroup from modules.base.command.register_group import RegisterGroup
from modules.base.command.submit_group import SubmitGroup
from modules.base.command.unregister_group import UnregisterGroup from modules.base.command.unregister_group import UnregisterGroup
from modules.base.command.user_group import UserGroup from modules.base.command.user_group import UserGroup
from modules.base.events.base_on_command_error_event import BaseOnCommandErrorEvent from modules.base.events.base_on_command_error_event import BaseOnCommandErrorEvent
@ -36,6 +37,8 @@ from modules.base.events.base_on_voice_state_update_event_help_channel import (
from modules.base.events.base_on_voice_state_update_event_scheduled_event_bonus import ( from modules.base.events.base_on_voice_state_update_event_scheduled_event_bonus import (
BaseOnVoiceStateUpdateEventScheduledEventBonus, BaseOnVoiceStateUpdateEventScheduledEventBonus,
) )
from modules.base.forms.bug_report_form import BugReportForm
from modules.base.forms.complaint_form import ComplaintForm
from modules.base.helper.base_reaction_handler import BaseReactionHandler from modules.base.helper.base_reaction_handler import BaseReactionHandler
from modules.base.service.base_helper_service import BaseHelperService from modules.base.service.base_helper_service import BaseHelperService
from modules.base.service.event_service import EventService from modules.base.service.event_service import EventService
@ -55,8 +58,13 @@ class BaseModule(ModuleABC):
services.add_singleton(EventService) services.add_singleton(EventService)
services.add_transient(UserWarningsService) services.add_transient(UserWarningsService)
# forms
services.add_singleton(BugReportForm)
services.add_singleton(ComplaintForm)
# commands # commands
self._dc.add_command(AFKCommand) self._dc.add_command(AFKCommand)
self._dc.add_command(SubmitGroup)
self._dc.add_command(HelpCommand) self._dc.add_command(HelpCommand)
self._dc.add_command(InfoCommand) self._dc.add_command(InfoCommand)
self._dc.add_command(MassMoveCommand) self._dc.add_command(MassMoveCommand)

View File

@ -0,0 +1,43 @@
from cpl_core.logging import LoggerABC
from cpl_discord.command import DiscordCommandABC
from cpl_discord.service import DiscordBotServiceABC
from discord.ext import commands
from discord.ext.commands import Context
from bot_core.helper.command_checks import CommandChecks
from modules.base.forms.bug_report_form import BugReportForm
from modules.base.forms.complaint_form import ComplaintForm
class SubmitGroup(DiscordCommandABC):
def __init__(
self, logger: LoggerABC, bot: DiscordBotServiceABC, complaint_form: ComplaintForm, bug_form: BugReportForm
):
DiscordCommandABC.__init__(self)
self._logger = logger
self._bot = bot
self._complaint_form = complaint_form
self._bug_form = bug_form
@commands.hybrid_group()
@commands.guild_only()
async def submit(self, ctx: Context):
pass
@submit.command()
@commands.guild_only()
@CommandChecks.check_is_ready()
async def complaint(self, ctx: Context):
self._logger.debug(__name__, f"Received command complaint {ctx}")
await ctx.interaction.response.send_modal(self._complaint_form)
self._logger.trace(__name__, f"Finished command complaint {ctx}")
pass
@submit.command()
@commands.guild_only()
@CommandChecks.check_is_ready()
async def bug_report(self, ctx: Context):
self._logger.debug(__name__, f"Received command complaint {ctx}")
await ctx.interaction.response.send_modal(self._bug_form)
self._logger.trace(__name__, f"Finished command complaint {ctx}")

View File

@ -0,0 +1 @@
# imports

View File

@ -0,0 +1,50 @@
import discord
from cpl_core.database.context import DatabaseContextABC
from cpl_discord.service import DiscordBotServiceABC
from cpl_translation import TranslatePipe
from discord import ui, TextStyle
from bot_core.abc.message_service_abc import MessageServiceABC
from bot_core.configuration.bot_settings import BotSettings
from bot_core.logging.command_logger import CommandLogger
from modules.base.service.base_helper_service import BaseHelperService
class BugReportForm(ui.Modal):
description = ui.TextInput(label="Report a bug", required=True, style=TextStyle.long)
def __init__(
self,
bot_settings: BotSettings,
bot: DiscordBotServiceABC,
db: DatabaseContextABC,
logger: CommandLogger,
message_service: MessageServiceABC,
base_helper: BaseHelperService,
t: TranslatePipe,
):
ui.Modal.__init__(self, title=t.transform("modules.base.bug.title"))
self._bot_settings = bot_settings
self._bot = bot
self._db = db
self._message_service = message_service
self._logger = logger
self._base_helper = base_helper
self._t = t
self.description.label = t.transform("modules.base.bug.label")
async def on_submit(self, interaction: discord.Interaction):
self._logger.debug(__name__, f"Started bug report form")
for t in self._bot_settings.technicians:
member = self._bot.get_user(t)
await self._message_service.send_dm_message(
self._t.transform("modules.base.bug.message").format(interaction.user.mention, self.description.value),
member,
without_tracking=True,
)
await self._message_service.send_interaction_msg(interaction, self._t.transform("modules.base.bug.response"))
self._logger.trace(__name__, f"Finished bug report form")

View File

@ -0,0 +1,47 @@
import discord
from cpl_core.database.context import DatabaseContextABC
from cpl_translation import TranslatePipe
from discord import ui, TextStyle
from bot_core.abc.message_service_abc import MessageServiceABC
from bot_core.logging.command_logger import CommandLogger
from modules.base.configuration.base_server_settings import BaseServerSettings
from modules.base.service.base_helper_service import BaseHelperService
class ComplaintForm(ui.Modal):
description = ui.TextInput(label="Complain about something", required=True, style=TextStyle.long)
def __init__(
self,
db: DatabaseContextABC,
logger: CommandLogger,
message_service: MessageServiceABC,
base_helper: BaseHelperService,
t: TranslatePipe,
):
ui.Modal.__init__(self, title=t.transform("modules.base.complaints.title"))
self._db = db
self._message_service = message_service
self._logger = logger
self._base_helper = base_helper
self._t = t
self.description.label = t.transform("modules.base.complaints.label")
async def on_submit(self, interaction: discord.Interaction):
self._logger.debug(__name__, f"Started complaint command form")
settings: BaseServerSettings = self._base_helper.get_config(interaction.guild.id)
channel = interaction.guild.get_channel(settings.team_channel_id)
await self._message_service.send_channel_message(
channel,
self._t.transform("modules.base.complaints.message").format(
interaction.user.mention, self.description.value
),
is_persistent=True,
)
await self._message_service.send_interaction_msg(
interaction, self._t.transform("modules.base.complaints.response")
)
self._logger.trace(__name__, f"Finished complaint command form")