Skip to content

Commit

Permalink
feat: support Bot API 7.10 (#54)
Browse files Browse the repository at this point in the history
* feat: support Bot API 7.10

* fix: make prize_star_count_optional

* style: fix order and docs

* docs: insert new star count value
  • Loading branch information
KnorpelSenf authored Sep 6, 2024
1 parent 2456d5e commit 23c208c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
6 changes: 4 additions & 2 deletions manage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -902,14 +902,16 @@ export interface ChatBoostSourceGiftCode {
user: User;
}

/** The boost was obtained by the creation of a Telegram Premium giveaway. This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription. */
/** The boost was obtained by the creation of a Telegram Premium or a Telegram Star giveaway. This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription for Telegram Premium giveaways and prize_star_count / 500 times for one year for Telegram Star giveaways. */
export interface ChatBoostSourceGiveaway {
/** Source of the boost, always “giveaway” */
source: "giveaway";
/** Identifier of a message in the chat with the giveaway; the message could have been deleted already */
giveaway_message_id: number;
/** User that won the prize in the giveaway if any */
/** User that won the prize in the giveaway if any; for Telegram Premium giveaways only */
user?: User;
/** The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only */
prize_star_count?: number;
/** True, if the giveaway was completed, but there was no user to win the prize */
is_unclaimed?: true;
}
Expand Down
17 changes: 13 additions & 4 deletions message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1186,8 +1186,11 @@ export interface VideoChatParticipantsInvited {
users: User[];
}

/** This object represents a service message about the creation of a scheduled giveaway. Currently holds no information. */
export interface GiveawayCreated {}
/** This object represents a service message about the creation of a scheduled giveaway. */
export interface GiveawayCreated {
/** The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only */
prize_star_count?: number;
}

/** This object represents a message about a scheduled giveaway. */
export interface Giveaway {
Expand All @@ -1205,7 +1208,9 @@ export interface Giveaway {
prize_description?: string;
/** A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which eligible users for the giveaway must come. If empty, then all users can participate in the giveaway. Users with a phone number that was bought on Fragment can always participate in giveaways. */
country_codes?: string[];
/** The number of months the Telegram Premium subscription won from the giveaway will be active for */
/** The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only */
prize_star_count?: number;
/** The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only */
premium_subscription_month_count?: number;
}

Expand All @@ -1223,7 +1228,9 @@ export interface GiveawayWinners {
winners: User[];
/** The number of other chats the user had to join in order to be eligible for the giveaway */
additional_chat_count?: number;
/** The number of months the Telegram Premium subscription won from the giveaway will be active for */
/** The number of Telegram Stars that were split between giveaway winners; for Telegram Star giveaways only */
prize_star_count?: number;
/** The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only */
premium_subscription_month_count?: number;
/** Number of undistributed prizes */
unclaimed_prize_count?: number;
Expand All @@ -1243,6 +1250,8 @@ export interface GiveawayCompleted {
unclaimed_prize_count?: number;
/** Message with the giveaway that was completed, if it wasn't deleted */
giveaway_message?: Message;
/** True, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway. */
is_star_giveaway?: true;
}

/** Describes the options used for link preview generation. */
Expand Down
4 changes: 3 additions & 1 deletion methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,10 +650,12 @@ export type ApiMethods<F> = {
business_connection_id?: string;
/** Unique identifier for the target chat or username of the target channel (in the format @channelusername). If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance. */
chat_id: number | string;
/** The number of Telegram Stars that must be paid to buy access to the media */
/** The number of Telegram Stars that must be paid to buy access to the media; 1-2500 */
star_count: number;
/** An array describing the media to be sent; up to 10 items */
media: InputPaidMedia<F>[];
/** Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes. */
payload?: string;
/** Media caption, 0-1024 characters after entities parsing */
caption?: string;
/** Mode for parsing entities in the media caption. See formatting options for more details. */
Expand Down
10 changes: 10 additions & 0 deletions payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ export interface TransactionPartnerUser {
invoice_payload?: string;
/** Information about the paid media bought by the user */
paid_media?: PaidMedia[];
/** Bot-specified paid media payload */
paid_media_payload?: string;
}

/** Describes a withdrawal transaction with Fragment. */
Expand Down Expand Up @@ -218,3 +220,11 @@ export interface StarTransactions {
/** The list of transactions */
transactions: StarTransaction[];
}

/** This object contains information about a paid media purchase. */
export interface PaidMediaPurchased {
/** User who purchased the media */
from: User;
/** Bot-specified paid media payload */
paid_media_payload: string;
}
8 changes: 7 additions & 1 deletion update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import type {
Poll,
PollAnswer,
} from "./message.ts";
import type { PreCheckoutQuery, ShippingQuery } from "./payment.ts";
import type {
PaidMediaPurchased,
PreCheckoutQuery,
ShippingQuery,
} from "./payment.ts";

/** Internal namespace used to make some message types more accurate */
export declare namespace Update {
Expand Down Expand Up @@ -90,4 +94,6 @@ export interface Update {
chat_boost?: ChatBoostUpdated;
/** A boost was removed from a chat. The bot must be an administrator in the chat to receive these updates. */
removed_chat_boost?: ChatBoostRemoved;
/** A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat */
purchased_paid_media?: PaidMediaPurchased;
}

0 comments on commit 23c208c

Please sign in to comment.