Cleaned up the drop-command's error messages somewhat.
This commit is contained in:
parent
87bfb97853
commit
fc4d7c92f9
2 changed files with 20 additions and 6 deletions
|
|
@ -119,7 +119,8 @@ def cmdparser(raw_string, cmdset, caller, match_index=None):
|
||||||
# those in this module.
|
# those in this module.
|
||||||
#
|
#
|
||||||
|
|
||||||
def at_search_result(msg_obj, ostring, results, global_search=False):
|
def at_search_result(msg_obj, ostring, results, global_search=False,
|
||||||
|
nofound_string=None, multimatch_string=None):
|
||||||
"""
|
"""
|
||||||
Called by search methods after a result of any type has been found.
|
Called by search methods after a result of any type has been found.
|
||||||
|
|
||||||
|
|
@ -132,6 +133,8 @@ def at_search_result(msg_obj, ostring, results, global_search=False):
|
||||||
global_search - if this was a global_search or not
|
global_search - if this was a global_search or not
|
||||||
(if it is, there might be an idea of supplying
|
(if it is, there might be an idea of supplying
|
||||||
dbrefs instead of only numbers)
|
dbrefs instead of only numbers)
|
||||||
|
nofound_string - optional custom string for not-found error message.
|
||||||
|
multimatch_string - optional custom string for multimatch error header
|
||||||
|
|
||||||
Multiple matches are returned to the searching object
|
Multiple matches are returned to the searching object
|
||||||
as
|
as
|
||||||
|
|
@ -144,7 +147,11 @@ def at_search_result(msg_obj, ostring, results, global_search=False):
|
||||||
string = ""
|
string = ""
|
||||||
if not results:
|
if not results:
|
||||||
# no results.
|
# no results.
|
||||||
string = _("Could not find '%s'." % ostring)
|
if nofound_string:
|
||||||
|
# custom return string
|
||||||
|
string = nofound_string
|
||||||
|
else:
|
||||||
|
string = _("Could not find '%s'." % ostring)
|
||||||
results = None
|
results = None
|
||||||
|
|
||||||
elif len(results) > 1:
|
elif len(results) > 1:
|
||||||
|
|
@ -154,9 +161,14 @@ def at_search_result(msg_obj, ostring, results, global_search=False):
|
||||||
# check if the msg_object may se dbrefs
|
# check if the msg_object may se dbrefs
|
||||||
show_dbref = global_search
|
show_dbref = global_search
|
||||||
|
|
||||||
string += "More than one match for '%s'" % ostring
|
if multimatch_string:
|
||||||
string += " (please narrow target):"
|
# custom header
|
||||||
string = _(string)
|
string = multimatch_string
|
||||||
|
else:
|
||||||
|
string = "More than one match for '%s'" % ostring
|
||||||
|
string += " (please narrow target):"
|
||||||
|
string = _(string)
|
||||||
|
|
||||||
for num, result in enumerate(results):
|
for num, result in enumerate(results):
|
||||||
invtext = ""
|
invtext = ""
|
||||||
dbreftext = ""
|
dbreftext = ""
|
||||||
|
|
|
||||||
|
|
@ -329,7 +329,9 @@ class CmdDrop(MuxCommand):
|
||||||
|
|
||||||
# now we send it into the error handler (this will output consistent
|
# now we send it into the error handler (this will output consistent
|
||||||
# error messages if there are problems).
|
# error messages if there are problems).
|
||||||
obj = AT_SEARCH_RESULT(caller, self.args, results, False)
|
obj = AT_SEARCH_RESULT(caller, self.args, results, False,
|
||||||
|
nofound_string="You don't carry %s." % self.args,
|
||||||
|
multimatch_string="You carry more than one %s:" % self.args)
|
||||||
if not obj:
|
if not obj:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue