Skip to content

Commit

Permalink
update Bot API to 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Borodin committed Dec 9, 2024
1 parent 1f7e826 commit eb62258
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
35 changes: 35 additions & 0 deletions src/types/AffiliateInfo.ts
Original file line number Diff line number Diff line change
@@ -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;
};
7 changes: 6 additions & 1 deletion src/types/StarTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TransactionPartner } from './TransactionPartner';
import { TransactionPartner } from './';

/**
* ## StarTransaction
Expand All @@ -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
*/
Expand Down
19 changes: 12 additions & 7 deletions src/types/TransactionPartner.ts
Original file line number Diff line number Diff line change
@@ -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;
24 changes: 24 additions & 0 deletions src/types/TransactionPartnerAffiliateProgram.ts
Original file line number Diff line number Diff line change
@@ -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;
};
9 changes: 6 additions & 3 deletions src/types/TransactionPartnerUser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { User } from './User';
import { PaidMedia } from './PaidMedia';
import { Gift } from './Gift';
import { User, PaidMedia, Gift, AffiliateInfo } from './';

/**
* ## TransactionPartnerUser
Expand All @@ -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
*/
Expand Down
2 changes: 2 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './AffiliateInfo';
export * from './Animation';
export * from './Audio';
export * from './BackgroundFill';
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit eb62258

Please sign in to comment.