telega/message

Types

pub type Chat {
  Chat(
    id: Int,
    username: Option(String),
    first_name: Option(String),
    last_name: Option(String),
    is_forum: Option(Bool),
  )
}

Constructors

  • Chat(
      id: Int,
      username: Option(String),
      first_name: Option(String),
      last_name: Option(String),
      is_forum: Option(Bool),
    )

    Official reference: https://core.telegram.org/bots/api#chat

    Arguments

    • id

      Unique identifier for this chat.

    • username

      Username, for private chats, supergroups and channels if available

    • first_name

      First name of the other party in a private chat

    • last_name

      Last name of the other party in a private chat

    • is_forum

      True, if the supergroup chat is a forum (has topics enabled)

Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “blockquote” (block quotation), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames), “custom_emoji” (for inline custom emoji stickers) Offset in UTF-16 code units to the start of the entity Length of the entity in UTF-16 code units For “text_link” only, URL that will be opened after user taps on the text For “text_mention” only, the mentioned user For “pre” only, the programming language of the entity text For “custom_emoji” only, unique identifier of the custom emoji. Use getCustomEmojiStickers to get full information about the sticker

pub type InlineKeyboardButton {
  InlineKeyboardButton(
    text: String,
    url: Option(String),
    callback_data: Option(String),
  )
}

Constructors

  • InlineKeyboardButton(
      text: String,
      url: Option(String),
      callback_data: Option(String),
    )

    Official reference: https://core.telegram.org/bots/api#inlinekeyboardbutton

    Arguments

    • text

      Label text on the button

    • url

      HTTP or tg:// URL to be opened when the button is pressed. Links tg://user?id=<user_id> can be used to mention a user by their identifier without using a username, if this is allowed by their privacy settings.

    • callback_data

      Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes

Label text on the button HTTP or tg:// URL to be opened when the button is pressed. Links tg://user?id=<user_id> can be used to mention a user by their identifier without using a username, if this is allowed by their privacy settings. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes

pub type InlineKeyboardMarkup {
  InlineKeyboardMarkup(
    inline_keyboard: List(List(InlineKeyboardButton)),
  )
}

Constructors

  • InlineKeyboardMarkup(
      inline_keyboard: List(List(InlineKeyboardButton)),
    )

    Official reference: https://core.telegram.org/bots/api#inlinekeyboardmarkup

Messages represent the data that the bot receives from the Telegram API.

pub type Message {
  Message(kind: MessageKind, raw: RawMessage)
}

Constructors

  • Message(kind: MessageKind, raw: RawMessage)

    Arguments

    • raw

      Raw message data from the Telegram API.

Unique identifier for this user or bot. User’s or bot’s first name User’s or bot’s last name Username, for private chats, supergroups and channels if available IETF language tag of the user’s language True, if this user is a Telegram Premium user True, if this user added the bot to the attachment menu

pub type MessageEntity {
  MessageEntity(
    entity_type: String,
    offset: Int,
    length: Int,
    url: Option(String),
    user: Option(User),
    language: Option(String),
    custom_emoji_id: Option(String),
  )
}

Constructors

  • MessageEntity(
      entity_type: String,
      offset: Int,
      length: Int,
      url: Option(String),
      user: Option(User),
      language: Option(String),
      custom_emoji_id: Option(String),
    )

    Official reference: https://core.telegram.org/bots/api#messageentity

    Arguments

    • entity_type

      Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “blockquote” (block quotation), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames), “custom_emoji” (for inline custom emoji stickers)

    • offset

      Offset in UTF-16 code units to the start of the entity

    • length

      Length of the entity in UTF-16 code units

    • url

      For “text_link” only, URL that will be opened after user taps on the text

    • user

      For “text_mention” only, the mentioned user

    • language

      For “pre” only, the programming language of the entity text

    • custom_emoji_id

      For “custom_emoji” only, unique identifier of the custom emoji. Use getCustomEmojiStickers to get full information about the sticker

The update’s unique identifier.

