From e9b9fcb825a68b545525cce1a99581475cab9c33 Mon Sep 17 00:00:00 2001 From: Namanyay Goel Date: Fri, 3 May 2024 22:50:33 +0530 Subject: [PATCH] Only optionally show 'commands' in help --- .env.example | 3 ++- bot/main.py | 1 + bot/telegram_bot.py | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index d3d368d0..020bbbc1 100644 --- a/.env.example +++ b/.env.example @@ -54,4 +54,5 @@ ALLOWED_TELEGRAM_USER_IDS=USER_ID_1,USER_ID_2 # TTS_PRICES=0.015,0.030 # BOT_LANGUAGE=en # ENABLE_VISION_FOLLOW_UP_QUESTIONS="true" -# VISION_MODEL="gpt-4-vision-preview" \ No newline at end of file +# VISION_MODEL="gpt-4-vision-preview" +# SHOW_COMMANDS_IN_HELP=true diff --git a/bot/main.py b/bot/main.py index 8e0118d2..0d56719b 100644 --- a/bot/main.py +++ b/bot/main.py @@ -100,6 +100,7 @@ def main(): 'tts_prices': [float(i) for i in os.environ.get('TTS_PRICES', "0.015,0.030").split(",")], 'transcription_price': float(os.environ.get('TRANSCRIPTION_PRICE', 0.006)), 'bot_language': os.environ.get('BOT_LANGUAGE', 'en'), + 'show_commands_in_help': os.environ.get('SHOW_COMMANDS_IN_HELP', 'true').lower() == 'true', } plugin_config = { diff --git a/bot/telegram_bot.py b/bot/telegram_bot.py index 4cf9fa4c..d19e0732 100644 --- a/bot/telegram_bot.py +++ b/bot/telegram_bot.py @@ -66,17 +66,17 @@ async def help(self, update: Update, _: ContextTypes.DEFAULT_TYPE) -> None: """ commands = self.group_commands if is_group_chat(update) else self.commands commands_description = [f'/{command.command} - {command.description}' for command in commands] + commands_description_text = '\n'.join(commands_description) + '\n\n' if self.config.get('show_commands_in_help', True) else '' bot_language = self.config['bot_language'] help_text = ( localized_text('help_text', bot_language)[0] + '\n\n' + - '\n'.join(commands_description) + - '\n\n' + + commands_description_text + localized_text('help_text', bot_language)[1] + '\n\n' + localized_text('help_text', bot_language)[2] ) - await update.message.reply_text(help_text, disable_web_page_preview=True) + await update.message.reply_text(help_text, parse_mode=constants.ParseMode.MARKDOWN, disable_web_page_preview=True) async def stats(self, update: Update, context: ContextTypes.DEFAULT_TYPE): """