From 59f89d8accbefb87cfb03d1282b16596bab521ca Mon Sep 17 00:00:00 2001 From: partmedia Date: Sat, 2 Jan 2021 23:47:28 +0000 Subject: [PATCH] Add 'report' command to report issues in-game git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@21706 282e977c-c81d-0410-88c4-b93c2d0d6712 --- python/commands/report.py | 39 +++++++++++++++++++++++++++ python/events/init/python_commands.py | 1 + 2 files changed, 40 insertions(+) create mode 100644 python/commands/report.py diff --git a/python/commands/report.py b/python/commands/report.py new file mode 100644 index 000000000..a997735f2 --- /dev/null +++ b/python/commands/report.py @@ -0,0 +1,39 @@ +from email.mime.text import MIMEText +import subprocess + +import Crossfire + +def report(pl): + desc = Crossfire.ScriptParameters() + if desc == None: + pl.Message("To report an issue, type 'report '.") + return + + details = { + 'PLAYER': Crossfire.WhoAmI().Name, + 'MAP': Crossfire.WhoAmI().Map.Path, + 'X': Crossfire.WhoAmI().X, + 'Y': Crossfire.WhoAmI().Y, + 'DESC': desc, + } + + report = """ +Reporter: {PLAYER} +Map: {MAP} ({X}, {Y}) +Report: {DESC} +""".format(**details) + + Crossfire.Log(Crossfire.LogInfo, "A problem was reported: %s" % (report)) + + msg = MIMEText(report) + recipient = "crossfire" + msg["From"] = "crossfire" + msg["Subject"] = "Crossfire issue report" + + result = subprocess.run(['sendmail', recipient], input=msg.as_bytes()) + if result.returncode == 0: + pl.Message("Thank you for your report.") + else: + pl.Message("There was an error reporting your problem. Please contact a Dungeon Master to report your problem.") + +report(Crossfire.WhoAmI()) diff --git a/python/events/init/python_commands.py b/python/events/init/python_commands.py index 9e4394f37..9dea46b59 100644 --- a/python/events/init/python_commands.py +++ b/python/events/init/python_commands.py @@ -4,4 +4,5 @@ Crossfire.RegisterCommand("autojail", "/python/commands/autojail", 0) Crossfire.RegisterCommand("dip", "/python/commands/dip", 0) Crossfire.RegisterCommand("disinfect", "/python/commands/disinfect", 0) Crossfire.RegisterCommand("give", "/python/commands/give", 0) +Crossfire.RegisterCommand("report", "/python/commands/report", 0) Crossfire.RegisterCommand("reputation", "/python/commands/reputation", 0)