pub type MessageKind {
  CommonMessage
  CommandMessage
  TextMessage
}

Constructors

  • CommonMessage
  • CommandMessage
  • TextMessage
pub type RawMessage {
  RawMessage(
    message_id: Int,
    message_thread_id: Option(Int),
    from: Option(User),
    sender_chat: Option(Chat),
    sender_boost_count: Option(Int),
    date: Int,
    chat: Chat,
    is_topic_message: Option(Bool),
    is_automatic_forward: Option(Bool),
    reply_to_message: Option(RawMessage),
    via_bot: Option(User),
    edit_date: Option(Int),
    has_protected_content: Option(Bool),
    media_group_id: Option(String),
    author_signature: Option(String),
    text: Option(String),
    entities: Option(List(MessageEntity)),
    caption: Option(String),
    caption_entities: Option(List(MessageEntity)),
    has_media_spoiler: Option(Bool),
    new_chat_members: Option(List(User)),
    left_chat_member: Option(User),
    new_chat_title: Option(String),
    delete_chat_photo: Option(Bool),
    group_chat_created: Option(Bool),
    supergroup_chat_created: Option(Bool),
    channel_chat_created: Option(Bool),
    migrate_to_chat_id: Option(Int),
    migrate_from_chat_id: Option(Int),
    connected_website: Option(String),
    reply_markup: Option(InlineKeyboardMarkup),
  )
}

Constructors

  • RawMessage(
      message_id: Int,
      message_thread_id: Option(Int),
      from: Option(User),
      sender_chat: Option(Chat),
      sender_boost_count: Option(Int),
      date: Int,
      chat: Chat,
      is_topic_message: Option(Bool),
      is_automatic_forward: Option(Bool),
      reply_to_message: Option(RawMessage),
      via_bot: Option(User),
      edit_date: Option(Int),
      has_protected_content: Option(Bool),
      media_group_id: Option(String),
      author_signature: Option(String),
      text: Option(String),
      entities: Option(List(MessageEntity)),
      caption: Option(String),
      caption_entities: Option(List(MessageEntity)),
      has_media_spoiler: Option(Bool),
      new_chat_members: Option(List(User)),
      left_chat_member: Option(User),
      new_chat_title: Option(String),
      delete_chat_photo: Option(Bool),
      group_chat_created: Option(Bool),
      supergroup_chat_created: Option(Bool),
      channel_chat_created: Option(Bool),
      migrate_to_chat_id: Option(Int),
      migrate_from_chat_id: Option(Int),
      connected_website: Option(String),
      reply_markup: Option(InlineKeyboardMarkup),
    )

    Official reference: https://core.telegram.org/bots/api#message

    Arguments

    • message_id

      Unique message identifier inside this chat

    • message_thread_id

      Unique identifier of a message thread to which the message belongs; for supergroups only

    • from

      Sender of the message; empty for messages sent to channels. For backward compatibility, the field contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.

    • sender_chat

      Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group. For backward compatibility, the field from contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.

    • sender_boost_count

      If the sender of the message boosted the chat, the number of boosts added by the user

    • date

      Date the message was sent in Unix time. It is always a positive number, representing a valid date.

    • chat

      Chat the message belongs to

    • is_topic_message

      True, if the message is sent to a forum topic

    • is_automatic_forward

      True, if the message is a channel post that was automatically forwarded to the connected discussion group

    • reply_to_message

      For replies in the same chat and message thread, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.

    • edit_date

      Date the message was last edited in Unix time

    • has_protected_content

      True, if the message can’t be forwarded

    • media_group_id

      The unique identifier of a media message group this message belongs to

    • author_signature

      Signature of the post author for messages in channels, or the custom title of an anonymous group administrator

    • text

      For text messages, the actual UTF-8 text of the message

    • entities

      For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text

    • caption_entities

      For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption

    • has_media_spoiler

      True, if the message media is covered by a spoiler animation

    • new_chat_members

      New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)

    • left_chat_member

      A member was removed from the group, information about them (this member may be the bot itself)

    • new_chat_title

      A chat title was changed to this value

    • delete_chat_photo

      Service message: the chat photo was deleted

    • group_chat_created

      Service message: the group has been created

    • supergroup_chat_created

      Service message: the supergroup has been created. This field can’t be received in a message coming through updates, because bot can’t be a member of a supergroup when it is created. It can only be found in reply_to_message if someone replies to a very first message in a directly created supergroup.

    • channel_chat_created

      Service message: the channel has been created. This field can’t be received in a message coming through updates, because bot can’t be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel.

    • migrate_to_chat_id

      The group has been migrated to a supergroup with the specified identifier.

    • migrate_from_chat_id

      The supergroup has been migrated from a group with the specified identifier.

    • connected_website

      The domain name of the website on which the user has logged in. More about Telegram Login >>

    • reply_markup

      Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons.

