nephthys/nephthys/macros/types.py
Mish 2fc6a90a4d
Improvements to macros (#123)
* Attempts at getting macro aliases to work

* Store instances of macros as well as just the classes

* Add ?unresolve and ?open aliases for ?reopen

* Add an error message for invalid macros

* Add ?close as an alias for ?resolve

* Add error message for running a macro on a closed ticket

* Allow ?thread to be run on closed tickets

* Add type annotation to macro list
2025-11-29 11:22:08 +00:00

20 lines
547 B
Python

from prisma.models import Ticket
from prisma.models import User
class Macro:
name: str
aliases: list[str] = []
can_run_on_closed: bool = False
async def run(self, ticket: Ticket, helper: User, **kwargs) -> None:
"""
Run the macro with the given arguments.
"""
raise NotImplementedError("Subclasses must implement this method.")
def all_aliases(self) -> set[str]:
"""
Get all names for this macro, including aliases.
"""
return set([self.name] + self.aliases)