0.4.8 #43

Merged
edraft merged 4 commits from 0.4.8 into 0.4 2022-01-15 14:53:44 +01:00
27 changed files with 103 additions and 48 deletions

View File

@ -15,11 +15,11 @@ __title__ = 'gismo'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

@ -1 +1 @@
Subproject commit ed5887b6d068d33e686347081630b18d896ece4c
Subproject commit 35473ff33eb69349f5f4f5b44d1d50983a3adc2b

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "0",
"Minor": "4",
"Micro": "3"
"Micro": "8"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -38,6 +38,7 @@ from gismo_data.service.user_joined_voice_channel_service import UserJoinedVoice
from gismo_data.service.user_repository_service import UserRepositoryService
from modules.base.base import Base
from modules.base.service.afk_command_service import AFKCommandService
from modules.base.service.help_command_service import HelpCommandService
from modules.base.service.ping_command_service import PingCommandService
from modules.base.service.purge_command_service import PurgeCommandService
from modules.boot_log.boot_log import BootLog
@ -99,6 +100,7 @@ class Startup(StartupABC):
services.add_singleton(CommandABC, PingCommandService)
services.add_singleton(CommandABC, PurgeCommandService)
services.add_singleton(CommandABC, AFKCommandService)
services.add_singleton(CommandABC, HelpCommandService)
# modules
services.add_transient(ModuleABC, Database)

View File

@ -15,11 +15,11 @@ __title__ = 'gismo_core'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

View File

@ -15,11 +15,11 @@ __title__ = 'gismo_core.abc'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

View File

@ -15,11 +15,11 @@ __title__ = 'gismo_core.abc.events'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

View File

@ -12,7 +12,7 @@ class MessageServiceABC(ABC):
def __init__(self): pass
@abstractmethod
async def delete_messages(self, messages: List[discord.Message]): pass
async def delete_messages(self, messages: List[discord.Message], guild_id: int): pass
@abstractmethod
async def delete_message(self, message: discord.Message): pass
@ -24,4 +24,4 @@ class MessageServiceABC(ABC):
async def send_dm_message(self, message: str, receiver: Union[discord.User, discord.Member]): pass
@abstractmethod
async def send_ctx_msg(self, ctx: Context, message: str, file: discord.File = None): pass
async def send_ctx_msg(self, ctx: Context, message: str, file: discord.File = None, is_persistent: bool = False): pass

View File

@ -15,11 +15,11 @@ __title__ = 'gismo_core.configuration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

View File

@ -15,11 +15,11 @@ __title__ = 'gismo_core.service'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

View File

@ -23,11 +23,11 @@ class MessageService(MessageServiceABC):
self._clients = clients
self._db = db
async def delete_messages(self, messages: List[discord.Message]):
async def delete_messages(self, messages: List[discord.Message], guild_id: int):
self._logger.debug(__name__, f'Try to delete {messages.count()} messages')
for message in messages:
server_st: ServerSettings = self._config.get_configuration(f'DSERVER_{message.guild.id}')
server_st: ServerSettings = self._config.get_configuration(f'DSERVER_{guild_id}')
await asyncio.sleep(server_st.message_delete_timer)
for message in messages:
await self.delete_message(message, mass_delete=True)
self._logger.debug(__name__, 'Deleting messages finished')
@ -70,7 +70,7 @@ class MessageService(MessageServiceABC):
self._db.save_changes()
self._logger.info(__name__, f'Sent message to user {receiver.id}')
async def send_ctx_msg(self, ctx: Context, message: str, file: discord.File = None):
async def send_ctx_msg(self, ctx: Context, message: str, file: discord.File = None, is_persistent: bool = False):
if ctx is None:
self._logger.warn(__name__, 'Message context is empty')
self._logger.debug(__name__, f'Message: {message}')
@ -89,4 +89,8 @@ class MessageService(MessageServiceABC):
self._logger.info(__name__, f'Sent message to channel {ctx.channel.id}')
self._clients.append_sent_message_count(self._bot.user.id, ctx.guild.id, 1)
self._db.save_changes()
await self.delete_messages(List(discord.Message, [msg, ctx.message]))
if is_persistent:
await self.delete_message(ctx.message)
return
await self.delete_messages(List(discord.Message, [msg, ctx.message]), ctx.guild.id)

View File

@ -15,11 +15,11 @@ __title__ = 'gismo_data'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

View File

@ -15,11 +15,11 @@ __title__ = 'gismo_data.abc'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

View File

@ -15,11 +15,11 @@ __title__ = 'gismo_data.migration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

View File

@ -15,11 +15,11 @@ __title__ = 'gismo_data.model'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

View File

@ -15,11 +15,11 @@ __title__ = 'gismo_data.service'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

