Sexy.Bot.Sender (Sexy v0.9.13)

Copy Markdown View Source

Delivers Sexy.Utils.Object structs to Telegram and manages the message lifecycle.

This is the engine behind Sexy.Bot.send/2. You typically don't call it directly.

How it works

  1. Detects content type via Sexy.Utils.Object.detect_object_type/1
  2. Calls the appropriate Sexy.Bot.Api method (send_message, send_photo, send_document, etc.)
  3. If update_mid: true (default):
    • Deletes the old message via Session.get_message_id/1
    • Saves the new message id via Session.on_message_sent/4

Content type detection

Object fieldTypeAPI method
media: niltextsendMessage
upload_type: :document (or media: "file")documentsendDocument (multipart)
upload_type: :photophotosendPhoto (multipart)
upload_type: :videovideosendVideo (multipart)
upload_type: :animationanimationsendAnimation (multipart)
media starts with "A"photosendPhoto (by file_id)
media starts with "B"videosendVideo (by file_id)
media starts with "C"animationsendAnimation (by file_id)

Summary

Functions

Send an Object (or list of Objects) to Telegram.

Types

tg_response()

@type tg_response() :: map()

Functions

deliver(items, opts \\ [])

@spec deliver(
  Sexy.Utils.Object.t() | [Sexy.Utils.Object.t()],
  keyword()
) :: tg_response() | :ok

Send an Object (or list of Objects) to Telegram.

Options

  • :update_midtrue (default) to delete old message and save new mid, false to send without modifying screen state