Vibe.Gateway.Message (vibe v0.2.3)

Copy Markdown View Source

Normalized inbound message from an external chat gateway.

Platform adapters should download/copy media to local files or session artifacts before constructing this struct. The rest of Vibe can then process text, attachments, source identity, and replies without depending on Telegram or any other platform SDK.

Summary

Functions

Extracts a slash command name without the leading slash or bot suffix.

Returns true when the message text starts with a slash command.

Returns the text after a slash command, normalizing common mobile dash substitutions.

Builds a normalized gateway message.

Types

media()

@type media() :: %{
  path: String.t(),
  mime_type: String.t() | nil,
  filename: String.t() | nil
}

message_type()

@type message_type() ::
  :text
  | :command
  | :photo
  | :video
  | :audio
  | :voice
  | :document
  | :sticker
  | :location

t()

@type t() :: %Vibe.Gateway.Message{
  id: String.t() | nil,
  media: [media()],
  metadata: map(),
  platform_update_id: String.t() | integer() | nil,
  reply_to_message_id: String.t() | nil,
  reply_to_text: String.t() | nil,
  source: Vibe.Gateway.Source.t(),
  text: String.t(),
  timestamp: DateTime.t() | nil,
  type: message_type()
}

Functions

command(message)

@spec command(t()) :: String.t() | nil

Extracts a slash command name without the leading slash or bot suffix.

command?(message)

@spec command?(t()) :: boolean()

Returns true when the message text starts with a slash command.

command_args(message)

@spec command_args(t()) :: String.t()

Returns the text after a slash command, normalizing common mobile dash substitutions.

new(source, opts \\ [])

@spec new(
  Vibe.Gateway.Source.t(),
  keyword()
) :: t()

Builds a normalized gateway message.