Fixed up spammy commands
This commit is contained in:
parent
51ccb3e844
commit
1a1e1f8479
1 changed files with 17 additions and 20 deletions
|
@ -47,37 +47,30 @@ def itemid(input, reply=None):
|
||||||
".itemid <item/id> -- gets the id from an item or vice versa"
|
".itemid <item/id> -- gets the id from an item or vice versa"
|
||||||
input = input.lower().strip()
|
input = input.lower().strip()
|
||||||
|
|
||||||
|
|
||||||
all = False
|
|
||||||
limit = 4
|
|
||||||
parts = input.split()
|
|
||||||
|
|
||||||
if parts[0] == "-all":
|
|
||||||
all = True
|
|
||||||
input = " ".join(parts[1:])
|
|
||||||
|
|
||||||
if input == "":
|
if input == "":
|
||||||
reply("no input")
|
reply("No input.")
|
||||||
return
|
return
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
for id, name in ids:
|
for id, name in ids:
|
||||||
if input == id or input in name.lower():
|
if input == id or input in name.lower():
|
||||||
results.append("%s %s" % (id, name))
|
results.append("\x02[%s]\x02 %s" % (id, name))
|
||||||
|
|
||||||
if not len(results):
|
if not len(results):
|
||||||
reply("no matches found")
|
reply("No matches found.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if not all and len(results) > limit:
|
out = ", ".join(results)
|
||||||
reply("Displaying %d of %d matches, use -all to get all." % (limit, len(results)))
|
|
||||||
|
if len(out) > 200:
|
||||||
for result in results if all else itertools.islice(results, limit):
|
out = out[:out.rfind(' ')] + '...'
|
||||||
reply(result)
|
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@hook.command("crafting")
|
||||||
@hook.command
|
@hook.command
|
||||||
def recipe(input, reply=None):
|
def recipe(input, reply=None):
|
||||||
".recipe <item> -- gets the crafting recipe for an item"
|
".recipe <item> -- gets the crafting recipe for an item"
|
||||||
|
@ -90,7 +83,11 @@ def recipe(input, reply=None):
|
||||||
results.append(recipe.line)
|
results.append(recipe.line)
|
||||||
|
|
||||||
if not len(results):
|
if not len(results):
|
||||||
reply("no matches found")
|
reply("No matches found.")
|
||||||
|
return
|
||||||
|
|
||||||
|
if len(results) > 3:
|
||||||
|
reply("Too many results (%s)" % len(results))
|
||||||
return
|
return
|
||||||
|
|
||||||
for result in results:
|
for result in results:
|
||||||
|
|
Reference in a new issue