Telegramex (Telegramex v0.1.0) View Source

Telegram's Bot API wrapper.

Hex.pm Version CI Coverage Status

Features

  • Support for multiple bots
  • Configurable HTTP client
  • No application configuration

Usage

  1. Add the dependencies
def deps do
  [
    {:finch, "~> 0.5"},
    {:telegramex, "~> 0.1.0"}
  ]
end
  1. Add the finch client to your supervision tree
children = [
  {Finch, name: Telegramex.HTTPClient}
]

Note: Checkout the Telegramex.Client on how to use other HTTP client.

  1. Make a request
client = %Telegramex.Client{token: "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"}
Telegramex.get_updates(client)

Full documentation can be found at https://hexdocs.pm/telegramex.

Changelog

See the changelog.

Link to this section Summary

Functions

Use this method to send answers to an inline query.

Use this method to receive incoming updates using long polling.

Link to this section Functions

Link to this function

answer_inline_query(client, inline_query_id, results, opts \\ [])

View Source

Specs

answer_inline_query(Telegramex.Client.t(), String.t(), [map()], Keyword.t()) ::
  {:ok, map()} | {:error, term()}

Use this method to send answers to an inline query.

Options

  • cache_time - (optional)
  • is_personal - (optional)
  • next_offset - (optional)
  • switch_pm_text - (optional)
  • switch_pm_parameter - (optional)

Checkout the Telegram Bot API Documentation for a complete description of each option.

Usage

client = %Telegramex.Client{token: "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"}
Telegramex.answer_inline_query(client, "2648678931644704387", results)
Link to this function

get_updates(client, opts \\ [])

View Source

Specs

get_updates(Telegramex.Client.t(), Keyword.t()) ::
  {:ok, map()} | {:error, term()}

Use this method to receive incoming updates using long polling.

Options

  • offset - (optional)
  • limit - (optional)
  • timeout - (optional)
  • allowed_updates - (optional)

Checkout the Telegram Bot API Documentation for a complete description of each option.

Usage

client = %Telegramex.Client{token: "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"}
Telegramex.get_updates(client)