Use this method to stream a partial message to a user while the message is being generated. Note that the streamed draft is ephemeral and acts as a temporary 30-second preview - once the output is finalized, you must call :meth:`~Bot.send_message` with the complete message to
(
self,
chat_id: int,
draft_id: int,
text: str | None = None,
message_thread_id: int | None = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
entities: Sequence["MessageEntity"] | None = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict | None = None,
)
| 1214 | ) |
| 1215 | |
| 1216 | async def send_message_draft( |
| 1217 | self, |
| 1218 | chat_id: int, |
| 1219 | draft_id: int, |
| 1220 | text: str | None = None, |
| 1221 | message_thread_id: int | None = None, |
| 1222 | parse_mode: ODVInput[str] = DEFAULT_NONE, |
| 1223 | entities: Sequence["MessageEntity"] | None = None, |
| 1224 | *, |
| 1225 | read_timeout: ODVInput[float] = DEFAULT_NONE, |
| 1226 | write_timeout: ODVInput[float] = DEFAULT_NONE, |
| 1227 | connect_timeout: ODVInput[float] = DEFAULT_NONE, |
| 1228 | pool_timeout: ODVInput[float] = DEFAULT_NONE, |
| 1229 | api_kwargs: JSONDict | None = None, |
| 1230 | ) -> bool: |
| 1231 | """Use this method to stream a partial message to a user while the message is being |
| 1232 | generated. Note that the streamed draft is ephemeral and acts as a temporary 30-second |
| 1233 | preview - once the output is finalized, you must call :meth:`~Bot.send_message` with |
| 1234 | the complete message to persist it in the user's chat. |
| 1235 | |
| 1236 | .. versionadded:: 22.6 |
| 1237 | |
| 1238 | .. versionchanged:: 22.7 |
| 1239 | Now all bots can use this method. |
| 1240 | |
| 1241 | |
| 1242 | Args: |
| 1243 | chat_id (:obj:`int`): Unique identifier for the target private chat. |
| 1244 | draft_id (:obj:`int`): Unique identifier of the message draft; must be non-zero. |
| 1245 | Changes of drafts with the same identifier are animated. |
| 1246 | text (:obj:`str`, optional): Text of the message to be sent, |
| 1247 | 0-:tg-const:`telegram.constants.MessageLimit.MAX_TEXT_LENGTH` characters after |
| 1248 | entities parsing. Pass an empty text to show a "Thinking..." placeholder. |
| 1249 | |
| 1250 | .. versionchanged:: 22.8 |
| 1251 | Bot API 10.0 now makes this an optional parameter. |
| 1252 | |
| 1253 | message_thread_id (:obj:`int`, optional): Unique identifier for the target |
| 1254 | message thread. |
| 1255 | parse_mode (:obj:`str`): |parse_mode| |
| 1256 | entities (Sequence[:class:`telegram.MessageEntity`], optional): Sequence of special |
| 1257 | entities that appear in message text, which can be specified instead of |
| 1258 | :paramref:`parse_mode`. |
| 1259 | |
| 1260 | |sequenceargs| |
| 1261 | |
| 1262 | Returns: |
| 1263 | :obj:`bool`: On success, :obj:`True` is returned. |
| 1264 | """ |
| 1265 | data: JSONDict = { |
| 1266 | "chat_id": chat_id, |
| 1267 | "draft_id": draft_id, |
| 1268 | "text": text, |
| 1269 | "entities": entities, |
| 1270 | } |
| 1271 | return await self._send_message( |
| 1272 | "sendMessageDraft", |
| 1273 | data, |