@@ -179,20 +179,45 @@ def default_about_response():
179
179
return "**{name}**" .format (** bot_details )
180
180
return "**{name}**: {description}" .format (** bot_details )
181
181
182
+ def default_commands_response ():
183
+ return "**Commands**: {} {}" .format (
184
+ " " .join (name for name in command_defaults if name ),
185
+ " " .join (name for name in bot_details ['commands' ] if name ))
186
+
187
+ def commands_list ():
188
+ return ("\n " .join ("**{}** - {}" .format (name , options ['help' ])
189
+ for name , options in command_defaults .items () if name ) +
190
+ "\n " +
191
+ "\n " .join ("**{}** - {}" .format (name , description )
192
+ for name , description in bot_details ['commands' ].items () if name ))
193
+
194
+ def default_help_response ():
195
+ return "{}\n {}\n {}" .format (default_about_response (),
196
+ message_handler .usage (), commands_list ())
197
+
182
198
command_defaults = OrderedDict ([ # Variable definition required for callbacks above
183
199
('' , {'action' : default_empty_response ,
184
200
'help' : "[BLANK MESSAGE NOT SHOWN]" }),
185
201
('about' , {'action' : default_about_response ,
186
202
'help' : "The type and use of this bot" }),
187
203
('usage' , {'action' : lambda : message_handler .usage (),
188
204
'help' : "Bot-provided usage text" }),
205
+ ('commands' , {'action' : default_commands_response ,
206
+ 'help' : "A short list of supported commands" }),
207
+ ('help' , {'action' : default_help_response ,
208
+ 'help' : "This help text" }),
189
209
])
190
210
return command_defaults
191
211
192
212
def updated_default_commands (default_commands , bot_details ):
193
213
if not bot_details ['default_commands_enabled' ]:
194
214
return OrderedDict ()
195
- updated = OrderedDict (default_commands )
215
+ exclude_list = bot_details ['commands' ] or ('commands' , 'help' )
216
+ updated = OrderedDict ((name , option ) for name , option in default_commands .items ()
217
+ if name not in exclude_list )
218
+ # Update bot_details if updated is empty
219
+ if len (updated ) == 0 :
220
+ bot_details ['default_commands_enabled' ] = False
196
221
return updated
197
222
198
223
def get_bot_details (bot_class , bot_name ):
0 commit comments