From 5a6144453576c9a23b034cf835b6bfff1ec962ce Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Thu, 9 Jun 2022 11:36:40 +0100 Subject: [PATCH] Build command list for help from handlers --- smsbot/telegram.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/smsbot/telegram.py b/smsbot/telegram.py index d1aadf3..ad1c113 100644 --- a/smsbot/telegram.py +++ b/smsbot/telegram.py @@ -1,4 +1,5 @@ import logging +from setuptools import Command from telegram.ext import CommandHandler, Updater @@ -32,7 +33,12 @@ class TelegramSmsBot(object): def help_handler(self, update, context): """Send a message when the command /help is issued.""" self.logger.info('/help command received in chat: %s', update.message.chat) - update.message.reply_markdown('Smsbot v{0}\n\n/help\n/subscribe\n/unsubscribe'.format(get_smsbot_version())) + + commands = [] + for command in self.updater.dispatcher.handlers[0]: + commands.extend(['/{0}'.format(x) for x in command.command]) + + update.message.reply_markdown('Smsbot v{0}\n\n{1}'.format(get_smsbot_version(), '\n'.join(commands))) def subscribe_handler(self, update, context): self.logger.info('/subscribe command received')