Unique message identifier inside this chat Unique identifier of a message thread to which the message belongs; for supergroups only Sender of the message; empty for messages sent to channels. For backward compatibility, the field contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group. For backward compatibility, the field from contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. If the sender of the message boosted the chat, the number of boosts added by the user Date the message was sent in Unix time. It is always a positive number, representing a valid date. Chat the message belongs to True, if the message is sent to a forum topic True, if the message is a channel post that was automatically forwarded to the connected discussion group For replies in the same chat and message thread, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. Date the message was last edited in Unix time True, if the message can’t be forwarded The unique identifier of a media message group this message belongs to Signature of the post author for messages in channels, or the custom title of an anonymous group administrator For text messages, the actual UTF-8 text of the message For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption True, if the message media is covered by a spoiler animation New members that were added to the group or supergroup and information about them (the bot itself may be one of these members) A member was removed from the group, information about them (this member may be the bot itself) A chat title was changed to this value Service message: the chat photo was deleted Service message: the group has been created Service message: the supergroup has been created. This field can’t be received in a message coming through updates, because bot can’t be a member of a supergroup when it is created. It can only be found in reply_to_message if someone replies to a very first message in a directly created supergroup. Service message: the channel has been created. This field can’t be received in a message coming through updates, because bot can’t be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel. The group has been migrated to a supergroup with the specified identifier. The supergroup has been migrated from a group with the specified identifier. The domain name of the website on which the user has logged in. More about Telegram Login >> Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons.

pub type Update {
  Update(message: RawMessage, update_id: Int)
}

Constructors

  • Update(message: RawMessage, update_id: Int)

    Official reference: https://core.telegram.org/bots/api#update

    Arguments

    • update_id

      The update’s unique identifier.

Unique identifier for this chat. Username, for private chats, supergroups and channels if available First name of the other party in a private chat Last name of the other party in a private chat True, if the supergroup chat is a forum (has topics enabled)

pub type User {
  User(
    id: Int,
    is_bot: Bool,
    first_name: String,
    last_name: String,
    username: Option(String),
    language_code: Option(String),
    is_premium: Option(Bool),
    added_to_attachment_menu: Option(Bool),
  )
}

Constructors

  • User(
      id: Int,
      is_bot: Bool,
      first_name: String,
      last_name: String,
      username: Option(String),
      language_code: Option(String),
      is_premium: Option(Bool),
      added_to_attachment_menu: Option(Bool),
    )

    Official reference: https://core.telegram.org/bots/api#user

    Arguments

    • id

      Unique identifier for this user or bot.

    • first_name

      User’s or bot’s first name

    • last_name

      User’s or bot’s last name

    • username

      Username, for private chats, supergroups and channels if available

    • language_code

      IETF language tag of the user’s language

    • is_premium

      True, if this user is a Telegram Premium user

    • added_to_attachment_menu

      True, if this user added the bot to the attachment menu

Functions

pub fn decode(
  json: Dynamic,
) -> Result(Message, List(DecodeError))

Decode a message from the Telegram API.

Search Document