@telegram.ts/types 1.0.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Represents the response from the API, which can be either a success or an error.
3
+ * If 'ok' is true, the request was successful, and the result of the query can be found in the 'result' field.
4
+ * In case of an unsuccessful request, 'ok' is false, and the error is explained in the 'description' field.
5
+ * An optional 'error_code' field of type number may be returned, but its contents are subject to change in the future.
6
+ * Some errors may also have an additional 'parameters' field of type ResponseParameters,
7
+ * which can provide information to automatically handle the error.
8
+ */
9
+ export type ApiResponse < T > = ApiError | ApiSuccess < T >;
10
+
11
+ /**
12
+ * Represents an API error response.
13
+ */
14
+ export interface ApiError {
15
+ ok: false;
16
+ error_code: number;
17
+ description: string;
18
+ parameters?: ResponseParameters;
19
+ }
20
+
21
+ /**
22
+ * Represents a successful API response.
23
+ * 'ok' is true, and the result of the query can be found in the 'result' field.
24
+ */
25
+ export interface ApiSuccess < T > {
26
+ ok: true;
27
+ result: T;
28
+ }
29
+
30
+ /**
31
+ * Describes additional parameters provided in an API error response.
32
+ */
33
+ export interface ResponseParameters {
34
+ /**
35
+ * The group has been migrated to a supergroup with the specified identifier.
36
+ * This number may have more than 32 significant bits, and some programming languages may have difficulty/silent defects in interpreting it.
37
+ * However, it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type is safe for storing this identifier.
38
+ */
39
+ migrate_to_chat_id?: number;
40
+ /**
41
+ * In case of exceeding flood control, the number of seconds left to wait before the request can be repeated.
42
+ */
43
+ retry_after?: number;
44
+ }
45
+
46
+ /**
47
+ * All methods in the Bot API are case-insensitive.
48
+ * All queries must be made using UTF-8.
49
+ */
@@ -0,0 +1,141 @@
1
+ import type {
2
+ ChosenInlineResult,
3
+ InlineQuery
4
+ } from "./inlineTypes.js";
5
+ import type {
6
+ Chat,
7
+ ChatJoinRequest,
8
+ ChatMemberUpdated,
9
+ User
10
+ } from "./manageTypes.js";
11
+ import type {
12
+ CallbackQuery
13
+ } from "./markupTypes.js";
14
+ import type {
15
+ Message,
16
+ Poll,
17
+ PollAnswer
18
+ } from "./messageTypes.js";
19
+ import type {
20
+ PreCheckoutQuery,
21
+ ShippingQuery
22
+ } from "./invoiceTypes.js";
23
+
24
+ /**
25
+ * Namespace used internally to define more accurate message update types.
26
+ */
27
+ export declare namespace Update {
28
+ /**
29
+ * Internal type holding properties that message updates in channels share.
30
+ */
31
+ interface Channel {
32
+ chat: Chat.ChannelChat;
33
+ }
34
+
35
+ /**
36
+ * Internal type holding properties that message updates outside of channels share.
37
+ */
38
+ interface NonChannel {
39
+ chat: Exclude < Chat,
40
+ Chat.ChannelChat >;
41
+ from: User;
42
+ }
43
+
44
+ /**
45
+ * Internal type holding properties that updates about edited messages share.
46
+ */
47
+ interface Edited {
48
+ /**
49
+ * Date the message was last edited in Unix time.
50
+ */
51
+ edit_date: number;
52
+ }
53
+ }
54
+
55
+ /**
56
+ * This object represents an incoming update.
57
+ * At most one of the optional parameters can be present in any given update.
58
+ */
59
+ export interface Update {
60
+ /**
61
+ * The update's unique identifier. Update identifiers start from a certain positive number and increase sequentially.
62
+ * This ID becomes especially handy if you're using webhooks, as it allows you to ignore repeated updates or restore the correct update sequence if they get out of order.
63
+ * If there are no new updates for at least a week, the identifier of the next update will be chosen randomly instead of sequentially.
64
+ */
65
+ update_id: number;
66
+
67
+ /**
68
+ * New incoming message of any kind - text, photo, sticker, etc.
69
+ */
70
+ message?: Message & Update.NonChannel;
71
+
72
+ /**
73
+ * New version of a message known to the bot that has been edited.
74
+ */
75
+ edited_message?: Message & Update.Edited & Update.NonChannel;
76
+
77
+ /**
78
+ * New incoming channel post of any kind - text, photo, sticker, etc.
79
+ */
80
+ channel_post?: Message & Update.Channel;
81
+
82
+ /**
83
+ * New version of a channel post known to the bot that has been edited.
84
+ */
85
+ edited_channel_post?: Message & Update.Edited & Update.Channel;
86
+
87
+ /**
88
+ * New incoming inline query.
89
+ */
90
+ inline_query?: InlineQuery;
91
+
92
+ /**
93
+ * The result of an inline query that was chosen by a user and sent to their chat partner.
94
+ * Please refer to our documentation on collecting feedback for details on how to enable these updates for your bot.
95
+ */
96
+ chosen_inline_result?: ChosenInlineResult;
97
+
98
+ /**
99
+ * New incoming callback query.
100
+ */
101
+ callback_query?: CallbackQuery;
102
+
103
+ /**
104
+ * New incoming shipping query. Only for invoices with flexible price.
105
+ */
106
+ shipping_query?: ShippingQuery;
107
+
108
+ /**
109
+ * New incoming pre-checkout query. Contains full information about checkout.
110
+ */
111
+ pre_checkout_query?: PreCheckoutQuery;
112
+
113
+ /**
114
+ * New poll state. Bots receive updates only about stopped polls and polls sent by the bot.
115
+ */
116
+ poll?: Poll;
117
+
118
+ /**
119
+ * A user changed their answer in a non-anonymous poll.
120
+ * Bots receive new votes only in polls that were sent by the bot itself.
121
+ */
122
+ poll_answer?: PollAnswer;
123
+
124
+ /**
125
+ * The bot's chat member status was updated in a chat.
126
+ * For private chats, this update is received only when the bot is blocked or unblocked by the user.
127
+ */
128
+ my_chat_member?: ChatMemberUpdated;
129
+
130
+ /**
131
+ * A chat member's status was updated in a chat.
132
+ * The bot must be an administrator in the chat and must explicitly specify "chat_member" in the list of allowed_updates to receive these updates.
133
+ */
134
+ chat_member?: ChatMemberUpdated;
135
+
136
+ /**
137
+ * A request to join the chat has been sent.
138
+ * The bot must have the can_invite_users administrator right in the chat to receive these updates.
139
+ */
140
+ chat_join_request?: ChatJoinRequest;
141
+ }
package/src/api.d.ts DELETED
@@ -1,22 +0,0 @@
1
- export interface ApiError {
2
- ok: false;
3
- error_code: number;
4
- description: string;
5
- parameters?: ResponseParameters;
6
- }
7
- export interface ApiSuccess < T > {
8
- ok: true;
9
- result: T;
10
- }
11
- /** The response contains an object, which always has a Boolean field 'ok' and may have an optional String field 'description' with a human-readable description of the result. If 'ok' equals true, the request was successful and the result of the query can be found in the 'result' field. In case of an unsuccessful request, 'ok' equals false and the error is explained in the 'description'. An Integer 'error_code' field is also returned, but its contents are subject to change in the future. Some errors may also have an optional field 'parameters' of the type ResponseParameters, which can help to automatically handle the error.
12
-
13
- All methods in the Bot API are case-insensitive.
14
- All queries must be made using UTF-8. */
15
- export type ApiResponse < T > = ApiError | ApiSuccess < T >;
16
- /** Describes why a request was unsuccessful. */
17
- export interface ResponseParameters {
18
- /** The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier. */
19
- migrate_to_chat_id?: number;
20
- /** In case of exceeding flood control, the number of seconds left to wait before the request can be repeated */
21
- retry_after?: number;
22
- }