TelegramEx.Builder.Contact (TelegramEx v1.2.1)

Copy Markdown View Source

Builder for contact payloads.

This module provides a fluent API for sending contact information.

Examples

# Send contact with first name only
ctx
|> Contact.contact("John", "+123456789")
|> Contact.send(chat_id)

# Send contact with first and last name
ctx
|> Contact.contact("John", "Doe", "+123456789")
|> Contact.send(chat_id)

# Send contact silently
ctx
|> Contact.contact("Jane", "+987654321")
|> Contact.silent()
|> Contact.send(chat_id)

Summary

Functions

Sets contact information with first name and phone number.

Sets contact information with first name, last name, and phone number.

Sends the contact to the specified chat.

Sends the contact without notification sound.

Functions

contact(ctx, name, phone)

@spec contact(map(), String.t(), String.t()) :: map()

Sets contact information with first name and phone number.

Parameters

  • ctx - Context map
  • name - Contact's first name
  • phone - Contact's phone number

Returns

Updated context map with contact data set.

Examples

ctx
|> Contact.contact("John", "+1234567890")
|> Contact.send(chat_id)

contact(ctx, first_name, last_name, phone)

@spec contact(map(), String.t(), String.t(), String.t()) :: map()

Sets contact information with first name, last name, and phone number.

Parameters

  • ctx - Context map
  • first_name - Contact's first name
  • last_name - Contact's last name
  • phone - Contact's phone number

Returns

Updated context map with contact data set.

Examples

ctx
|> Contact.contact("John", "Doe", "+1234567890")
|> Contact.send(chat_id)

send(ctx, id)

@spec send(map(), integer()) :: :ok | {:error, term()}

Sends the contact to the specified chat.

Parameters

  • ctx - Context map with accumulated contact data
  • id - Chat ID to send the contact to

Returns

  • :ok - Contact sent successfully
  • {:error, reason} - Failed to send contact

silent(ctx)

@spec silent(map()) :: map()

Sends the contact without notification sound.

Parameters

  • ctx - Context map

Returns

Updated context map with silent flag set.