Skip to content

Commit

Permalink
chore(telegram): update telegram types to June 20, 2022
Browse files Browse the repository at this point in the history
  • Loading branch information
Anillc committed Jan 11, 2023
1 parent 453da0f commit 47ceb74
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
8 changes: 8 additions & 0 deletions adapters/telegram/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export interface User {
username?: string
/** Optional. IETF language tag of the user's language */
language_code?: string
/** Optional. True, if this user is a Telegram Premium user */
is_premium?: boolean
/** Optional. True, if this user added the bot to the attachment menu */
added_to_attachment_menu?: boolean
/** Optional. True, if the bot can be invited to groups. Returned only in getMe. */
can_join_groups?: boolean
/** Optional. True, if privacy mode is disabled for the bot. Returned only in getMe. */
Expand Down Expand Up @@ -85,6 +89,10 @@ export interface Chat {
bio?: string
/** Optional. True, if privacy settings of the other party in the private chat allows to use tg://user?id=<user_id> links only in chats with the user. Returned only in getChat. */
has_private_forwards?: boolean
/** Optional. True, if users need to join the supergroup before they can send messages. Returned only in getChat. */
join_to_send_messages?: boolean
/** Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators. Returned only in getChat. */
join_by_request?: boolean
/** Optional. Description, for groups, supergroups and channel chats. Returned only in getChat. */
description?: string
/** Optional. Primary invite link, for groups, supergroups and channel chats. Returned only in getChat. */
Expand Down
49 changes: 49 additions & 0 deletions adapters/telegram/src/types/payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,49 @@ export interface SendInvoicePayload {
reply_markup?: InlineKeyboardMarkup
}

export interface CreateInvoiceLinkPayload {
/** Product name, 1-32 characters */
title: string
/** Product description, 1-255 characters */
description: string
/** Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. */
payload: string
/** Payment provider token, obtained via BotFather */
provider_token: string
/** Three-letter ISO 4217 currency code, see more on currencies */
currency: string
/** Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) */
prices: LabeledPrice[]
/** The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0 */
max_tip_amount?: number
/** A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount. */
suggested_tip_amounts?: number[]
/** JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider. */
provider_data?: string
/** URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. */
photo_url?: string
/** Photo size in bytes */
photo_size?: number
/** Photo width */
photo_width?: number
/** Photo height */
photo_height?: number
/** Pass True if you require the user's full name to complete the order */
need_name?: boolean
/** Pass True if you require the user's phone number to complete the order */
need_phone_number?: boolean
/** Pass True if you require the user's email address to complete the order */
need_email?: boolean
/** Pass True if you require the user's shipping address to complete the order */
need_shipping_address?: boolean
/** Pass True if the user's phone number should be sent to the provider */
send_phone_number_to_provider?: boolean
/** Pass True if the user's email address should be sent to the provider */
send_email_to_provider?: boolean
/** Pass True if the final price depends on the shipping method */
is_flexible?: boolean
}

export interface AnswerShippingQueryPayload {
/** Unique identifier for the query to be answered */
shipping_query_id?: string
Expand Down Expand Up @@ -234,6 +277,11 @@ declare module './internal' {
* @see https://core.telegram.org/bots/api#sendinvoice
*/
sendInvoice(payload: SendInvoicePayload): Promise<Message>
/**
* Use this method to create a link for an invoice. Returns the created invoice link as String on success.
* @see https://core.telegram.org/bots/api#createinvoicelink
*/
createInvoiceLink(payload: CreateInvoiceLinkPayload): Promise<string>
/**
* If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.
* @see https://core.telegram.org/bots/api#answershippingquery
Expand All @@ -249,5 +297,6 @@ declare module './internal' {
}

Internal.define('sendInvoice')
Internal.define('createInvoiceLink')
Internal.define('answerShippingQuery')
Internal.define('answerPreCheckoutQuery')
4 changes: 3 additions & 1 deletion adapters/telegram/src/types/sticker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Float, ForceReply, InlineKeyboardMarkup, InputFile, Integer, Internal, Message, PhotoSize, ReplyKeyboardMarkup, ReplyKeyboardRemove } from '.'
import { File, Float, ForceReply, InlineKeyboardMarkup, InputFile, Integer, Internal, Message, PhotoSize, ReplyKeyboardMarkup, ReplyKeyboardRemove } from '.'

/**
* This object represents a sticker.
Expand All @@ -23,6 +23,8 @@ export interface Sticker {
emoji?: string
/** Optional. Name of the sticker set to which the sticker belongs */
set_name?: string
/** Optional. For premium regular stickers, premium animation for the sticker */
premium_animation?: File
/** Optional. For mask stickers, the position where the mask should be placed */
mask_position?: MaskPosition
/** Optional. File size in bytes */
Expand Down
2 changes: 2 additions & 0 deletions adapters/telegram/src/types/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export interface SetWebhookPayload {
allowed_updates?: string[]
/** Pass True to drop all pending updates */
drop_pending_updates?: boolean
/** A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters. Only characters A-Z, a-z, 0-9, _ and - are allowed. The header is useful to ensure that the request comes from a webhook set by you. */
secret_token?: string
}

export interface DeleteWebhookPayload {
Expand Down

0 comments on commit 47ceb74

Please sign in to comment.