mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-01-10 12:02:39 +01:00
add a help for extra commands.
This commit is contained in:
parent
9145f24efa
commit
ea5c690e7a
1 changed files with 13 additions and 0 deletions
|
@ -133,9 +133,22 @@ class CommandHandlerWithHelp(CommandHandler):
|
||||||
self._help_before_list = '' # text with information about the bot
|
self._help_before_list = '' # text with information about the bot
|
||||||
self._help_after_list = '' # a footer
|
self._help_after_list = '' # a footer
|
||||||
self._help_list_title = 'These are the commands:' # the title of the list
|
self._help_list_title = 'These are the commands:' # the title of the list
|
||||||
|
self._help_extra_message = 'These commands are only usefull to the developer.'
|
||||||
self.is_reply = True
|
self.is_reply = True
|
||||||
self.command_start = self.command_help
|
self.command_start = self.command_help
|
||||||
self.skip_in_help = []
|
self.skip_in_help = []
|
||||||
|
|
||||||
|
def command_helpextra(self,update):
|
||||||
|
""" The commands in here are only usefull to the developer of the bot"""
|
||||||
|
command_functions = [attr[1] for attr in getmembers(self, predicate=ismethod) if attr[0][:8] == 'command_' and attr[0] in self.skip_in_help]
|
||||||
|
chat_id = update.message.chat.id
|
||||||
|
help_message = self._help_extra_message +'\n'
|
||||||
|
for command_function in command_functions:
|
||||||
|
if command_function.__doc__ is not None:
|
||||||
|
help_message += ' /' + command_function.__name__[8:] + ' - ' + command_function.__doc__ + '\n'
|
||||||
|
else:
|
||||||
|
help_message += ' /' + command_function.__name__[8:] + ' - ' + '\n'
|
||||||
|
self.bot.sendMessage(chat_id=chat_id,text=help_message)
|
||||||
|
|
||||||
def _generate_help(self):
|
def _generate_help(self):
|
||||||
""" Generate a string which can be send as a help file.
|
""" Generate a string which can be send as a help file.
|
||||||
|
|
Loading…
Reference in a new issue