send_story()

Client.send_story()

Post new story.

Usable by Users Bots
Parameters:
  • chat_id (int | str) – Unique identifier (int) or username (str) of the target chat. For your personal cloud (Saved Messages) you can simply use “me” or “self”.

  • media (str | BinaryIO) – Video or photo to send. Pass a file_id as string to send a animation that exists on the Telegram servers, pass a file path as string to upload a new animation that exists on your local machine, or pass a binary file-like object with its attribute “.name” set for in-memory uploads.

  • caption (str, optional) – Story caption, 0-1024 characters.

  • period (int, optional) – Period after which the story is moved to archive (and to the profile if pinned is set), in seconds. Must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400 for Telegram Premium users, and 86400 otherwise.

  • media_areas (List of MediaArea, optional) – List of media areas to add to the story.

  • duration (int, optional) – Duration of sent video in seconds.

  • width (int, optional) – Video width.

  • height (int, optional) – Video height.

  • thumb (str | BinaryIO, optional) – Thumbnail of the video sent. The thumbnail should be in JPEG format and less than 200 KB in size. A thumbnail’s width and height should not exceed 320 pixels. Thumbnails can’t be reused and can be only uploaded as a new file.

  • supports_streaming (bool, optional) – True, if the uploaded video is suitable for streaming. Defaults to True.

  • file_name (str, optional) – File name of the story sent.

  • privacy (StoriesPrivacyRules, optional) – Story privacy. Defaults to PUBLIC

  • allowed_users (List of int, optional) – List of user_id or chat_id of chat users who are allowed to view stories. Note: chat_id available only with SELECTED_USERS. Works with CLOSE_FRIENDS and SELECTED_USERS only

  • disallowed_users (List of int, optional) – List of user_id whos disallow to view the stories. Note: Works with PUBLIC and CONTACTS only

  • pinned (bool, optional) – If True, the story will be pinned.

  • protect_content (bool, optional) – Protects the contents of the sent story from forwarding and saving.

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

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

  • progress (Callable, optional) – Pass a callback function to view the file transmission progress. The function must take (current, total) as positional arguments (look at Other Parameters below for a detailed description) and will be called back each time a new file chunk has been successfully transmitted.

  • progress_args (tuple, optional) – Extra custom arguments for the progress callback function. You can pass anything you need to be available in the progress callback scope; for example, a Message object or a Client instance in order to edit the message with the updated progress status.

Returns:

Story a single story is returned.

Example

# Post story to your profile
await app.send_story("me", "story.png", caption='My new story!')

# Post story to channel
await app.send_story(123456, "story.png", caption='My new story!')
Raises:

ValueError – In case of invalid arguments.