Fixed a bug in help. Resolves #955.

This commit is contained in:
Griatch 2016-04-14 21:32:41 +02:00
parent 02ba1c0695
commit 72bdc66022

View file

@ -196,27 +196,24 @@ class CmdSetHelp(MuxCommand):
lhslist = self.lhslist
if not self.args:
self.msg("Usage: @sethelp/[add|del|append|merge] <topic>[,category[,locks,..] = <text>")
self.msg("Usage: @sethelp[/switches] <topic>[,category[,locks,..] = <text>")
return
topicstr = ""
category = "General"
lockstring = "view:all()"
try:
topicstr = lhslist[0]
category = lhslist[1]
lockstring = ",".join(lhslist[2:])
except Exception:
pass
nlist = len(lhslist)
topicstr = lhslist[0] if nlist > 0 else ""
if not topicstr:
self.msg("You have to define a topic!")
return
# check if we have an old entry with the same name
try:
old_entry = HelpEntry.objects.get(db_key__iexact=topicstr)
category = lhslist[1] if nlist > 1 else old_entry.help_category
lockstring = ",".join(lhslist[2:]) if nlist > 2 else old_entry.locks.get()
except Exception:
old_entry = None
category = lhslist[1] if nlist > 1 else "General"
lockstring = ",".join(lhslist[2:]) if nlist > 2 else "view:all()"
if 'append' in switches or "merge" in switches:
# merge/append operations
@ -254,7 +251,7 @@ class CmdSetHelp(MuxCommand):
old_entry.locks.clear()
old_entry.locks.add(lockstring)
old_entry.save()
self.msg("Overwrote the old topic '%s' with a new one." % topicstr)
self.msg("Overwrote the old topic '%s'." % topicstr)
else:
self.msg("Topic '%s' already exists. Use /force to overwrite or /append or /merge to add text to it." % topicstr)
else: