Rollen per Reaktion hinzufügen (#54) #58

Merged
edraft merged 20 commits from #54 into master 2022-10-05 19:08:22 +02:00
5 changed files with 20 additions and 36 deletions
Showing only changes of commit f2e6be530b - Show all commits

View File

@ -9,19 +9,19 @@
"Command": {
"Path": "logs/",
"Filename": "commands.log",
"ConsoleLogLevel": "TRACE",
"ConsoleLogLevel": "DEBUG",
"FileLogLevel": "TRACE"
},
"Database": {
"Path": "logs/",
"Filename": "database.log",
"ConsoleLogLevel": "TRACE",
"ConsoleLogLevel": "DEBUG",
"FileLogLevel": "TRACE"
},
"Message": {
"Path": "logs/",
"Filename": "message.log",
"ConsoleLogLevel": "TRACE",
"ConsoleLogLevel": "DEBUG",
"FileLogLevel": "TRACE"
}
},

View File

@ -25,13 +25,10 @@ class AutoRoleRepositoryABC(ABC):
def get_auto_roles_by_server_id(self, id: int) -> AutoRole: pass
@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
def get_auto_roles_by_message_id(self, id: int) -> AutoRole: pass
@abstractmethod
def find_auto_roles_by_message_id(self, id: int) -> Optional[AutoRole]: pass
def find_auto_role_by_message_id(self, id: int) -> Optional[AutoRole]: pass
@abstractmethod
def add_auto_role(self, auto_role: AutoRole): pass

View File

@ -59,34 +59,22 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC):
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]:
edraft marked this conversation as resolved Outdated

Soll hier nicht eine Liste der auto-roles zurückgegeben werden, wegen dem "roles" im Namen?

Soll hier nicht eine Liste der auto-roles zurückgegeben werden, wegen dem "roles" im Namen?
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]
return AutoRole(
result[1],
result[2],
result[3],
result[4],
id=result[0]
)
auto_roles = List(AutoRole)
results = self._context.select(AutoRole.get_select_by_server_id_string(id))
for result in results:
auto_roles.append(AutoRole(
result[1],
result[2],
result[3],
result[4],
id=result[0]
))
edraft marked this conversation as resolved Outdated

Hier auch wieder eine Liste ausgeben wegen dem "roles" im Namen.

Hier auch wieder eine Liste ausgeben wegen dem "roles" im Namen.
def find_auto_roles_by_server_id(self, id: int) -> Optional[AutoRole]:
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
return auto_roles
result = result[0]
return AutoRole(
result[1],
result[2],
result[3],
result[4],
id=result[0]
)
def get_auto_roles_by_message_id(self, id: int) -> AutoRole:
def get_auto_role_by_message_id(self, id: int) -> AutoRole:
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]
return AutoRole(
@ -97,7 +85,7 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC):
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)}')
edraft marked this conversation as resolved
Review

Methode umbenennen in "get_auto_role_by_message_id", da es hier zu keiner Liste kommen sollte.

Methode umbenennen in "get_auto_role_by_message_id", da es hier zu keiner Liste kommen sollte.
result = self._context.select(AutoRole.get_select_by_message_id_string(id))
if result is None or len(result) == 0:

View File

@ -107,7 +107,7 @@ class AutoRoleGroup(DiscordCommandABC):
self._logger.trace(__name__, f'Finished command auto-role add')
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')
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')

View File

@ -1,5 +1,4 @@
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.service import DiscordBotServiceABC
from discord import RawReactionActionEvent