skip to Main Content

Recently Telegram has provided the ability to quote texts:

enter image description here

I want to send a message using Telegram Bot API using html as parse_mode but I cannot find any mention of how to do it using html tags in official docs.

How is this achievable?

2

Answers


  1. The formatting options providide by the Telegram Bot API do not include this functionality yet.

    Login or Signup to reply.
  2. If you want to quote a specific part of a message (for it to appear as a clickable object).
    You can modify reply_parameters in method sendMessage.

    I didn’t manage to build a post request that sends message with such quote, but here is how it looks using Aiogram3:

    from config import TOKEN, chat_id, message_id
    from aiogram import Bot, Dispatcher, types
    import asyncio
    
    bot = Bot(token = TOKEN)
    dp = Dispatcher()
    
    asyncio.run(
        bot.send_message(
            chat_id=chat_id,
            text='Quoting the message!',
            reply_parameters=types.ReplyParameters(
                chat_id=chat_id,
                message_id=message_id,
                quote='this'
            )
        )
    )
    

    Unfortunatelly, I can’t post screenshot to show how it works…
    That’s my first ever stackoverflow answer 😅


    You can also simply format message like as if it has a quote.

    If you desire to use HTML formatting, there is a <blockquote> tag.

    This is not a quote
    <blockquote>But this is!</blockquote>
    

    Or you can set parse_mode to MarkdownV2 and use the format below:

    This is not a quote
    > But this is!
    

    That’s how it looks with Aiogram3:

    from config import TOKEN, chat_id, message_id
    from aiogram import Bot, Dispatcher, types
    import asyncio
    
    bot = Bot(token = TOKEN)
    dp = Dispatcher()
    
    asyncio.run(
        bot.send_message(
            chat_id=chat_id,
            text=(
                'This is not a quoten'
                '<blockquote>But this is!</blockquote>'
            ),
            parse_mode='HTML'   
        )
    )
    
    
    

    All the formatting info on Telegram is provided here!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search