Skip to content

Commit 7f358ea

Browse files
authored
merge: #10 from telegraf/feat/api-9.0
2 parents 5a6ec01 + 9a4098d commit 7f358ea

File tree

7 files changed

+731
-82
lines changed

7 files changed

+731
-82
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
# Types for the Telegram Bot API [![Deno shield](https://img.shields.io/static/v1?label=Built%20for&message=Deno&style=flat-square&logo=deno&labelColor=000&color=fff)](https://deno.land/x/telegraf_types)
1+
# Types for the Telegram Bot API
22

3-
[![Bot API Version](https://img.shields.io/badge/Bot%20API-v8.3-f36caf.svg?style=flat-square&logo=Telegram&labelColor=white&color=blue)](https://core.telegram.org/bots/api) [![NPM version](https://img.shields.io/npm/v/@telegraf/types?style=flat-square&logo=npm&labelColor=fff&color=c53635)](https://npmjs.com/package/@telegraf/types)
3+
[![Bot API Version](https://img.shields.io/badge/Bot%20API-v9.0-f36caf.svg?style=flat-square&logo=Telegram&labelColor=white&color=blue)](https://core.telegram.org/bots/api) [![NPM version](https://img.shields.io/npm/v/@telegraf/types?style=flat-square&logo=npm&labelColor=fff&color=c53635)](https://npmjs.com/package/@telegraf/types)
44

5-
This project is a fork of [@KnorpelSenf/typegram](https://github.com/KnorpelSenf/typegram), specialised for Telegraf. Typegram is legacy, and now backported from [@grammyjs/types](https://github.com/grammyjs/types).
6-
7-
This fork keeps Telegram Bot API types updated for Telegraf. This project provides TypeScript types for the entire [Telegram Bot API](https://core.telegram.org/bots/api).
5+
This project keeps Telegram Bot API types updated for Telegraf. This project provides TypeScript types for the entire [Telegram Bot API](https://core.telegram.org/bots/api).
86

97
It contains zero bytes of executable code.
108

@@ -110,4 +108,4 @@ This project is written for Deno and built for Node. Running `npm prepare` runs
110108

111109
## Where do the types come from
112110

113-
They're handwritten. Typegram was started by [@KnorpelSenf](https://github.com/KnorpelSenf), who eventually used it as a starting point for [the grammY types package](https://github.com/grammyjs/types). `@telegraf/types` is based on both packages, and regularly syncs with them and the Bot API.
111+
They're handwritten. [Typegram](https://github.com/KnorpelSenf/typegram) was started by [@KnorpelSenf](https://github.com/KnorpelSenf), who eventually used it as a starting point for grammY's [types](https://github.com/grammyjs/types) package. `@telegraf/types` started as a fork of Typegram, specialised for Telegraf. It is now independently maintained and updated from the Bot API directly.

deno.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"tasks": {
3-
"check": "deno cache --check=all mod.ts",
3+
"check": "deno cache --check=all index.ts",
44
"dev": "deno fmt && deno lint && deno task check",
55
"backport": "deno run --no-prompt --allow-import=cdn.skypack.dev,deno.land --allow-read=. --allow-write=. https://deno.land/x/[email protected]/src/cli.ts tsconfig.json",
66
"clean": "git clean -fX '*.d.ts'"

manage.ts

Lines changed: 290 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import type { Location, Message, PhotoSize, Sticker } from "./message.ts";
1+
import type {
2+
Location,
3+
Message,
4+
MessageEntity,
5+
PhotoSize,
6+
Sticker,
7+
} from "./message.ts";
28

39
/** Describes the current status of a webhook. */
410
export interface WebhookInfo {
@@ -160,6 +166,8 @@ declare namespace ChatFullInfo {
160166
has_restricted_voice_and_video_messages?: true;
161167
/** The most recent pinned message (by sending date) */
162168
pinned_message?: Message;
169+
/** Information about types of gifts that are accepted by the chat or by the corresponding user for private chats */
170+
accepted_gift_types?: AcceptedGiftTypes[];
163171
/** The time after which all messages sent to the chat will be automatically deleted; in seconds */
164172
message_auto_delete_time?: number;
165173
/** True, if messages from the chat can't be forwarded to other chats */
@@ -195,6 +203,8 @@ declare namespace ChatFullInfo {
195203
pinned_message?: Message;
196204
/** Default chat member permissions, for groups and supergroups */
197205
permissions?: ChatPermissions;
206+
/** Information about types of gifts that are accepted by the chat or by the corresponding user for private chats */
207+
accepted_gift_types?: AcceptedGiftTypes[];
198208
/** The time after which all messages sent to the chat will be automatically deleted; in seconds */
199209
message_auto_delete_time?: number;
200210
/** True, if non-administrators can only get the list of bots and administrators in the chat */
@@ -236,6 +246,8 @@ declare namespace ChatFullInfo {
236246
pinned_message?: Message;
237247
/** Default chat member permissions, for groups and supergroups */
238248
permissions?: ChatPermissions;
249+
/** Information about types of gifts that are accepted by the chat or by the corresponding user for private chats */
250+
accepted_gift_types?: AcceptedGiftTypes[];
239251
/** True, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats. */
240252
can_send_paid_media?: true;
241253
/** For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user; in seconds */
@@ -285,6 +297,10 @@ declare namespace ChatFullInfo {
285297
description?: string;
286298
/** Primary invite link, for groups, supergroups and channel chats */
287299
invite_link?: string;
300+
/** The most recent pinned message (by sending date) */
301+
pinned_message?: Message;
302+
/** Information about types of gifts that are accepted by the chat or by the corresponding user for private chats */
303+
accepted_gift_types?: AcceptedGiftTypes[];
288304
/** True, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats. */
289305
can_send_paid_media?: true;
290306
/** The time after which all messages sent to the chat will be automatically deleted; in seconds */
@@ -621,6 +637,102 @@ export interface BusinessOpeningHours {
621637
opening_hours: BusinessOpeningHoursInterval[];
622638
}
623639

640+
/** Describes the position of a clickable area within a story. */
641+
export interface StoryAreaPosition {
642+
/** The abscissa of the area's center, as a percentage of the media width */
643+
x_percentage: number;
644+
/** The ordinate of the area's center, as a percentage of the media height */
645+
y_percentage: number;
646+
/** The width of the area's rectangle, as a percentage of the media width */
647+
width_percentage: number;
648+
/** The height of the area's rectangle, as a percentage of the media height */
649+
height_percentage: number;
650+
/** The clockwise rotation angle of the rectangle, in degrees; 0-360 */
651+
rotation_angle: number;
652+
/** The radius of the rectangle corner rounding, as a percentage of the media width */
653+
corner_radius_percentage: number;
654+
}
655+
656+
/** Describes the physical address of a location. */
657+
export interface LocationAddress {
658+
/** The two-letter ISO 3166-1 alpha-2 country code of the country where the location is located */
659+
country_code: string;
660+
/** State of the location */
661+
state?: string;
662+
/** City of the location */
663+
city?: string;
664+
/** Street address of the location */
665+
street?: string;
666+
}
667+
668+
/** Describes the type of a clickable area on a story. Currently, it can be one of */
669+
export type StoryAreaType =
670+
| StoryAreaTypeLocation
671+
| StoryAreaTypeSuggestedReaction
672+
| StoryAreaTypeLink
673+
| StoryAreaTypeWeather
674+
| StoryAreaTypeUniqueGift;
675+
676+
/** Describes a story area pointing to a location. Currently, a story can have up to 10 location areas. */
677+
export interface StoryAreaTypeLocation {
678+
/** Type of the area, always “location” */
679+
type: "location";
680+
/** Location latitude in degrees */
681+
latitude: number;
682+
/** Location longitude in degrees */
683+
longitude: number;
684+
/** Address of the location */
685+
address?: LocationAddress;
686+
}
687+
688+
/** Describes a story area pointing to a suggested reaction. Currently, a story can have up to 5 suggested reaction areas. */
689+
export interface StoryAreaTypeSuggestedReaction {
690+
/** Type of the area, always “suggested_reaction” */
691+
type: "suggested_reaction";
692+
/** Type of the reaction */
693+
reaction_type: ReactionType;
694+
/** Pass True if the reaction area has a dark background */
695+
is_dark?: boolean;
696+
/** Pass True if reaction area corner is flipped */
697+
is_flipped?: boolean;
698+
}
699+
700+
/** Describes a story area pointing to an HTTP or tg:// link. Currently, a story can have up to 3 link areas. */
701+
export interface StoryAreaTypeLink {
702+
/** Type of the area, always “link” */
703+
type: "link";
704+
/** HTTP or tg:// URL to be opened when the area is clicked */
705+
url: string;
706+
}
707+
708+
/** Describes a story area containing weather information. Currently, a story can have up to 3 weather areas. */
709+
export interface StoryAreaTypeWeather {
710+
/** Type of the area, always “weather” */
711+
type: "weather";
712+
/** Temperature, in degree Celsius */
713+
temperature: number;
714+
/** Emoji representing the weather */
715+
emoji: string;
716+
/** A color of the area background in the ARGB format */
717+
background_color: number;
718+
}
719+
720+
/** Describes a story area pointing to a unique gift. Currently, a story can have at most 1 unique gift area. */
721+
export interface StoryAreaTypeUniqueGift {
722+
/** Type of the area, always “unique_gift” */
723+
type: "unique_gift";
724+
/** Unique name of the gift */
725+
name: string;
726+
}
727+
728+
/** Describes a clickable area on a story media. */
729+
export interface StoryArea {
730+
/** Position of the area */
731+
position: StoryAreaPosition;
732+
/** Type of the area */
733+
type: StoryAreaType;
734+
}
735+
624736
/** Represents a location to which a chat is connected. */
625737
export interface ChatLocation {
626738
/** The location to which the supergroup is connected. Can't be a live location. */
@@ -674,6 +786,38 @@ export interface ReactionCount {
674786
total_count: number;
675787
}
676788

789+
/** Represents the rights of a business bot. */
790+
export interface BusinessBotRights {
791+
/** True, if the bot can send and edit messages in the private chats that had incoming messages in the last 24 hours */
792+
can_reply?: true;
793+
/** True, if the bot can mark incoming private messages as read */
794+
can_read_messages?: true;
795+
/** True, if the bot can delete messages sent by the bot */
796+
can_delete_outgoing_messages?: true;
797+
/** True, if the bot can delete all private messages in managed chats */
798+
can_delete_all_messages?: true;
799+
/** True, if the bot can edit the first and last name of the business account */
800+
can_edit_name?: true;
801+
/** True, if the bot can edit the bio of the business account */
802+
can_edit_bio?: true;
803+
/** True, if the bot can edit the profile photo of the business account */
804+
can_edit_profile_photo?: true;
805+
/** True, if the bot can edit the username of the business account */
806+
can_edit_username?: true;
807+
/** True, if the bot can change the privacy settings pertaining to gifts for the business account */
808+
can_change_gift_settings?: true;
809+
/** True, if the bot can view gifts and the amount of Telegram Stars owned by the business account */
810+
can_view_gifts_and_stars?: true;
811+
/** True, if the bot can convert regular gifts owned by the business account to Telegram Stars */
812+
can_convert_gifts_to_stars?: true;
813+
/** True, if the bot can transfer and upgrade gifts owned by the business account */
814+
can_transfer_and_upgrade_gifts?: true;
815+
/** True, if the bot can transfer Telegram Stars received by the business account to its own account, or use them to upgrade and transfer gifts */
816+
can_transfer_stars?: true;
817+
/** True, if the bot can post, edit and delete stories on behalf of the business account */
818+
can_manage_stories?: true;
819+
}
820+
677821
/** Describes the connection of the bot with a business account. */
678822
export interface BusinessConnection {
679823
/** Unique identifier of the business connection */
@@ -684,8 +828,8 @@ export interface BusinessConnection {
684828
user_chat_id: number;
685829
/** Date the connection was established in Unix time */
686830
date: number;
687-
/** True, if the bot can act on behalf of the business account in chats that were active in the last 24 hours */
688-
can_reply: boolean;
831+
/** Rights of the business bot */
832+
rights?: BusinessBotRights;
689833
/** True, if the connection is active */
690834
is_enabled: boolean;
691835
}
@@ -892,3 +1036,146 @@ export interface Gifts {
8921036
/** The list of gifts */
8931037
gifts: Gift[];
8941038
}
1039+
1040+
/** This object describes the model of a unique gift. */
1041+
export interface UniqueGiftModel {
1042+
/** Name of the model */
1043+
name: string;
1044+
/** The sticker that represents the unique gift */
1045+
sticker: Sticker;
1046+
/** The number of unique gifts that receive this model for every 1000 gifts upgraded */
1047+
rarity_per_mille: number;
1048+
}
1049+
1050+
/** This object describes the symbol shown on the pattern of a unique gift. */
1051+
export interface UniqueGiftSymbol {
1052+
/** Name of the symbol */
1053+
name: string;
1054+
/** The sticker that represents the unique gift */
1055+
sticker: Sticker;
1056+
/** The number of unique gifts that receive this model for every 1000 gifts upgraded */
1057+
rarity_per_mille: number;
1058+
}
1059+
1060+
/** This object describes the colors of the backdrop of a unique gift. */
1061+
export interface UniqueGiftBackdropColors {
1062+
/** The color in the center of the backdrop in RGB format */
1063+
center_color: number;
1064+
/** The color on the edges of the backdrop in RGB format */
1065+
edge_color: number;
1066+
/** The color to be applied to the symbol in RGB format */
1067+
symbol_color: number;
1068+
/** The color for the text on the backdrop in RGB format */
1069+
text_color: number;
1070+
}
1071+
1072+
/** This object describes the backdrop of a unique gift. */
1073+
export interface UniqueGiftBackdrop {
1074+
/** Name of the backdrop */
1075+
name: string;
1076+
/** Colors of the backdrop */
1077+
colors: UniqueGiftBackdropColors;
1078+
/** The number of unique gifts that receive this backdrop for every 1000 gifts upgraded */
1079+
rarity_per_mille: number;
1080+
}
1081+
1082+
/** This object describes a unique gift that was upgraded from a regular gift. */
1083+
export interface UniqueGift {
1084+
/** Human-readable name of the regular gift from which this unique gift was upgraded */
1085+
base_name: string;
1086+
/** Unique name of the gift. This name can be used in https://t.me/nft/... links and story areas */
1087+
name: string;
1088+
/** Unique number of the upgraded gift among gifts upgraded from the same regular gift */
1089+
number: number;
1090+
/** Model of the gift */
1091+
model: UniqueGiftModel;
1092+
/** Symbol of the gift */
1093+
symbol: UniqueGiftSymbol;
1094+
/** Backdrop of the gift */
1095+
backdrop: UniqueGiftBackdrop;
1096+
}
1097+
1098+
/** This object describes a gift received and owned by a user or a chat. Currently, it can be one of
1099+
* - OwnedGiftRegular
1100+
* - OwnedGiftUnique. */
1101+
export type OwnedGift = OwnedGiftRegular | OwnedGiftUnique;
1102+
1103+
/** Describes a regular gift owned by a user or a chat. */
1104+
export interface OwnedGiftRegular {
1105+
/** Type of the gift, always “regular” */
1106+
type: "regular";
1107+
/** Information about the regular gift */
1108+
gift: Gift;
1109+
/** Unique identifier of the gift for the bot; for gifts received on behalf of business accounts only */
1110+
owned_gift_id?: string;
1111+
/** Sender of the gift if it is a known user */
1112+
sender_user?: User;
1113+
/** Date the gift was sent in Unix time */
1114+
send_date: number;
1115+
/** Text of the message that was added to the gift */
1116+
text?: string;
1117+
/** Special entities that appear in the text */
1118+
entities?: MessageEntity[];
1119+
/** True, if the sender and gift text are shown only to the gift receiver; otherwise, everyone will be able to see them */
1120+
is_private?: boolean;
1121+
/** True, if the gift is displayed on the account's profile page; for gifts received on behalf of business accounts only */
1122+
is_saved?: boolean;
1123+
/** True, if the gift can be upgraded to a unique gift; for gifts received on behalf of business accounts only */
1124+
can_be_upgraded?: boolean;
1125+
/** True, if the gift was refunded and isn't available anymore */
1126+
was_refunded?: boolean;
1127+
/** Number of Telegram Stars that can be claimed by the receiver instead of the gift; omitted if the gift cannot be converted to Telegram Stars */
1128+
convert_star_count?: number;
1129+
/** Number of Telegram Stars that were paid by the sender for the ability to upgrade the gift */
1130+
prepaid_upgrade_star_count?: number;
1131+
}
1132+
1133+
/** Describes a unique gift received and owned by a user or a chat. */
1134+
export interface OwnedGiftUnique {
1135+
/** Type of the gift, always “unique” */
1136+
type: "unique";
1137+
/** Information about the unique gift */
1138+
gift: UniqueGift;
1139+
/** Unique identifier of the received gift for the bot; for gifts received on behalf of business accounts only */
1140+
owned_gift_id?: string;
1141+
/** Sender of the gift if it is a known user */
1142+
sender_user?: User;
1143+
/** Date the gift was sent in Unix time */
1144+
send_date: number;
1145+
/** True, if the gift is displayed on the account's profile page; for gifts received on behalf of business accounts only */
1146+
is_saved?: boolean;
1147+
/** True, if the gift can be transferred to another owner; for gifts received on behalf of business accounts only */
1148+
can_be_transferred?: boolean;
1149+
/** Number of Telegram Stars that must be paid to transfer the gift; omitted if the bot cannot transfer the gift */
1150+
transfer_star_count?: number;
1151+
}
1152+
1153+
/** Contains the list of gifts received and owned by a user or a chat. */
1154+
export interface OwnedGifts {
1155+
/** The total number of gifts owned by the user or the chat */
1156+
total_count: number;
1157+
/** The list of gifts */
1158+
gifts: OwnedGift[];
1159+
/** Offset for the next request. If empty, then there are no more results */
1160+
next_offset?: string;
1161+
}
1162+
1163+
/** This object describes the types of gifts that can be gifted to a user or a chat. */
1164+
export interface AcceptedGiftTypes {
1165+
/** True, if unlimited regular gifts are accepted */
1166+
unlimited_gifts: boolean;
1167+
/** True, if limited regular gifts are accepted */
1168+
limited_gifts: boolean;
1169+
/** True, if unique gifts or gifts that can be upgraded to unique for free are accepted */
1170+
unique_gifts: boolean;
1171+
/** True, if a Telegram Premium subscription is accepted */
1172+
premium_subscription: boolean;
1173+
}
1174+
1175+
/** Describes an amount of Telegram Stars. */
1176+
export interface StarAmount {
1177+
/** Integer amount of Telegram Stars, rounded to 0; can be negative */
1178+
amount: number;
1179+
/** Optional. The number of 1/1000000000 shares of Telegram Stars; from -999999999 to 999999999; can be negative if and only if amount is non-positive */
1180+
nanostar_amount?: number;
1181+
}

0 commit comments

Comments
 (0)