33import re
44
55from cloudbot import hook
6+ from cloudbot .util import formatting
67
78
89@asyncio .coroutine
@@ -37,13 +38,7 @@ def help_command(text, conn, bot, notice, has_permission):
3738 else :
3839 notice ("Unknown command '{}'" .format (searching_for ))
3940 else :
40-
41- # list of lines to send to the user
42- lines = []
43- # current line, containing words to join with " "
44- current_line = []
45- # current line length, to count how long the current line will be when joined with " "
46- current_line_length = 0
41+ commands = []
4742
4843 for plugin in sorted (set (bot .plugin_manager .commands .values ()), key = attrgetter ("name" )):
4944 # use set to remove duplicate commands (from multiple aliases), and sorted to sort by name
@@ -62,22 +57,12 @@ def help_command(text, conn, bot, notice, has_permission):
6257
6358 # add the command to lines sent
6459 command = plugin .name
65- added_length = len (command ) + 2 # + 2 to account for space and comma
6660
67- if current_line_length + added_length > 450 :
68- # if line limit is reached, add line to lines, and reset
69- lines .append (", " .join (current_line ) + "," )
70- current_line = []
71- current_line_length = 0
61+ commands .append (command )
7262
73- current_line .append (command )
74- current_line_length += added_length
75-
76- if current_line :
77- # make sure to include the last line
78- lines .append (", " .join (current_line ))
63+ # list of lines to send to the user
64+ lines = formatting .chunk_str ("Here's a list of commands you can use: " + ", " . join (commands ))
7965
80- notice ("Here's a list of commands you can use:" )
8166 for line in lines :
8267 notice (line )
8368 notice ("For detailed help, use {}help <command>, without the brackets." .format (conn .config ["command_prefix" ]))
0 commit comments