LemonCore.InboundMessage (lemon_core v0.1.0)

View Source

Normalized inbound message type (shared).

This struct represents an inbound message from any channel, normalized to a common format for processing by the router. It lives in :lemon_core so channel adapters do not need a compile-time dependency on :lemon_router.

Summary

Functions

Create an InboundMessage from Telegram update data.

Create a new InboundMessage.

Types

message()

@type message() :: %{
  id: binary() | nil,
  text: binary(),
  timestamp: non_neg_integer() | nil,
  reply_to_id: binary() | nil
}

peer()

@type peer() :: %{
  kind: :dm | :group | :channel,
  id: binary(),
  thread_id: binary() | nil
}

sender()

@type sender() :: %{
  optional(:bot) => boolean(),
  id: binary(),
  username: binary() | nil,
  display_name: binary() | nil
}

t()

@type t() :: %LemonCore.InboundMessage{
  account_id: binary(),
  channel_id: binary(),
  message: message(),
  meta: map() | nil,
  peer: peer(),
  raw: term(),
  sender: sender() | nil
}

Functions

from_telegram(transport, chat_id, message)

@spec from_telegram(transport :: atom(), chat_id :: integer(), message :: map()) ::
  t()

Create an InboundMessage from Telegram update data.

new(opts)

@spec new(keyword()) :: t()

Create a new InboundMessage.