Search code examples
pythonformattingtelegramtelegram-botpython-telegram-bot

How do you split a big message in different lines in python telebot?


So hey. My previous question was not well received so I'll try to do better this time.

One of my help commands for the bot sends them a list of commands that they can do. Here's the code for the specific part of the problem:

def help_command(update, context):
    update.message.reply_text("What do you need my help in?")
    update.message.reply_text("/commandhelp - Know my commands")
    update.message.reply_text("/helpmegetapartner - Get advice on getting a partner")

dp.add_handler(CommandHandler("jhelp", help_command))

Now, I will with time add more commands, which may not fall under the given list. But there's no way (that I know of) to send the same message but in one single one, along with line breaks. This method will bombard them with messages and make them hate me. Please help!


Solution

  • You can use triple quotes like that :

    help_command_text = """What do you need my help in?
    /commandhelp - Know my commands
    /helpmegetapartner - Get advice on getting a partner
    /anothercommand ...
    """
    

    And then

    update.message.reply_text(help_command_text)