Debian Codegraph @

python/commands/report.py

raw
1 from email.mime.text import MIMEText
2 import subprocess
3
4 import Crossfire
5
6 def report(pl):
7 desc = Crossfire.ScriptParameters()
8 if desc == None:
9 pl.Message("To report an issue, type 'report <description of the issue>'.")
10 return
11
12 details = {
13 'PLAYER': Crossfire.WhoAmI().Name,
14 'MAP': Crossfire.WhoAmI().Map.Path,
15 'X': Crossfire.WhoAmI().X,
16 'Y': Crossfire.WhoAmI().Y,
17 'DESC': desc,
18 }
19
20 report = """
21 Reporter: {PLAYER}
22 Map: {MAP} ({X}, {Y})
23 Report: {DESC}
24 """.format(**details)
25
26 Crossfire.Log(Crossfire.LogInfo, "A problem was reported: %s" % (report))
27
28 msg = MIMEText(report)
29 recipient = "crossfire"
30 msg["From"] = "crossfire"
31 msg["Subject"] = "Crossfire issue report"
32
33 result = subprocess.run(['sendmail', recipient], input=msg.as_bytes())
34 if result.returncode == 0:
35 pl.Message("Thank you for your report.")
36 else:
37 pl.Message("There was an error reporting your problem. Please contact a Dungeon Master to report your problem.")
38
39 report(Crossfire.WhoAmI())