View File

@ -15,11 +15,11 @@ __title__ = 'modules.base'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

View File

@ -22,6 +22,7 @@ from gismo_data.model.user_joined_server import UserJoinedServer
from gismo_data.model.user_joined_voice_channel import UserJoinedVoiceChannel
from modules.base.base_settings import BaseSettings
from modules.base.service.afk_command_service import AFKCommandService
from modules.base.service.help_command_service import HelpCommandService
from modules.base.service.ping_command_service import PingCommandService
from modules.base.service.purge_command_service import PurgeCommandService
from modules.permission.abc.permission_service_abc import PermissionServiceABC
@ -51,7 +52,8 @@ class Base(ModuleABC, OnMemberJoinABC, OnMemberRemoveABC, OnMessageABC, OnVoiceS
permission_service: PermissionServiceABC,
ping_command: PingCommandService,
purge_command: PurgeCommandService,
afk_command: AFKCommandService
afk_command: AFKCommandService,
help_command: HelpCommandService
):
self._config = config
self._logger = logger
@ -80,6 +82,7 @@ class Base(ModuleABC, OnMemberJoinABC, OnMemberRemoveABC, OnMessageABC, OnVoiceS
self._bot.add_cog(ping_command)
self._bot.add_cog(purge_command)
self._bot.add_cog(afk_command)
self._bot.add_cog(help_command)
self._logger.info(__name__, f'Module {type(self)} loaded')

View File

@ -21,6 +21,7 @@ class BaseSettings(ConfigurationModelABC):
self._afk_command_channel_id: int = 0
self._afk_command_channel_missing_message: str = ''
self._afk_command_move_message: str = ''
self._help_command_reference_url: str = ''
@property
def welcome_message(self) -> str:
@ -70,6 +71,10 @@ class BaseSettings(ConfigurationModelABC):
def afk_command_move_message(self) -> str:
return self._afk_command_move_message
@property
def help_command_reference_url(self) -> str:
return self._help_command_reference_url
def from_dict(self, settings: dict):
try:
self._welcome_message = settings['WelcomeMessage']
@ -85,6 +90,7 @@ class BaseSettings(ConfigurationModelABC):
self._afk_command_channel_id = settings['AFKCommandChannelId']
self._afk_command_channel_missing_message = settings['AFKCommandChannelMissingMessage']
self._afk_command_move_message = settings['AFKCommandMoveMessage']
self._help_command_reference_url = settings['HelpCommandReferenceUrl']
except Exception as e:
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings')
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')

View File

@ -15,11 +15,11 @@ __title__ = 'modules.base.service'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

View File

@ -0,0 +1,40 @@
from cpl_core.configuration import ConfigurationABC
from cpl_core.logging import LoggerABC
from discord.ext import commands
from discord.ext.commands import Context
from gismo_core.abc.bot_service_abc import BotServiceABC
from gismo_core.abc.client_utils_service_abc import ClientUtilsServiceABC
from gismo_core.abc.command_abc import CommandABC
from gismo_core.abc.message_service_abc import MessageServiceABC
from modules.base.base_settings import BaseSettings
class HelpCommandService(CommandABC):
def __init__(
self,
config: ConfigurationABC,
logger: LoggerABC,
message_service: MessageServiceABC,
bot: BotServiceABC,
client_utils: ClientUtilsServiceABC
):
CommandABC.__init__(self)
self._config = config
self._logger = logger
self._message_service = message_service
self._bot = bot
self._client_utils = client_utils
self._logger.trace(__name__, f'Loaded command service: {type(self).__name__}')
@commands.command()
async def help(self, ctx: Context, persistent_flag: str = None):
self._logger.debug(__name__, f'Received command ping {ctx}:{persistent_flag}')
self._client_utils.received_command(ctx.guild.id)
settings: BaseSettings = self._config.get_configuration(f'Base_{ctx.guild.id}')
is_persistent = persistent_flag == '--stay'
await self._message_service.send_ctx_msg(ctx, settings.help_command_reference_url, is_persistent=is_persistent)
self._logger.trace(__name__, f'Finished ping command')

View File

@ -15,11 +15,11 @@ __title__ = 'modules.boot_log'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

View File

@ -15,11 +15,11 @@ __title__ = 'modules.database'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

View File

@ -15,11 +15,11 @@ __title__ = 'modules.permission'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

View File

@ -15,11 +15,11 @@ __title__ = 'modules.permission.abc'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

View File

@ -15,11 +15,11 @@ __title__ = 'modules.permission.configuration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')

View File

@ -15,11 +15,11 @@ __title__ = 'modules.permission.service'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.3'
__version__ = '0.4.8'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='3')
version_info = VersionInfo(major='0', minor='4', micro='8')