mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 15:48:29 +02:00
Editing of custom commands, add posix flags
This commit is contained in:
parent
257eae6fa7
commit
d6a560851b
9 changed files with 184 additions and 22 deletions
|
|
@ -65,3 +65,23 @@ async def get_command_by_alias(session: AsyncSession, message: str) -> Optional[
|
|||
return None
|
||||
|
||||
return alias.command
|
||||
|
||||
|
||||
async def edit_command(
|
||||
session: AsyncSession, original_name: str, new_name: Optional[str] = None, new_response: Optional[str] = None
|
||||
) -> CustomCommand:
|
||||
"""Edit an existing command"""
|
||||
# Check if the command exists
|
||||
command = await get_command(session, original_name)
|
||||
if command is None:
|
||||
raise NoResultFoundException
|
||||
|
||||
if new_name is not None:
|
||||
command.name = new_name
|
||||
if new_response is not None:
|
||||
command.response = new_response
|
||||
|
||||
session.add(command)
|
||||
await session.commit()
|
||||
|
||||
return command
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue