reports contrib documentation

This commit is contained in:
Cal 2024-05-04 22:04:03 -06:00
parent ece8f4f138
commit 793ae05ece
2 changed files with 41 additions and 12 deletions

View file

@ -96,7 +96,7 @@ INGAME_REPORT_TYPES = ('bugs', 'players')
* `report_type` - The type of report this command is for (e.g. `player`). You only need to set it if you want a different string from the key. * `report_type` - The type of report this command is for (e.g. `player`). You only need to set it if you want a different string from the key.
* `report_locks` - The locks you want applied to the created reports. Defaults to `"read:pperm(Admin)"` * `report_locks` - The locks you want applied to the created reports. Defaults to `"read:pperm(Admin)"`
* `success_msg` - The string which is sent to players after submitting a report of this type. Defaults to `"Your report has been filed."` * `success_msg` - The string which is sent to players after submitting a report of this type. Defaults to `"Your report has been filed."`
* `require_target`: Set to `True` if your report requires a target (e.g. player reports). * `require_target`: Set to `True` if your report type requires a target (e.g. player reports).
> Note: The contrib's own commands - `CmdBug`, `CmdIdea`, and `CmdReport` - are implemented the same way, so you can review them as examples. > Note: The contrib's own commands - `CmdBug`, `CmdIdea`, and `CmdReport` - are implemented the same way, so you can review them as examples.

View file

@ -1,21 +1,48 @@
""" """
In-Game Reports In-Game Reporting System
"""
# TODO: docstring This contrib provides an in-game reporting system, with player-facing commands and a staff
management interface.
# Installation
To install, just add the provided cmdset to your default AccountCmdSet:
# in commands/default_cmdset.py
from evennia.contrib.base_systems.ingame_reports import ReportsCmdSet
class AccountCmdSet(default_cmds.AccountCmdSet):
# ...
def at_cmdset_creation(self):
# ...
self.add(ReportsCmdSet)
# Features
The contrib provides three commands by default and their associated report types: `CmdBug`, `CmdIdea`,
and `CmdReport` (which is for reporting other players).
The `ReportCmdBase` class holds most of the functionality for creating new reports, providing a
convenient parent class for adding your own categories of reports.
The contrib can be further configured through two settings, `INGAME_REPORT_TYPES` and `INGAME_REPORT_STATUS_TAGS`
"""
from django.conf import settings from django.conf import settings
from evennia import CmdSet from evennia import CmdSet
from evennia.utils import create, evmenu, logger, search from evennia.utils import create, evmenu, logger, search
from evennia.utils.utils import datetime_format, is_iter, iter_to_str from evennia.utils.utils import class_from_module, datetime_format, is_iter, iter_to_str
from evennia.commands.default.muxcommand import MuxCommand from evennia.commands.default.muxcommand import MuxCommand
from evennia.comms.models import Msg from evennia.comms.models import Msg
from . import menu from . import menu
# TODO: use actual default command class # TODO: use actual default command class
_DEFAULT_COMMAND_CLASS = MuxCommand _DEFAULT_COMMAND_CLASS = class_from_module(settings.COMMAND_DEFAULT_CLASS)
# the default report types # the default report types
_REPORT_TYPES = ("bugs", "ideas", "players") _REPORT_TYPES = ("bugs", "ideas", "players")
@ -116,6 +143,7 @@ class ReportCmdBase(_DEFAULT_COMMAND_CLASS):
require_target = False require_target = False
# the message sent to the reporter after the report has been created # the message sent to the reporter after the report has been created
success_msg = "Your report has been filed." success_msg = "Your report has been filed."
# the report type for this command, if different from the key
report_type = None report_type = None
def at_pre_cmd(self): def at_pre_cmd(self):
@ -134,13 +162,13 @@ class ReportCmdBase(_DEFAULT_COMMAND_CLASS):
return return
if self.rhs: if self.rhs:
message = self.rhs message = self.rhs
target = self.lhs target_str = self.lhs
else: else:
message = self.lhs message = self.lhs
target = None target_str = ""
if target: if target_str:
target = self.caller.search(target) target = self.caller.search(target_str)
if not target: if not target:
return return
elif self.require_target: elif self.require_target:
@ -171,7 +199,7 @@ class CmdBug(ReportCmdBase):
file a bug file a bug
Usage: Usage:
bug [target] = message bug [<target> =] <message>
Note: If a specific object, location or character is bugged, please target it for the report. Note: If a specific object, location or character is bugged, please target it for the report.
@ -189,7 +217,7 @@ class CmdReport(ReportCmdBase):
report a player report a player
Usage: Usage:
report player = message report <player> = <message>
All player reports will be reviewed. All player reports will be reviewed.
""" """
@ -197,6 +225,7 @@ class CmdReport(ReportCmdBase):
key = "report" key = "report"
report_type = "player" report_type = "player"
require_target = True require_target = True
account_caller = True
class CmdIdea(ReportCmdBase): class CmdIdea(ReportCmdBase):