diff --git a/README.md b/README.md index 7a53e44..f98b488 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![npm](https://img.shields.io/npm/dt/typescript-telegram-bot-api)](https://www.npmjs.com/package/typescript-telegram-bot-api) [![codecov](https://codecov.io/github/Borodin/typescript-telegram-bot-api/graph/badge.svg?token=509N5AZDTV)](https://codecov.io/github/Borodin/typescript-telegram-bot-api) [![codesandbox](https://img.shields.io/badge/Open_in-sandbox-eaff96)](https://codesandbox.io/p/sandbox/interesting-wave-qgspfs) -[![GitHub](https://img.shields.io/badge/Bot_API-v8.0-0088cc)](https://core.telegram.org/bots/api#november-17-2024) +[![GitHub](https://img.shields.io/badge/Bot_API-v8.1-0088cc)](https://core.telegram.org/bots/api#december-4-2024) This is a TypeScript wrapper for the [Telegram Bot API](https://core.telegram.org/bots/api) Node.js and browsers. It allows you to easily interact with the Telegram Bot API using TypeScript. diff --git a/package.json b/package.json index 3e82f5a..99d55f4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "type": "commonjs", "name": "typescript-telegram-bot-api", - "version": "0.5.0", + "version": "0.6.0", "description": "Telegram Bot API wrapper for Node.js written in TypeScript", "repository": "github:Borodin/typescript-telegram-bot-api", "main": "dist/index.js", diff --git a/src/types/AffiliateInfo.ts b/src/types/AffiliateInfo.ts new file mode 100644 index 0000000..21614ed --- /dev/null +++ b/src/types/AffiliateInfo.ts @@ -0,0 +1,35 @@ +import { User, Chat } from './'; + +/** + * ## AffiliateInfo + * Contains information about the affiliate that received a commission via this transaction. + */ +export type AffiliateInfo = { + /** + * Optional. The bot or the user that received an affiliate commission if it was received by a bot or a user + */ + affiliate_user?: User; + + /** + * Optional. The chat that received an affiliate commission if it was received by a chat + */ + affiliate_chat?: Chat; + + /** + * The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars received by the bot from + * referred users + */ + commission_per_mille: number; + + /** + * Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for + * refunds + */ + amount: number; + + /** + * Optional. The number of 1/1000000000 shares of Telegram Stars received by the affiliate; + * from -999999999 to 999999999; can be negative for refunds + */ + nanostar_amount?: number; +}; diff --git a/src/types/StarTransaction.ts b/src/types/StarTransaction.ts index 443512f..bfec1ee 100644 --- a/src/types/StarTransaction.ts +++ b/src/types/StarTransaction.ts @@ -1,4 +1,4 @@ -import { TransactionPartner } from './TransactionPartner'; +import { TransactionPartner } from './'; /** * ## StarTransaction @@ -18,6 +18,11 @@ export type StarTransaction = { */ amount: number; + /** + * Optional. The number of 1/1000000000 shares of Telegram Stars transferred by the transaction; from 0 to 999999999 + */ + nanostar_amount?: number; + /** * Date the transaction was created in Unix time */ diff --git a/src/types/TransactionPartner.ts b/src/types/TransactionPartner.ts index 5863e11..7619bae 100644 --- a/src/types/TransactionPartner.ts +++ b/src/types/TransactionPartner.ts @@ -1,23 +1,28 @@ -import { TransactionPartnerFragment } from './TransactionPartnerFragment'; -import { TransactionPartnerUser } from './TransactionPartnerUser'; -import { TransactionPartnerTelegramAds } from './TransactionPartnerTelegramAds'; -import { TransactionPartnerTelegramApi } from './TransactionPartnerTelegramApi'; -import { TransactionPartnerOther } from './TransactionPartnerOther'; +import { + TransactionPartnerFragment, + TransactionPartnerUser, + TransactionPartnerTelegramAds, + TransactionPartnerTelegramApi, + TransactionPartnerOther, + TransactionPartnerAffiliateProgram, +} from './'; /** * ## TransactionPartner * This object describes the source of a transaction, or its recipient for outgoing transactions. Currently, it can be * one of - * - TransactionPartnerFragment * - TransactionPartnerUser + * - TransactionPartnerAffiliateProgram + * - TransactionPartnerFragment * - TransactionPartnerTelegramAds * - TransactionPartnerTelegramApi * - TransactionPartnerOther * @see https://core.telegram.org/bots/api#transactionpartner */ export type TransactionPartner = - | TransactionPartnerFragment | TransactionPartnerUser + | TransactionPartnerAffiliateProgram + | TransactionPartnerFragment | TransactionPartnerTelegramAds | TransactionPartnerTelegramApi | TransactionPartnerOther; diff --git a/src/types/TransactionPartnerAffiliateProgram.ts b/src/types/TransactionPartnerAffiliateProgram.ts new file mode 100644 index 0000000..4e6584c --- /dev/null +++ b/src/types/TransactionPartnerAffiliateProgram.ts @@ -0,0 +1,24 @@ +import { User } from './'; + +/** + * ## TransactionPartnerAffiliateProgram + * Describes the affiliate program that issued the affiliate commission received via this transaction. + * @see https://core.telegram.org/bots/api#transactionpartneraffiliateprogram + */ +export type TransactionPartnerAffiliateProgram = { + /** + * Type of the transaction partner, always “affiliate_program” + */ + type: 'affiliate_program'; + + /** + * Optional. Information about the bot that sponsored the affiliate program + */ + sponsor_user?: User; + + /** + * The number of Telegram Stars received by the bot for each 1000 Telegram Stars received by the affiliate program + * sponsor from referred users + */ + commission_per_mille: number; +}; diff --git a/src/types/TransactionPartnerUser.ts b/src/types/TransactionPartnerUser.ts index 9885d60..fa39782 100644 --- a/src/types/TransactionPartnerUser.ts +++ b/src/types/TransactionPartnerUser.ts @@ -1,6 +1,4 @@ -import { User } from './User'; -import { PaidMedia } from './PaidMedia'; -import { Gift } from './Gift'; +import { User, PaidMedia, Gift, AffiliateInfo } from './'; /** * ## TransactionPartnerUser @@ -18,6 +16,11 @@ export type TransactionPartnerUser = { */ user: User; + /** + * Optional. Information about the affiliate that received a commission via this transaction + */ + affiliate?: AffiliateInfo; + /** * Optional. Bot-specified invoice payload */ diff --git a/src/types/index.ts b/src/types/index.ts index 9e3bc01..1605424 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,3 +1,4 @@ +export * from './AffiliateInfo'; export * from './Animation'; export * from './Audio'; export * from './BackgroundFill'; @@ -206,6 +207,7 @@ export * from './PaidMediaPreview'; export * from './PaidMediaPurchased'; export * from './PaidMediaVideo'; export * from './TransactionPartner'; +export * from './TransactionPartnerAffiliateProgram'; export * from './TransactionPartnerFragment'; export * from './TransactionPartnerOther'; export * from './TransactionPartnerTelegramAds';