0.3 #146

Merged
edraft merged 359 commits from 0.3 into master 2023-01-12 07:04:40 +01:00
4 changed files with 140 additions and 10 deletions
Showing only changes of commit 7ed30c40be - Show all commits

View File

@ -150,7 +150,17 @@
"login_message": "Ich bin on the line :D\nDer Scheiß hat {} Sekunden gedauert"
},
"level": {
"new_level_message": "<@{}> ist nun Level {}"
"new_level_message": "<@{}> ist nun Level {}",
"error": {
"nothing_found": "Keine auto-role Einträge gefunden."
},
"list": {
"title": "Level:",
"description": "Konfigurierte Level:",
"name": "Name",
"min_xp": "Mindest XP",
"permission_int": "Berechtigungen"
}
},
"database": {},
"permission": {
@ -166,15 +176,15 @@
"message": "Dies ist eine Test-Mail vom Krümmelmonster Web Interface\nGesendet von {}-{}"
}
},
"auth": {
"confirmation": {
"subject": "E-Mail für {} {} bestätigen",
"message": "Öffne den Link um die E-Mail zu bestätigen:\n{}auth/register/{}"
},
"forgot_password": {
"subject": "Passwort für {} {} zurücksetzen",
"message": "Öffne den Link um das Passwort zu ändern:\n{}auth/forgot-password/{}"
}
"auth": {
"confirmation": {
"subject": "E-Mail für {} {} bestätigen",
"message": "Öffne den Link um die E-Mail zu bestätigen:\n{}auth/register/{}"
},
"forgot_password": {
"subject": "Passwort für {} {} zurücksetzen",
"message": "Öffne den Link um das Passwort zu ändern:\n{}auth/forgot-password/{}"
}
}
}
}

View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
"""
bot Keksdose bot
~~~~~~~~~~~~~~~~~~~
Discord bot for the Keksdose discord Server
:copyright: (c) 2022 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'modules.level.command'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '0.3.dev29'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='3', micro='dev29')

View File

@ -0,0 +1,89 @@
import discord
from cpl_core.database.context import DatabaseContextABC
from cpl_discord.command import DiscordCommandABC
from cpl_discord.service import DiscordBotServiceABC
from cpl_translation import TranslatePipe
from discord.ext import commands
from discord.ext.commands import Context
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
from bot_core.abc.message_service_abc import MessageServiceABC
from bot_core.logging.command_logger import CommandLogger
from bot_data.abc.level_repository_abc import LevelRepositoryABC
from bot_data.abc.server_repository_abc import ServerRepositoryABC
from modules.permission.abc.permission_service_abc import PermissionServiceABC
class LevelGroup(DiscordCommandABC):
def __init__(
self,
logger: CommandLogger,
message_service: MessageServiceABC,
bot: DiscordBotServiceABC,
client_utils: ClientUtilsServiceABC,
permission_service: PermissionServiceABC,
translate: TranslatePipe,
db_context: DatabaseContextABC,
levels: LevelRepositoryABC,
servers: ServerRepositoryABC,
):
DiscordCommandABC.__init__(self)
self._logger = logger
self._message_service = message_service
self._bot = bot
self._client_utils = client_utils
self._permissions = permission_service
self._t = translate
self._db_context = db_context
self._levels = levels
self._servers = servers
self._logger.trace(__name__, f'Loaded command service: {type(self).__name__}')
@commands.hybrid_group()
@commands.guild_only()
async def level(self, ctx: Context):
pass
@level.command(alias='levels')
@commands.guild_only()
async def list(self, ctx: Context, wait: int = None):
self._logger.debug(__name__, f'Received command level list {ctx}')
if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx):
return
if not self._permissions.is_member_moderator(ctx.author):
await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message'))
self._logger.trace(__name__, f'Finished command level list')
return
if ctx.guild is None:
return
server = self._servers.get_server_by_discord_id(ctx.guild.id)
levels = self._levels.get_levels_by_server_id(server.server_id)
if levels.count() < 1:
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.error.nothing_found'))
self._logger.trace(__name__, f'Finished command level list')
return
level_name = ''
xp = ''
permissions = ''
for level in levels:
level_name += f'\n{level.name}'
xp += f'\n{level.min_xp}'
permissions += f'\n{level.permissions}'
embed = discord.Embed(
title=self._t.transform('modules.level.list.title'),
description=self._t.transform('modules.level.list.description'),
color=int('ef9d0d', 16)
)
embed.add_field(name=self._t.transform('modules.level.list.name'), value=level_name, inline=True)
embed.add_field(name=self._t.transform('modules.level.list.min_xp'), value=xp, inline=True)
embed.add_field(name=self._t.transform('modules.level.list.permission_int'), value=permissions, inline=True)
await self._message_service.send_ctx_msg(ctx, embed, wait_before_delete=wait)
self._logger.trace(__name__, f'Finished command level list')

View File

@ -8,6 +8,7 @@ from cpl_discord.service.discord_collection_abc import DiscordCollectionABC
from bot_core.abc.module_abc import ModuleABC
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
from modules.level.command.level_group import LevelGroup
from modules.level.events.level_on_message_event import LevelOnMessageEvent
from modules.level.events.level_on_voice_state_update_event import LevelOnVoiceStateUpdateEvent
from modules.level.level_seeder import LevelSeeder
@ -29,5 +30,9 @@ class LevelModule(ModuleABC):
services.add_transient(LevelSeeder)
services.add_transient(LevelService)
# commands
self._dc.add_command(LevelGroup)
# events
self._dc.add_event(DiscordEventTypesEnum.on_message.value, LevelOnMessageEvent)
self._dc.add_event(DiscordEventTypesEnum.on_voice_state_update.value, LevelOnVoiceStateUpdateEvent)