forked from sh-edraft.de/sh_discord_bot
Renamed some functions & fixed list return context #54
This commit is contained in:
parent
2df4f90802
commit
f2e6be530b
@ -9,19 +9,19 @@
|
|||||||
"Command": {
|
"Command": {
|
||||||
"Path": "logs/",
|
"Path": "logs/",
|
||||||
"Filename": "commands.log",
|
"Filename": "commands.log",
|
||||||
"ConsoleLogLevel": "TRACE",
|
"ConsoleLogLevel": "DEBUG",
|
||||||
"FileLogLevel": "TRACE"
|
"FileLogLevel": "TRACE"
|
||||||
},
|
},
|
||||||
"Database": {
|
"Database": {
|
||||||
"Path": "logs/",
|
"Path": "logs/",
|
||||||
"Filename": "database.log",
|
"Filename": "database.log",
|
||||||
"ConsoleLogLevel": "TRACE",
|
"ConsoleLogLevel": "DEBUG",
|
||||||
"FileLogLevel": "TRACE"
|
"FileLogLevel": "TRACE"
|
||||||
},
|
},
|
||||||
"Message": {
|
"Message": {
|
||||||
"Path": "logs/",
|
"Path": "logs/",
|
||||||
"Filename": "message.log",
|
"Filename": "message.log",
|
||||||
"ConsoleLogLevel": "TRACE",
|
"ConsoleLogLevel": "DEBUG",
|
||||||
"FileLogLevel": "TRACE"
|
"FileLogLevel": "TRACE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -25,13 +25,10 @@ class AutoRoleRepositoryABC(ABC):
|
|||||||
def get_auto_roles_by_server_id(self, id: int) -> AutoRole: pass
|
def get_auto_roles_by_server_id(self, id: int) -> AutoRole: pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def find_auto_roles_by_server_id(self, id: int) -> Optional[AutoRole]: pass
|
def get_auto_role_by_message_id(self, id: int) -> AutoRole: pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_auto_roles_by_message_id(self, id: int) -> AutoRole: pass
|
def find_auto_role_by_message_id(self, id: int) -> Optional[AutoRole]: pass
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def find_auto_roles_by_message_id(self, id: int) -> Optional[AutoRole]: pass
|
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def add_auto_role(self, auto_role: AutoRole): pass
|
def add_auto_role(self, auto_role: AutoRole): pass
|
||||||
|
@ -59,34 +59,22 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC):
|
|||||||
id=result[0]
|
id=result[0]
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_auto_roles_by_server_id(self, id: int) -> AutoRole:
|
def get_auto_roles_by_server_id(self, id: int) -> List[AutoRole]:
|
||||||
self._logger.trace(__name__, f'Send SQL command: {AutoRole.get_select_by_server_id_string(id)}')
|
self._logger.trace(__name__, f'Send SQL command: {AutoRole.get_select_by_server_id_string(id)}')
|
||||||
result = self._context.select(AutoRole.get_select_by_server_id_string(id))[0]
|
auto_roles = List(AutoRole)
|
||||||
return AutoRole(
|
results = self._context.select(AutoRole.get_select_by_server_id_string(id))
|
||||||
result[1],
|
for result in results:
|
||||||
result[2],
|
auto_roles.append(AutoRole(
|
||||||
result[3],
|
result[1],
|
||||||
result[4],
|
result[2],
|
||||||
id=result[0]
|
result[3],
|
||||||
)
|
result[4],
|
||||||
|
id=result[0]
|
||||||
|
))
|
||||||
|
|
||||||
def find_auto_roles_by_server_id(self, id: int) -> Optional[AutoRole]:
|
return auto_roles
|
||||||
self._logger.trace(__name__, f'Send SQL command: {AutoRole.get_select_by_server_id_string(id)}')
|
|
||||||
result = self._context.select(AutoRole.get_select_by_server_id_string(id))
|
|
||||||
if result is None or len(result) == 0:
|
|
||||||
return None
|
|
||||||
|
|
||||||
result = result[0]
|
def get_auto_role_by_message_id(self, id: int) -> AutoRole:
|
||||||
|
|
||||||
return AutoRole(
|
|
||||||
result[1],
|
|
||||||
result[2],
|
|
||||||
result[3],
|
|
||||||
result[4],
|
|
||||||
id=result[0]
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_auto_roles_by_message_id(self, id: int) -> AutoRole:
|
|
||||||
self._logger.trace(__name__, f'Send SQL command: {AutoRole.get_select_by_message_id_string(id)}')
|
self._logger.trace(__name__, f'Send SQL command: {AutoRole.get_select_by_message_id_string(id)}')
|
||||||
result = self._context.select(AutoRole.get_select_by_message_id_string(id))[0]
|
result = self._context.select(AutoRole.get_select_by_message_id_string(id))[0]
|
||||||
return AutoRole(
|
return AutoRole(
|
||||||
@ -97,7 +85,7 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC):
|
|||||||
id=result[0]
|
id=result[0]
|
||||||
)
|
)
|
||||||
|
|
||||||
def find_auto_roles_by_message_id(self, id: int) -> Optional[AutoRole]:
|
def find_auto_role_by_message_id(self, id: int) -> Optional[AutoRole]:
|
||||||
self._logger.trace(__name__, f'Send SQL command: {AutoRole.get_select_by_message_id_string(id)}')
|
self._logger.trace(__name__, f'Send SQL command: {AutoRole.get_select_by_message_id_string(id)}')
|
||||||
result = self._context.select(AutoRole.get_select_by_message_id_string(id))
|
result = self._context.select(AutoRole.get_select_by_message_id_string(id))
|
||||||
if result is None or len(result) == 0:
|
if result is None or len(result) == 0:
|
||||||
|
@ -107,7 +107,7 @@ class AutoRoleGroup(DiscordCommandABC):
|
|||||||
self._logger.trace(__name__, f'Finished command auto-role add')
|
self._logger.trace(__name__, f'Finished command auto-role add')
|
||||||
return
|
return
|
||||||
|
|
||||||
if self._auto_roles.find_auto_roles_by_message_id(int(message_id)) is not None:
|
if self._auto_roles.find_auto_role_by_message_id(int(message_id)) is not None:
|
||||||
self._logger.debug(__name__, f'auto-role for message {message_id} already exists')
|
self._logger.debug(__name__, f'auto-role for message {message_id} already exists')
|
||||||
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.auto_role.add.error.already_exists').format(message_id))
|
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.auto_role.add.error.already_exists').format(message_id))
|
||||||
self._logger.trace(__name__, f'Finished command auto-role add')
|
self._logger.trace(__name__, f'Finished command auto-role add')
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from cpl_core.logging import LoggerABC
|
from cpl_core.logging import LoggerABC
|
||||||
from cpl_discord.events.on_raw_reaction_add_abc import OnRawReactionAddABC
|
|
||||||
from cpl_discord.events.on_raw_reaction_remove_abc import OnRawReactionRemoveABC
|
from cpl_discord.events.on_raw_reaction_remove_abc import OnRawReactionRemoveABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
from discord import RawReactionActionEvent
|
from discord import RawReactionActionEvent
|
||||||
|
Loading…
Reference in New Issue
Block a user