0.4.3 - Befehl AFK #41
@ -14,15 +14,19 @@
|
||||
"permission": "src/modules/permission/permission.json"
|
||||
},
|
||||
"Scripts": {
|
||||
"build-start": "cd src/gismo_cli; echo 'gismo-cli:'; cpl build; cd ../gismo; echo 'gismo:'; cpl build; cd ../../dist/gismo/build/gismo; bash gismo",
|
||||
"build-gismo": "cd src/gismo; echo 'gismo:'; cpl build; cd ../../;",
|
||||
"build-gismo-cli": "cd src/gismo_cli; echo 'gismo-cli:'; cpl build; cd ../../;",
|
||||
"build-start": "cpl build-gismo-cli; cpl build-gismo; cd dist/gismo/build/gismo; bash gismo",
|
||||
"bs": "cpl build-start",
|
||||
"build-all": "cpl build-gismo-cli; cpl build-gismo;",
|
||||
"ba": "cpl build-all",
|
||||
"pre-build": "cd ../gismo_cli; echo 'gismo-cli:'; cpl build; echo 'gismo:'",
|
||||
"pre-start": "if [ -z $GISMO_ENVIRONMENT ]; then echo '!WARNING! You should start with the right environment!\nRun cpl start-ENV\nSee workspace for more details.'; sleep 2; fi",
|
||||
"pre-dev": "echo 'development:'; ",
|
||||
"pre-dev": "echo 'development:';",
|
||||
"dev": "export GISMO_ENVIRONMENT=development; export GISMO_NAME=Gismo-dev; cpl start",
|
||||
"pre-test": "echo 'staging:'; ",
|
||||
"pre-test": "echo 'staging:';",
|
||||
"test": "export GISMO_ENVIRONMENT=staging; export GISMO_NAME=Gismo-test; cpl start",
|
||||
"pre-prod": "echo 'production:'; ",
|
||||
"pre-prod": "echo 'production:';",
|
||||
"prod": "export GISMO_ENVIRONMENT=production; export GISMO_NAME=Gismo-prod; cpl start"
|
||||
}
|
||||
}
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'gismo'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||
__version__ = '0.3.0'
|
||||
__version__ = '0.4.3'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='0', minor='3', micro='0')
|
||||
version_info = VersionInfo(major='0', minor='4', micro='3')
|
||||
|
@ -11,6 +11,9 @@
|
||||
910199452915093594
|
||||
],
|
||||
"PurgeMessage": "Ja mein Herr, ich lösche alle Nachrichten!",
|
||||
"NoPermissionsMessage": "Nein!\nIch höre nicht auf dich ¯\\_(ツ)_/¯"
|
||||
"NoPermissionsMessage": "Nein!\nIch höre nicht auf dich ¯\\_(ツ)_/¯",
|
||||
"AFKCommandChannelId": 910199452915093594,
|
||||
"AFKCommandChannelMissingMessage": "Zu unfähig einem Sprachkanal beizutreten?",
|
||||
"AFKCommandMoveMessage": "Ich verschiebe dich ja schon... (◔_◔)"
|
||||
}
|
||||
}
|
@ -3,8 +3,8 @@
|
||||
"Name": "gismo",
|
||||
"Version": {
|
||||
"Major": "0",
|
||||
"Minor": "3",
|
||||
"Micro": "0"
|
||||
"Minor": "4",
|
||||
"Micro": "3"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'gismo_core'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||
__version__ = '0.3.0'
|
||||
__version__ = '0.4.3'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='0', minor='3', micro='0')
|
||||
version_info = VersionInfo(major='0', minor='4', micro='3')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'gismo_core.abc'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||
__version__ = '0.3.0'
|
||||
__version__ = '0.4.3'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='0', minor='3', micro='0')
|
||||
version_info = VersionInfo(major='0', minor='4', micro='3')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'gismo_core.configuration'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||
__version__ = '0.3.0'
|
||||
__version__ = '0.4.3'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='0', minor='3', micro='0')
|
||||
version_info = VersionInfo(major='0', minor='4', micro='3')
|
||||
|
@ -11,6 +11,7 @@ class ServerSettings(ConfigurationModelABC):
|
||||
|
||||
self._id: int = 0
|
||||
self._message_delete_timer: int = 0
|
||||
self._bot_has_no_permission_message: str = ''
|
||||
|
||||
@property
|
||||
def id(self) -> str:
|
||||
@ -20,10 +21,15 @@ class ServerSettings(ConfigurationModelABC):
|
||||
def message_delete_timer(self) -> int:
|
||||
return self._message_delete_timer
|
||||
|
||||
@property
|
||||
def bot_has_no_permission_message(self) -> str:
|
||||
return self._bot_has_no_permission_message
|
||||
|
||||
def from_dict(self, settings: dict):
|
||||
try:
|
||||
self._id = int(settings['Id'])
|
||||
self._message_delete_timer = int(settings['MessageDeleteTimer'])
|
||||
self._message_delete_timer = int(settings['MessageDeleteTimer'])
|
||||
self._bot_has_no_permission_message = settings['BotHasNoPermissionMessage']
|
||||
except Exception as e:
|
||||
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in settings')
|
||||
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'gismo_core.service'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||
__version__ = '0.3.0'
|
||||
__version__ = '0.4.3'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='0', minor='3', micro='0')
|
||||
version_info = VersionInfo(major='0', minor='4', micro='3')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'gismo_data'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||
__version__ = '0.3.0'
|
||||
__version__ = '0.4.3'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='0', minor='3', micro='0')
|
||||
version_info = VersionInfo(major='0', minor='4', micro='3')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'gismo_data.abc'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||
__version__ = '0.3.0'
|
||||
__version__ = '0.4.3'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='0', minor='3', micro='0')
|
||||
version_info = VersionInfo(major='0', minor='4', micro='3')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'gismo_data.migration'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||
__version__ = '0.3.0'
|
||||
__version__ = '0.4.3'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='0', minor='3', micro='0')
|
||||
version_info = VersionInfo(major='0', minor='4', micro='3')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'gismo_data.model'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||
__version__ = '0.3.0'
|
||||
__version__ = '0.4.3'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='0', minor='3', micro='0')
|
||||
version_info = VersionInfo(major='0', minor='4', micro='3')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'gismo_data.service'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||
__version__ = '0.3.0'
|
||||
__version__ = '0.4.3'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='0', minor='3', micro='0')
|
||||
version_info = VersionInfo(major='0', minor='4', micro='3')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'modules.base'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||
__version__ = '0.3.0'
|
||||
__version__ = '0.4.3'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='0', minor='3', micro='0')
|
||||
version_info = VersionInfo(major='0', minor='4', micro='3')
|
||||
|
@ -246,24 +246,24 @@ class Base(ModuleABC, OnMemberJoinABC, OnMemberRemoveABC, OnMessageABC, OnVoiceS
|
||||
# join
|
||||
if before.channel is None and after.channel is not None and after.channel.id not in settings.afk_channel_ids:
|
||||
self._logger.trace(__name__, f'User {u.id} joined {after.channel}')
|
||||
self._update_voice_state(True, member.id, after.channel.id, server.server_id)
|
||||
self._update_voice_state(True, member.id, after.channel.id, server)
|
||||
|
||||
# leave
|
||||
elif before.channel is not None and after.channel is None and before.channel.id not in settings.afk_channel_ids:
|
||||
self._logger.trace(__name__, f'User {u.id} left {before.channel}')
|
||||
self._update_voice_state(False, member.id, before.channel.id, server.server_id)
|
||||
self._update_voice_state(False, member.id, before.channel.id, server)
|
||||
|
||||
# channel to channel
|
||||
elif before.channel is not None and after.channel is not None:
|
||||
# joined
|
||||
if before.channel.id in settings.afk_channel_ids and after.channel.id not in settings.afk_channel_ids:
|
||||
self._logger.trace(__name__, f'User {u.id} joined {after.channel}')
|
||||
self._update_voice_state(True, member.id, after.channel.id, server.server_id)
|
||||
self._update_voice_state(True, member.id, after.channel.id, server)
|
||||
|
||||
# left
|
||||
elif after.channel.id in settings.afk_channel_ids and before.channel.id not in settings.afk_channel_ids:
|
||||
self._logger.trace(__name__, f'User {u.id} left {before.channel}')
|
||||
self._update_voice_state(False, member.id, before.channel.id, server.server_id)
|
||||
self._update_voice_state(False, member.id, before.channel.id, server)
|
||||
|
||||
else:
|
||||
self._logger.trace(__name__, f'User {u.id} switched to {after.channel}')
|
||||
|
@ -18,6 +18,9 @@ class BaseSettings(ConfigurationModelABC):
|
||||
self._afk_channel_ids: list[int] = []
|
||||
self._purge_message: str = ''
|
||||
self._no_permissions_message: str = ''
|
||||
self._afk_command_channel_id: int = 0
|
||||
self._afk_command_channel_missing_message: str = ''
|
||||
self._afk_command_move_message: str = ''
|
||||
|
||||
@property
|
||||
def welcome_message(self) -> str:
|
||||
@ -55,6 +58,18 @@ class BaseSettings(ConfigurationModelABC):
|
||||
def no_permissions_message(self) -> str:
|
||||
return self._no_permissions_message
|
||||
|
||||
@property
|
||||
def afk_command_channel_id(self) -> int:
|
||||
return self._afk_command_channel_id
|
||||
|
||||
@property
|
||||
def afk_command_channel_missing_message(self) -> str:
|
||||
return self._afk_command_channel_missing_message
|
||||
|
||||
@property
|
||||
def afk_command_move_message(self) -> str:
|
||||
return self._afk_command_move_message
|
||||
|
||||
def from_dict(self, settings: dict):
|
||||
try:
|
||||
self._welcome_message = settings['WelcomeMessage']
|
||||
@ -67,6 +82,9 @@ class BaseSettings(ConfigurationModelABC):
|
||||
self._afk_channel_ids.append(int(id))
|
||||
self._purge_message = settings['PurgeMessage']
|
||||
self._no_permissions_message = settings['NoPermissionsMessage']
|
||||
self._afk_command_channel_id = settings['AFKCommandChannelId']
|
||||
self._afk_command_channel_missing_message = settings['AFKCommandChannelMissingMessage']
|
||||
self._afk_command_move_message = settings['AFKCommandMoveMessage']
|
||||
except Exception as e:
|
||||
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings')
|
||||
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
|
||||
|
@ -1 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
gismo sh-edraft Gismo
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
sh-edraft Dicord bot Gismo
|
||||
|
||||
:copyright: (c) 2021 - 2022 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'modules.base.service'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||
__version__ = '0.4.3'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='0', minor='4', micro='3')
|
||||
|
@ -1,14 +1,18 @@
|
||||
import asyncio
|
||||
from cpl_core.database.context.database_context import DatabaseContext
|
||||
import discord
|
||||
from discord.channel import VoiceChannel
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands import Context
|
||||
|
||||
from cpl_core.logging import LoggerABC
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from gismo_core.abc.bot_service_abc import BotServiceABC
|
||||
|
||||
from gismo_core.abc.command_abc import CommandABC
|
||||
from gismo_core.abc.message_service_abc import MessageServiceABC
|
||||
from gismo_core.configuration.server_settings import ServerSettings
|
||||
from gismo_data.abc.client_repository_abc import ClientRepositoryABC
|
||||
from modules.base.base_settings import BaseSettings
|
||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||
|
||||
@ -20,7 +24,10 @@ class BaseCommandService(CommandABC):
|
||||
logger: LoggerABC,
|
||||
config: ConfigurationABC,
|
||||
message_service: MessageServiceABC,
|
||||
permissions: PermissionServiceABC
|
||||
permissions: PermissionServiceABC,
|
||||
clients: ClientRepositoryABC,
|
||||
db: DatabaseContext,
|
||||
bot: BotServiceABC
|
||||
):
|
||||
CommandABC.__init__(self)
|
||||
|
||||
@ -28,6 +35,9 @@ class BaseCommandService(CommandABC):
|
||||
self._config = config
|
||||
self._message_service = message_service
|
||||
self._permissions = permissions
|
||||
self._clients = clients
|
||||
self._db = db
|
||||
self._bot = bot
|
||||
|
||||
self._logger.trace(__name__, f'Loaded command service: {type(self).__name__}')
|
||||
|
||||
@ -50,5 +60,36 @@ class BaseCommandService(CommandABC):
|
||||
|
||||
await self._message_service.send_ctx_msg(ctx, settings.purge_message)
|
||||
await asyncio.sleep(server_settings.message_delete_timer)
|
||||
await ctx.channel.purge()
|
||||
try:
|
||||
await ctx.channel.purge()
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f'Cannot purge channel {ctx.channel.id}', e)
|
||||
await self._message_service.send_ctx_msg(ctx, server_settings.bot_has_no_permission_message)
|
||||
|
||||
self._logger.trace(__name__, f'Finished purge command')
|
||||
|
||||
@commands.command()
|
||||
async def afk(self, ctx: Context):
|
||||
self._logger.debug(__name__, f'Received command afk {ctx}')
|
||||
settings: BaseSettings = self._config.get_configuration(f'Base_{ctx.guild.id}')
|
||||
server_settings: ServerSettings = self._config.get_configuration(f'DSERVER_{ctx.guild.id}')
|
||||
|
||||
if ctx.author.voice is None or ctx.author.voice.channel is None:
|
||||
await self._message_service.send_ctx_msg(ctx, settings.afk_command_channel_missing_message)
|
||||
self._logger.trace(__name__, f'Finished afk command')
|
||||
return
|
||||
|
||||
await self._message_service.send_ctx_msg(ctx, settings.afk_command_move_message)
|
||||
channel: VoiceChannel = ctx.guild.get_channel(settings.afk_command_channel_id)
|
||||
try:
|
||||
await ctx.author.move_to(channel)
|
||||
|
||||
client = self._clients.get_client_by_discord_id(self._bot.user.id)
|
||||
client.moved_users_count += 1
|
||||
self._clients.update_client(client)
|
||||
self._db.save_changes()
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f'Cannot move user {ctx.author.id} to channel {ctx.channel.id}', e)
|
||||
await self._message_service.send_ctx_msg(ctx, server_settings.bot_has_no_permission_message)
|
||||
|
||||
self._logger.trace(__name__, f'Finished afk command')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'modules.boot_log'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||
__version__ = '0.3.0'
|
||||
__version__ = '0.4.3'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='0', minor='3', micro='0')
|
||||
version_info = VersionInfo(major='0', minor='4', micro='3')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'modules.database'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||
__version__ = '0.3.0'
|
||||
__version__ = '0.4.3'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='0', minor='3', micro='0')
|
||||
version_info = VersionInfo(major='0', minor='4', micro='3')
|
||||
|
Reference in New Issue
Block a user