@xtsea/tgcore-ts 0.1.7 → 0.1.9

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.
@@ -1,86 +1,29 @@
1
- // src/builders/keyboard.ts
2
- var KeyboardBuilder = class _KeyboardBuilder {
3
- constructor() {
4
- this.keyboard = [[]];
5
- this._maxPerRow = null;
6
- }
7
- static inline() {
8
- return new _KeyboardBuilder();
9
- }
10
- maxPerRow(n) {
11
- if (!Number.isInteger(n) || n <= 0) throw new Error("maxPerRow must be a positive integer");
12
- this._maxPerRow = n;
13
- return this;
14
- }
15
- currentRow() {
16
- return this.keyboard[this.keyboard.length - 1];
17
- }
18
- row() {
19
- if (this.currentRow().length === 0) return this;
20
- this.keyboard.push([]);
21
- return this;
22
- }
23
- push(btn) {
24
- var _a;
25
- if (!((_a = btn.text) == null ? void 0 : _a.trim())) throw new Error("Button text is required");
26
- if (btn.text.length > 64) throw new Error("Button text too long (max 64 chars)");
27
- const actionKeys = [
28
- "url",
29
- "callback_data",
30
- "web_app",
31
- "login_url",
32
- "switch_inline_query",
33
- "switch_inline_query_current_chat",
34
- "switch_inline_query_chosen_chat",
35
- "copy_text"
36
- ];
37
- const used = actionKeys.filter((k) => btn[k] != null);
38
- if (used.length !== 1) {
39
- throw new Error(`InlineKeyboardButton must have exactly 1 action field, got: ${used.join(", ") || "none"}`);
40
- }
41
- if (btn.callback_data && btn.callback_data.length > 64) {
42
- throw new Error("callback_data too long (max 64 chars)");
43
- }
44
- if (this._maxPerRow && this.currentRow().length >= this._maxPerRow) {
45
- this.row();
46
- }
47
- this.currentRow().push(btn);
48
- return this;
49
- }
50
- url(text, url) {
51
- return this.push({ text, url });
52
- }
53
- style(text, style, url) {
54
- return this.push({ text, style, url });
55
- }
56
- callback(text, data) {
57
- return this.push({ text, callback_data: data });
58
- }
59
- webApp(text, url) {
60
- return this.push({ text, web_app: { url } });
61
- }
62
- loginUrl(text, url, opts) {
63
- return this.push({ text, login_url: { url, ...opts != null ? opts : {} } });
64
- }
65
- switchInline(text, query) {
66
- return this.push({ text, switch_inline_query: query });
67
- }
68
- switchInlineCurrentChat(text, query) {
69
- return this.push({ text, switch_inline_query_current_chat: query });
70
- }
71
- switchInlineChosenChat(text, opts) {
72
- if (!opts) throw new Error("switch_inline_query_chosen_chat options required");
73
- return this.push({ text, switch_inline_query_chosen_chat: opts });
74
- }
75
- copyText(text, copy) {
76
- return this.push({ text, copy_text: { text: copy } });
77
- }
78
- build() {
79
- const cleaned = this.keyboard.filter((r) => r.length > 0);
80
- if (cleaned.length === 0) throw new Error("Keyboard is empty");
81
- return { inline_keyboard: cleaned };
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
82
15
  }
16
+ return to;
83
17
  };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Client: () => Client,
24
+ KeyboardBuilder: () => KeyboardBuilder
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
84
27
 
85
28
  // src/http.ts
86
29
  var Http = class {
@@ -97,7 +40,7 @@ var Http = class {
97
40
  "content-type": "application/json",
98
41
  "x-api-key": this.opts.api_key
99
42
  },
100
- body: JSON.stringify(body != null ? body : {}),
43
+ body: JSON.stringify(body ?? {}),
101
44
  signal: controller.signal
102
45
  });
103
46
  const json = await res.json().catch(() => null);
@@ -142,7 +85,7 @@ var BaseCallBuilder = class {
142
85
  }
