Add channel prefix to .usage (So it shows .8ball <question> instead of just 8ball <question>, based on the channel's prefix)
Updated ducks.py, more efficient code and style tweaks.
This commit is contained in:
parent
69543c04db
commit
11f7ebaa86
2 changed files with 21 additions and 13 deletions
|
@ -190,12 +190,20 @@ class Module(object):
|
||||||
event["stdout"].write("Commands: %s" % ", ".join(help_available))
|
event["stdout"].write("Commands: %s" % ", ".join(help_available))
|
||||||
|
|
||||||
def usage(self, event):
|
def usage(self, event):
|
||||||
|
command_prefix = event["target"].get_setting("command-prefix",
|
||||||
|
event["server"].get_setting(
|
||||||
|
"command-prefix",
|
||||||
|
"!"))
|
||||||
|
|
||||||
command = event["args_split"][0].lower()
|
command = event["args_split"][0].lower()
|
||||||
if command in self.events.on("received").on(
|
if command in self.events.on("received").on(
|
||||||
"command").get_children():
|
"command").get_children():
|
||||||
hooks = self.events.on("received").on("command").on(command).get_hooks()
|
hooks = self.events.on("received").on("command").on(command).get_hooks()
|
||||||
if hooks and "usage" in hooks[0].kwargs:
|
if hooks and "usage" in hooks[0].kwargs:
|
||||||
event["stdout"].write("Usage: %s %s" % (command, hooks[0].kwargs["usage"]))
|
event["stdout"].write("Usage: %s%s %s" % (command_prefix,
|
||||||
|
command,
|
||||||
|
hooks[0].kwargs[
|
||||||
|
"usage"]))
|
||||||
else:
|
else:
|
||||||
event["stderr"].write("No usage help available for %s" % command)
|
event["stderr"].write("No usage help available for %s" % command)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -303,16 +303,16 @@ class Module(object):
|
||||||
enemy_nicks.append(user)
|
enemy_nicks.append(user)
|
||||||
enemy_ducks.append(enemies)
|
enemy_ducks.append(enemies)
|
||||||
|
|
||||||
sentence = "Most Notorious Users -- "
|
sentence = "Duck Wranglers -- "
|
||||||
|
build = []
|
||||||
|
|
||||||
length = len(enemy_nicks) if len(enemy_nicks) < 11 else 11
|
length = len(enemy_nicks) if len(enemy_nicks) < 8 else 8
|
||||||
|
|
||||||
for i in range(0, length):
|
for i in range(0, length):
|
||||||
sentence += enemy_nicks[i] + " (" + str(enemy_ducks[i]) + ")"
|
build.append(Utils.bold(enemy_nicks[i]) + " ("
|
||||||
if i < 10:
|
+ str(enemy_ducks[i]) + ")")
|
||||||
sentence += ", "
|
|
||||||
|
|
||||||
sentence = sentence[0:-2]
|
sentence += ", ".join(build)
|
||||||
|
|
||||||
event["stdout"].write(sentence)
|
event["stdout"].write(sentence)
|
||||||
|
|
||||||
|
@ -335,15 +335,15 @@ class Module(object):
|
||||||
friend_nicks.append(user)
|
friend_nicks.append(user)
|
||||||
friend_ducks.append(friends)
|
friend_ducks.append(friends)
|
||||||
|
|
||||||
sentence = "Friendliest Users -- "
|
sentence = "Duck Befrienders -- "
|
||||||
|
|
||||||
length = len(friend_nicks) if len(friend_nicks) < 11 else 11
|
length = len(friend_nicks) if len(friend_nicks) < 8 else 8
|
||||||
|
build = []
|
||||||
|
|
||||||
for i in range(0, length):
|
for i in range(0, length):
|
||||||
sentence += friend_nicks[i] + " (" + str(friend_ducks[i]) + ")"
|
build.append(Utils.bold(friend_nicks[i]) + " ("
|
||||||
if i < 10:
|
+ str(friend_ducks[i]) + ")")
|
||||||
sentence += ", "
|
|
||||||
|
|
||||||
sentence = sentence[0:-2]
|
sentence += ", ".join(build)
|
||||||
|
|
||||||
event["stdout"].write(sentence)
|
event["stdout"].write(sentence)
|
||||||
|
|
Loading…
Reference in a new issue