send_message_draft()

Client.send_message_draft()

Use this method to stream a partial message to a user while the message is being generated.

Usable by Users Bots
Parameters:
  • chat_id (int | str) – Unique identifier (int) or username (str) of the target chat.

  • draft_id (int) – Unique identifier of the message draft, must be non-zero. Changes of drafts with the same identifier are animated.

  • text (str) – Text of the message to be sent.

  • message_thread_id (int, optional) – Unique identifier for the target message thread.

  • parse_mode (ParseMode, optional) – By default, texts are parsed using both Markdown and HTML styles. You can combine both syntaxes together.

  • entities (List of MessageEntity) – List of special entities that appear in message text, which can be specified instead of parse_mode.

Returns:

bool – On success, True is returned.

Example

text = "Hello! I'm your Pyrogram bot! How can I help you?"
words = text.split()
draft_id = app.rnd_id()

for i, word in enumerate(words):
    await app.send_message_draft(
        chat_id=chat_id,
        draft_id=draft_id,
        text=" ".join(words[:i+1]),
    )

    await asyncio.sleep(0.33)

await app.send_message(chat_id, text)