Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions commands/base_commands/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
database migration to add in their functionality.

"""
from enum import Enum
from django.conf import settings

from evennia.utils.create import create_object
Expand Down Expand Up @@ -289,6 +290,9 @@ class CmdRequest(ArxPlayerCommand):
+featurerequest <title>=<message>
+prprequest <title>=<question about a player run plot>

Switches:
%s

Send a message to the GMs for help. This is usually because
of wanting to take some action that requires GM intervention,
such as a plot idea or some other in-game activity, but can
Expand Down Expand Up @@ -322,6 +326,16 @@ class CmdRequest(ArxPlayerCommand):
help_category = "Admin"
locks = "cmd:all()"

class Switches(Enum):
followup = "<#>=<message> | Add a followup message to a request."
close = "<#>=<reason> | Close a request prematurely and provide a reason."

switch_options = Switches.__members__

def __init__(self, **kwargs):
super().__init__(**kwargs)
self.format_docstring()

def display_ticket(self, ticket):
"""Display the ticket to the caller"""
self.msg(ticket.display())
Expand Down Expand Up @@ -433,12 +447,13 @@ def comment_on_ticket(self):

def func(self):
"""Implement the command"""
switches = [self.Switches[string] for string in self.switches]
caller = self.caller
if "followup" in self.switches or "comment" in self.switches:
if self.Switches.followup in switches:
self.comment_on_ticket()
return

if "close" in self.switches:
if self.Switches.close in switches:
self.close_ticket(self.lhs, self.rhs)
return

Expand Down
5 changes: 5 additions & 0 deletions commands/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ class ArxCommmandMixin(object):
error_class = CommandError
help_entry_tags = []

def format_docstring(self):
self.__doc__ = self.__doc__ % "%r ".join(
f"{switch.name} {switch.value}" for switch in self.switch_options
)

def fail(self, msg):
"""Raises an error for the class with a given message"""
raise self.error_class(msg)
Expand Down