143
86
  async throw() {
144
87
  const res = await this.execute();
145
- if (!(res == null ? void 0 : res.ok)) {
88
+ if (!res?.ok) {
146
89
  throw new Error(JSON.stringify(res));
147
90
  }
148
91
  return res;
@@ -193,20 +136,103 @@ var CallMethods = class {
193
136
  // src/client.ts
194
137
  var Client = class {
195
138
  constructor(opts) {
196
- var _a, _b;
197
- if (!(opts == null ? void 0 : opts.api_key)) {
139
+ if (!opts?.api_key) {
198
140
  throw new Error("tgcore-ts: api_key is required");
199
141
  }
200
142
  this.http = new Http({
201
143
  api_key: opts.api_key,
202
- base_url: (_a = opts.base_url) != null ? _a : "https://services-pro.ryzenths.dpdns.org",
203
- timeout_ms: (_b = opts.timeout_ms) != null ? _b : 3e4
144
+ base_url: opts.base_url ?? "https://services-pro.ryzenths.dpdns.org",
145
+ timeout_ms: opts.timeout_ms ?? 3e4
204
146
  });
205
147
  this.calls = new CallMethods(this.http);
206
148
  this.raw = new RawMethods(this.http);
207
149
  }
208
150
  };
209
- export {
151
+
152
+ // src/builders/keyboard.ts
153
+ var KeyboardBuilder = class _KeyboardBuilder {
154
+ constructor() {
155
+ this.keyboard = [[]];
156
+ this._maxPerRow = null;
157
+ }
158
+ static inline() {
159
+ return new _KeyboardBuilder();
160
+ }
161
+ maxPerRow(n) {
162
+ if (!Number.isInteger(n) || n <= 0) throw new Error("maxPerRow must be a positive integer");
163
+ this._maxPerRow = n;
164
+ return this;
165
+ }
166
+ currentRow() {
167
+ return this.keyboard[this.keyboard.length - 1];
168
+ }
169
+ row() {
170
+ if (this.currentRow().length === 0) return this;
171
+ this.keyboard.push([]);
172
+ return this;
173
+ }
174
+ push(btn) {
175
+ if (!btn.text?.trim()) throw new Error("Button text is required");
176
+ if (btn.text.length > 64) throw new Error("Button text too long (max 64 chars)");
177
+ const actionKeys = [
178
+ "url",
179
+ "callback_data",
180
+ "web_app",
181
+ "login_url",
182
+ "switch_inline_query",
183
+ "switch_inline_query_current_chat",
184
+ "switch_inline_query_chosen_chat",
185
+ "copy_text"
186
+ ];
187
+ const used = actionKeys.filter((k) => btn[k] != null);
188
+ if (used.length !== 1) {
189
+ throw new Error(`InlineKeyboardButton must have exactly 1 action field, got: ${used.join(", ") || "none"}`);
190
+ }
191
+ if (btn.callback_data && btn.callback_data.length > 64) {
192
+ throw new Error("callback_data too long (max 64 chars)");
193
+ }
194
+ if (this._maxPerRow && this.currentRow().length >= this._maxPerRow) {
195
+ this.row();
196
+ }
197
+ this.currentRow().push(btn);
198
+ return this;
199
+ }
200
+ url(text, url) {
201
+ return this.push({ text, url });
202
+ }
203
+ style(text, style, url) {
204
+ return this.push({ text, style, url });
205
+ }
206
+ callback(text, data) {
207
+ return this.push({ text, callback_data: data });
208
+ }
209
+ webApp(text, url) {
210
+ return this.push({ text, web_app: { url } });
211
+ }
212
+ loginUrl(text, url, opts) {
213
+ return this.push({ text, login_url: { url, ...opts ?? {} } });
214
+ }
215
+ switchInline(text, query) {
216
+ return this.push({ text, switch_inline_query: query });
217
+ }
218
+ switchInlineCurrentChat(text, query) {
219
+ return this.push({ text, switch_inline_query_current_chat: query });
220
+ }
221
+ switchInlineChosenChat(text, opts) {
222
+ if (!opts) throw new Error("switch_inline_query_chosen_chat options required");
223
+ return this.push({ text, switch_inline_query_chosen_chat: opts });
224
+ }
225
+ copyText(text, copy) {
226
+ return this.push({ text, copy_text: { text: copy } });
227
+ }
228
+ build() {
229
+ const cleaned = this.keyboard.filter((r) => r.length > 0);
230
+ if (cleaned.length === 0) throw new Error("Keyboard is empty");
231
+ return { inline_keyboard: cleaned };
232
+ }
233
+ };
234
+ // Annotate the CommonJS export names for ESM import in node:
235
+ 0 && (module.exports = {
210
236
  Client,
211
237
  KeyboardBuilder
212
- };
238
+ });
package/dist/index.d.ts CHANGED
@@ -1,53 +1,3 @@
1
- type InlineKeyboardButton = {
2
- text: string;
3
- url?: string;
4
- style?: string;
5
- callback_data?: string;
6
- web_app?: {
7
- url: string;
8
- };
9
- login_url?: {
10
- url: string;
11
- forward_text?: string;
12
- bot_username?: string;
13
- request_write_access?: boolean;
14
- };
15
- switch_inline_query?: string;
16
- switch_inline_query_current_chat?: string;
17
- switch_inline_query_chosen_chat?: {
18
- query?: string;
19
- allow_user_chats?: boolean;
20
- allow_bot_chats?: boolean;
21
- allow_group_chats?: boolean;
22
- allow_channel_chats?: boolean;
23
- };
24
- copy_text?: {
25
- text: string;
26
- };
27
- };
28
- type InlineKeyboardMarkup = {
29
- inline_keyboard: InlineKeyboardButton[][];
30
- };
31
- declare class KeyboardBuilder {
32
- private keyboard;
33
- private _maxPerRow;
34
- static inline(): KeyboardBuilder;
35
- maxPerRow(n: number): this;
36
- private currentRow;
37
- row(): this;
38
- private push;
39
- url(text: string, url: string): this;
40
- style(text: string, style: string, url: string): this;
41
- callback(text: string, data: string): this;
42
- webApp(text: string, url: string): this;
43
- loginUrl(text: string, url: string, opts?: Omit<NonNullable<InlineKeyboardButton["login_url"]>, "url">): this;
44
- switchInline(text: string, query: string): this;
45
- switchInlineCurrentChat(text: string, query: string): this;
46
- switchInlineChosenChat(text: string, opts: InlineKeyboardButton["switch_inline_query_chosen_chat"]): this;
47
- copyText(text: string, copy: string): this;
48
- build(): InlineKeyboardMarkup;
49
- }
50
-
51
1
  type HttpOptions = {
52
2
  api_key: string;
53
3
  base_url: string;
@@ -110,4 +60,54 @@ declare class Client {
110
60
  constructor(opts: ClientOptions);
111
61
  }
112
62
 
63
+ type InlineKeyboardButton = {
64
+ text: string;
65
+ url?: string;
66
+ style?: string;
67
+ callback_data?: string;
68
+ web_app?: {
69
+ url: string;
70
+ };
71
+ login_url?: {
72
+ url: string;
73
+ forward_text?: string;
74
+ bot_username?: string;
75
+ request_write_access?: boolean;
76
+ };
77
+ switch_inline_query?: string;
78
+ switch_inline_query_current_chat?: string;
79
+ switch_inline_query_chosen_chat?: {
80
+ query?: string;
81
+ allow_user_chats?: boolean;
82
+ allow_bot_chats?: boolean;
83
+ allow_group_chats?: boolean;
84
+ allow_channel_chats?: boolean;
85
+ };
86
+ copy_text?: {
87
+ text: string;
88
+ };
89
+ };
90
+ type InlineKeyboardMarkup = {
91
+ inline_keyboard: InlineKeyboardButton[][];
92
+ };
93
+ declare class KeyboardBuilder {
94
+ private keyboard;
95
+ private _maxPerRow;
96
+ static inline(): KeyboardBuilder;
97
+ maxPerRow(n: number): this;
98
+ private currentRow;
99
+ row(): this;
100
+ private push;
101
+ url(text: string, url: string): this;
102
+ style(text: string, style: string, url: string): this;
103
+ callback(text: string, data: string): this;
104
+ webApp(text: string, url: string): this;
105
+ loginUrl(text: string, url: string, opts?: Omit<NonNullable<InlineKeyboardButton["login_url"]>, "url">): this;
106
+ switchInline(text: string, query: string): this;
107
+ switchInlineCurrentChat(text: string, query: string): this;
108
+ switchInlineChosenChat(text: string, opts: InlineKeyboardButton["switch_inline_query_chosen_chat"]): this;
109
+ copyText(text: string, copy: string): this;
110
+ build(): InlineKeyboardMarkup;
111
+ }
112
+
113
113
  export { Client, type ClientOptions, type InlineKeyboardButton, type InlineKeyboardMarkup, KeyboardBuilder };
package/dist/index.js CHANGED
@@ -1,114 +1,3 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- Client: () => Client,
24
- KeyboardBuilder: () => KeyboardBuilder
25
- });
26
- module.exports = __toCommonJS(index_exports);
27
-
28
- // src/builders/keyboard.ts
29
- var KeyboardBuilder = class _KeyboardBuilder {
30
- constructor() {
31
- this.keyboard = [[]];
32
- this._maxPerRow = null;
33
- }
34
- static inline() {
35
- return new _KeyboardBuilder();
36
- }
37
- maxPerRow(n) {
38
- if (!Number.isInteger(n) || n <= 0) throw new Error("maxPerRow must be a positive integer");
39
- this._maxPerRow = n;
40
- return this;
41
- }
42
- currentRow() {
43
- return this.keyboard[this.keyboard.length - 1];
44
- }
45
- row() {
46
- if (this.currentRow().length === 0) return this;
47
- this.keyboard.push([]);
48
- return this;
49
- }
50
- push(btn) {
51
- var _a;
52
- if (!((_a = btn.text) == null ? void 0 : _a.trim())) throw new Error("Button text is required");
53
- if (btn.text.length > 64) throw new Error("Button text too long (max 64 chars)");
54
- const actionKeys = [
55
- "url",
56
- "callback_data",
57
- "web_app",
58
- "login_url",
59
- "switch_inline_query",
60
- "switch_inline_query_current_chat",
61
- "switch_inline_query_chosen_chat",
62
- "copy_text"
63
- ];
64
- const used = actionKeys.filter((k) => btn[k] != null);
65
- if (used.length !== 1) {
66
- throw new Error(`InlineKeyboardButton must have exactly 1 action field, got: ${used.join(", ") || "none"}`);
67
- }
68
- if (btn.callback_data && btn.callback_data.length > 64) {
69
- throw new Error("callback_data too long (max 64 chars)");
70
- }
71
- if (this._maxPerRow && this.currentRow().length >= this._maxPerRow) {
72
- this.row();
73
- }
74
- this.currentRow().push(btn);
75
- return this;
76
- }
77
- url(text, url) {
78
- return this.push({ text, url });
79
- }
80
- style(text, style, url) {
81
- return this.push({ text, style, url });
82
- }
83
- callback(text, data) {
84
- return this.push({ text, callback_data: data });
85
- }
86
- webApp(text, url) {
87
- return this.push({ text, web_app: { url } });
88
- }
89
- loginUrl(text, url, opts) {
90
- return this.push({ text, login_url: { url, ...opts != null ? opts : {} } });
91
- }
92
- switchInline(text, query) {
93
- return this.push({ text, switch_inline_query: query });
94
- }
95
- switchInlineCurrentChat(text, query) {
96
- return this.push({ text, switch_inline_query_current_chat: query });
97
- }
98
- switchInlineChosenChat(text, opts) {
99
- if (!opts) throw new Error("switch_inline_query_chosen_chat options required");
100
- return this.push({ text, switch_inline_query_chosen_chat: opts });
101
- }
102
- copyText(text, copy) {
103
- return this.push({ text, copy_text: { text: copy } });
104
- }
105
- build() {
106
- const cleaned = this.keyboard.filter((r) => r.length > 0);
107
- if (cleaned.length === 0) throw new Error("Keyboard is empty");
108
- return { inline_keyboard: cleaned };
109
- }
110
- };
111
-
112
1
  // src/http.ts
113
2
  var Http = class {
114
3
  constructor(opts) {
@@ -124,7 +13,7 @@ var Http = class {
124
13
  "content-type": "application/json",
125
14
  "x-api-key": this.opts.api_key
126
15
  },
127
- body: JSON.stringify(body != null ? body : {}),
16
+ body: JSON.stringify(body ?? {}),
128
17
  signal: controller.signal
129
18
  });
130
19
  const json = await res.json().catch(() => null);
@@ -169,7 +58,7 @@ var BaseCallBuilder = class {
169
58
  }
170
59
  async throw() {
171
60
  const res = await this.execute();
172
- if (!(res == null ? void 0 : res.ok)) {
61
+ if (!res?.ok) {
173
62
  throw new Error(JSON.stringify(res));
174
63
  }
175
64
  return res;
@@ -220,21 +109,102 @@ var CallMethods = class {
220
109
  // src/client.ts
221
110
  var Client = class {
222
111
  constructor(opts) {
223
- var _a, _b;
224
- if (!(opts == null ? void 0 : opts.api_key)) {
112
+ if (!opts?.api_key) {
225
113
  throw new Error("tgcore-ts: api_key is required");
226
114
  }
227
115
  this.http = new Http({
228
116
  api_key: opts.api_key,
229
- base_url: (_a = opts.base_url) != null ? _a : "https://services-pro.ryzenths.dpdns.org",
230
- timeout_ms: (_b = opts.timeout_ms) != null ? _b : 3e4
117
+ base_url: opts.base_url ?? "https://services-pro.ryzenths.dpdns.org",
118
+ timeout_ms: opts.timeout_ms ?? 3e4
231
119
  });
232
120
  this.calls = new CallMethods(this.http);
233
121
  this.raw = new RawMethods(this.http);
234
122
  }
235
123
  };
236
- // Annotate the CommonJS export names for ESM import in node:
237
- 0 && (module.exports = {
124
+
125
+ // src/builders/keyboard.ts
126
+ var KeyboardBuilder = class _KeyboardBuilder {
127
+ constructor() {
128
+ this.keyboard = [[]];
129
+ this._maxPerRow = null;
130
+ }
131
+ static inline() {
132
+ return new _KeyboardBuilder();
133
+ }
134
+ maxPerRow(n) {
135
+ if (!Number.isInteger(n) || n <= 0) throw new Error("maxPerRow must be a positive integer");
136
+ this._maxPerRow = n;
137
+ return this;
138
+ }
139
+ currentRow() {
140
+ return this.keyboard[this.keyboard.length - 1];
141
+ }
142
+ row() {
143
+ if (this.currentRow().length === 0) return this;
144
+ this.keyboard.push([]);
145
+ return this;
146
+ }
147
+ push(btn) {
148
+ if (!btn.text?.trim()) throw new Error("Button text is required");
149
+ if (btn.text.length > 64) throw new Error("Button text too long (max 64 chars)");
150
+ const actionKeys = [
151
+ "url",
152
+ "callback_data",
153
+ "web_app",
154
+ "login_url",
155
+ "switch_inline_query",
156
+ "switch_inline_query_current_chat",
157
+ "switch_inline_query_chosen_chat",
158
+ "copy_text"
159
+ ];
160
+ const used = actionKeys.filter((k) => btn[k] != null);
161
+ if (used.length !== 1) {
162
+ throw new Error(`InlineKeyboardButton must have exactly 1 action field, got: ${used.join(", ") || "none"}`);
163
+ }
164
+ if (btn.callback_data && btn.callback_data.length > 64) {
165
+ throw new Error("callback_data too long (max 64 chars)");
166
+ }
167
+ if (this._maxPerRow && this.currentRow().length >= this._maxPerRow) {
168
+ this.row();
169
+ }
170
+ this.currentRow().push(btn);
171
+ return this;
172
+ }
173
+ url(text, url) {
174
+ return this.push({ text, url });
175
+ }
176
+ style(text, style, url) {
177
+ return this.push({ text, style, url });
178
+ }
179
+ callback(text, data) {
180
+ return this.push({ text, callback_data: data });
181
+ }
182
+ webApp(text, url) {
183
+ return this.push({ text, web_app: { url } });
184
+ }
185
+ loginUrl(text, url, opts) {
186
+ return this.push({ text, login_url: { url, ...opts ?? {} } });
187
+ }
188
+ switchInline(text, query) {
189
+ return this.push({ text, switch_inline_query: query });
190
+ }
191
+ switchInlineCurrentChat(text, query) {
192
+ return this.push({ text, switch_inline_query_current_chat: query });
193
+ }
194
+ switchInlineChosenChat(text, opts) {
195
+ if (!opts) throw new Error("switch_inline_query_chosen_chat options required");
196
+ return this.push({ text, switch_inline_query_chosen_chat: opts });
197
+ }
198
+ copyText(text, copy) {
199
+ return this.push({ text, copy_text: { text: copy } });
200
+ }
201
+ build() {
202
+ const cleaned = this.keyboard.filter((r) => r.length > 0);
203
+ if (cleaned.length === 0) throw new Error("Keyboard is empty");
204
+ return { inline_keyboard: cleaned };
205
+ }
206
+ };
207
+ export {
238
208
  Client,
239
209
  KeyboardBuilder
240
- });
210
+ };
package/package.json CHANGED
@@ -1,10 +1,19 @@
1
1
  {
2
2
  "name": "@xtsea/tgcore-ts",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "tgcore TypeScript SDK • Telegram Engine Client",
5
- "main": "dist/index.js",
6
- "module": "dist/index.js",
7
- "types": "dist/index.d.ts",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ },
15
+ "./package.json": "./package.json"
16
+ },
8
17
  "license": "Apache-2.0",
9
18
  "author": "XTSEA",
10
19
  "repository": {
@@ -22,7 +31,7 @@
22
31
  "dist"
23
32
  ],
24
33
  "scripts": {
25
- "build": "tsup src/index.ts --format esm,cjs --dts",
34
+ "build": "tsup src/index.ts --format esm,cjs --dts --target es2020 --clean",
26
35
  "dev": "tsup src/index.ts --watch",
27
36
  "clean": "rm -rf dist"
28
37
  },
@@ -1,53 +1,3 @@
1
- type InlineKeyboardButton = {
2
- text: string;
3
- url?: string;
4
- style?: string;
5
- callback_data?: string;
6
- web_app?: {
7
- url: string;
8
- };
9
- login_url?: {
10
- url: string;
11
- forward_text?: string;
12
- bot_username?: string;
13
- request_write_access?: boolean;
14
- };
15
- switch_inline_query?: string;
16
- switch_inline_query_current_chat?: string;
17
- switch_inline_query_chosen_chat?: {
18
- query?: string;
19
- allow_user_chats?: boolean;
20
- allow_bot_chats?: boolean;
21
- allow_group_chats?: boolean;
22
- allow_channel_chats?: boolean;
23
- };
24
- copy_text?: {
25
- text: string;
26
- };
27
- };
28
- type InlineKeyboardMarkup = {
29
- inline_keyboard: InlineKeyboardButton[][];
30
- };
31
- declare class KeyboardBuilder {
32
- private keyboard;
33
- private _maxPerRow;
34
- static inline(): KeyboardBuilder;
35
- maxPerRow(n: number): this;
36
- private currentRow;
37
- row(): this;
38
- private push;
39
- url(text: string, url: string): this;
40
- style(text: string, style: string, url: string): this;
41
- callback(text: string, data: string): this;
42
- webApp(text: string, url: string): this;
43
- loginUrl(text: string, url: string, opts?: Omit<NonNullable<InlineKeyboardButton["login_url"]>, "url">): this;
44
- switchInline(text: string, query: string): this;
45
- switchInlineCurrentChat(text: string, query: string): this;
46
- switchInlineChosenChat(text: string, opts: InlineKeyboardButton["switch_inline_query_chosen_chat"]): this;
47
- copyText(text: string, copy: string): this;
48
- build(): InlineKeyboardMarkup;
49
- }
50
-
51
1
  type HttpOptions = {
52
2
  api_key: string;
53
3
  base_url: string;
@@ -110,4 +60,54 @@ declare class Client {
110
60
  constructor(opts: ClientOptions);
111
61
  }
112
62
 
63
+ type InlineKeyboardButton = {
64
+ text: string;
65
+ url?: string;
66
+ style?: string;
67
+ callback_data?: string;
68
+ web_app?: {
69
+ url: string;
70
+ };
71
+ login_url?: {
72
+ url: string;
73
+ forward_text?: string;
74
+ bot_username?: string;
75
+ request_write_access?: boolean;
76
+ };
77
+ switch_inline_query?: string;
78
+ switch_inline_query_current_chat?: string;
79
+ switch_inline_query_chosen_chat?: {
80
+ query?: string;
81
+ allow_user_chats?: boolean;
82
+ allow_bot_chats?: boolean;
83
+ allow_group_chats?: boolean;
84
+ allow_channel_chats?: boolean;
85
+ };
86
+ copy_text?: {
87
+ text: string;
88
+ };
89
+ };
90
+ type InlineKeyboardMarkup = {
91
+ inline_keyboard: InlineKeyboardButton[][];
92
+ };
93
+ declare class KeyboardBuilder {
94
+ private keyboard;
95
+ private _maxPerRow;
96
+ static inline(): KeyboardBuilder;
97
+ maxPerRow(n: number): this;
98
+ private currentRow;
99
+ row(): this;
100
+ private push;
101
+ url(text: string, url: string): this;
102
+ style(text: string, style: string, url: string): this;
103
+ callback(text: string, data: string): this;
104
+ webApp(text: string, url: string): this;
105
+ loginUrl(text: string, url: string, opts?: Omit<NonNullable<InlineKeyboardButton["login_url"]>, "url">): this;
106
+ switchInline(text: string, query: string): this;
107
+ switchInlineCurrentChat(text: string, query: string): this;
108
+ switchInlineChosenChat(text: string, opts: InlineKeyboardButton["switch_inline_query_chosen_chat"]): this;
109
+ copyText(text: string, copy: string): this;
110
+ build(): InlineKeyboardMarkup;
111
+ }
112
+
113
113
  export { Client, type ClientOptions, type InlineKeyboardButton, type InlineKeyboardMarkup, KeyboardBuilder };