Compare commits
5 Commits
ba173a6743
...
dev
Author | SHA1 | Date | |
---|---|---|---|
266dacb301 | |||
280cd9827d | |||
36998470e8 | |||
53c6bf4208 | |||
4e80e3ccb7 |
@@ -11,7 +11,7 @@ jobs:
|
||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||
steps:
|
||||
- name: Shutdown stack
|
||||
run: docker stack rm sdb_test
|
||||
run: docker stack rm sdb_staging
|
||||
|
||||
build-bot:
|
||||
needs: pre-build
|
||||
|
@@ -33,7 +33,8 @@
|
||||
"cryptography==41.0.4",
|
||||
"discord==2.3.2",
|
||||
"bs4==0.0.1",
|
||||
"lxml==4.9.3"
|
||||
"lxml==4.9.3",
|
||||
"python-valve==0.2.1"
|
||||
],
|
||||
"DevDependencies": [
|
||||
"cpl-cli==2023.4.0.post3",
|
||||
|
@@ -11,6 +11,7 @@ from flask import request
|
||||
from bot_api.configuration.authentication_settings import AuthenticationSettings
|
||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||
from bot_core.service.permission_service import PermissionService
|
||||
from bot_data.abc.api_key_repository_abc import ApiKeyRepositoryABC
|
||||
from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
@@ -24,7 +25,6 @@ from bot_data.model.server_config import ServerConfig
|
||||
from bot_data.model.user_joined_game_server import UserJoinedGameServer
|
||||
from bot_data.model.user_role_enum import UserRoleEnum
|
||||
from bot_graphql.abc.query_abc import QueryABC
|
||||
from bot_core.service.permission_service import PermissionService
|
||||
|
||||
|
||||
class UserJoinedGameServerMutation(QueryABC):
|
||||
@@ -79,7 +79,10 @@ class UserJoinedGameServerMutation(QueryABC):
|
||||
)
|
||||
|
||||
def resolve_user_joined(self, *_, input: dict):
|
||||
game_ident = self._user_game_idents.get_user_game_ident_by_ident(input["ident"])
|
||||
game_ident = self._user_game_idents.find_user_game_ident_by_ident(input["ident"])
|
||||
if game_ident is None:
|
||||
return
|
||||
|
||||
user = game_ident.user
|
||||
|
||||
settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}")
|
||||
|
@@ -9,6 +9,7 @@ from cpl_translation import TranslatePipe
|
||||
from discord import app_commands
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands import Context
|
||||
from valve.steam.id import SteamID
|
||||
|
||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||
@@ -50,6 +51,17 @@ class RegisterGroup(DiscordCommandABC):
|
||||
|
||||
self._logger.trace(__name__, f"Loaded command service: {type(self).__name__}")
|
||||
|
||||
async def _game_server_autocomplete(
|
||||
self, interaction: discord.Interaction, current: str
|
||||
) -> TList[app_commands.Choice[str]]:
|
||||
server = self._servers.get_server_by_discord_id(interaction.guild.id)
|
||||
game_servers = self._game_server.get_game_servers_by_server_id(server.id)
|
||||
|
||||
return [
|
||||
app_commands.Choice(name=gs.name, value=gs.id)
|
||||
for gs in self._client_utils.get_auto_complete_list(game_servers, current, lambda x: x.name)
|
||||
]
|
||||
|
||||
@commands.hybrid_group()
|
||||
@commands.guild_only()
|
||||
async def register(self, ctx: Context):
|
||||
@@ -101,10 +113,44 @@ class RegisterGroup(DiscordCommandABC):
|
||||
async def game_server_autocomplete(
|
||||
self, interaction: discord.Interaction, current: str
|
||||
) -> TList[app_commands.Choice[str]]:
|
||||
server = self._servers.get_server_by_discord_id(interaction.guild.id)
|
||||
game_servers = self._game_server.get_game_servers_by_server_id(server.id)
|
||||
return await self._game_server_autocomplete(interaction, current)
|
||||
|
||||
return [
|
||||
app_commands.Choice(name=gs.name, value=gs.id)
|
||||
for gs in self._client_utils.get_auto_complete_list(game_servers, current, lambda x: x.name)
|
||||
]
|
||||
@register.command()
|
||||
@commands.guild_only()
|
||||
@CommandChecks.check_is_ready()
|
||||
@CommandChecks.check_is_member_moderator()
|
||||
async def gmod(self, ctx: Context, member: discord.Member, game_server: int, steam_url: str):
|
||||
self._logger.debug(__name__, f"Received command register gmod {ctx}")
|
||||
|
||||
steam_id = None
|
||||
try:
|
||||
self._logger.debug(__name__, f"Try to get steam id for {id}")
|
||||
steam_id = SteamID.from_community_url(steam_url)
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f"Get steam id for {steam_id} failed", e)
|
||||
await self._message_service.send_interaction_msg(
|
||||
ctx.interaction, self._t.transform("modules.base.register.not_found")
|
||||
)
|
||||
|
||||
if steam_id is None:
|
||||
return
|
||||
|
||||
server = self._servers.get_server_by_discord_id(ctx.guild.id)
|
||||
user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id)
|
||||
gs = self._game_server.get_game_server_by_id(game_server)
|
||||
|
||||
game_ident = UserGameIdent(user, gs, steam_id)
|
||||
self._user_game_ident.add_user_game_ident(game_ident)
|
||||
self._db.save_changes()
|
||||
|
||||
await self._message_service.send_interaction_msg(
|
||||
ctx.interaction, self._t.transform("modules.base.register.success")
|
||||
)
|
||||
|
||||
self._logger.trace(__name__, f"Finished register gmod command")
|
||||
|
||||
@gmod.autocomplete("game_server")
|
||||
async def game_server_autocomplete(
|
||||
self, interaction: discord.Interaction, current: str
|
||||
) -> TList[app_commands.Choice[str]]:
|
||||
return await self._game_server_autocomplete(interaction, current)
|
||||
|
@@ -9,7 +9,7 @@ from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_core.logging import LoggerABC
|
||||
from cpl_discord.container import Guild
|
||||
from cpl_query.extension import List
|
||||
from discord import PrivacyLevel
|
||||
from discord import PrivacyLevel, EventStatus
|
||||
from discord.scheduled_event import ScheduledEvent as DiscordEvent
|
||||
|
||||
from bot_data.abc.scheduled_event_repository_abc import ScheduledEventRepositoryABC
|
||||
@@ -106,6 +106,7 @@ class EventService:
|
||||
lambda x: x.name == scheduled_event.name
|
||||
and x.description == scheduled_event.description
|
||||
and x.entity_type == scheduled_event.entity_type
|
||||
and x.status == EventStatus.scheduled
|
||||
)
|
||||
if from_guild.count() != 0:
|
||||
self._logger.debug(__name__, f"Event {scheduled_event.name} already exists on discord server")
|
||||
|
Reference in New Issue
Block a user