@xtsea/tgcore-ts 0.1.8 → 0.1.10

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.
package/README.md CHANGED
@@ -34,9 +34,11 @@ npm install @xtsea/tgcore-ts
34
34
  ## Getting started
35
35
 
36
36
  ```ts
37
- import { Client } from "@xtsea/tgcore-ts"
37
+ import { tgcore } from "@xtsea/tgcore-ts"
38
38
 
39
- const tg = new Client({ api_key: "fw_live_xxx" })
39
+ // old version: 0.1.9 new Client({})
40
+
41
+ const tg = tgcore({ api_key: "fw_live_xxx" }) // version: 0.1.10
40
42
 
41
43
  await tg.raw.sendMessage({
42
44
  chat_id: -1001234567890,
@@ -1,85 +1,30 @@
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
- if (!btn.text?.trim()) throw new Error("Button text is required");
25
- if (btn.text.length > 64) throw new Error("Button text too long (max 64 chars)");
26
- const actionKeys = [
27
- "url",
28
- "callback_data",
29
- "web_app",
30
- "login_url",
31
- "switch_inline_query",
32
- "switch_inline_query_current_chat",
33
- "switch_inline_query_chosen_chat",
34
- "copy_text"
35
- ];
36
- const used = actionKeys.filter((k) => btn[k] != null);
37
- if (used.length !== 1) {
38
- throw new Error(`InlineKeyboardButton must have exactly 1 action field, got: ${used.join(", ") || "none"}`);
39
- }
40
- if (btn.callback_data && btn.callback_data.length > 64) {
41
- throw new Error("callback_data too long (max 64 chars)");
42
- }
43
- if (this._maxPerRow && this.currentRow().length >= this._maxPerRow) {
44
- this.row();
45
- }
46
- this.currentRow().push(btn);
47
- return this;
48
- }
49
- url(text, url) {
50
- return this.push({ text, url });
51
- }
52
- style(text, style, url) {
53
- return this.push({ text, style, url });
54
- }
55
- callback(text, data) {
56
- return this.push({ text, callback_data: data });
57
- }
58
- webApp(text, url) {
59
- return this.push({ text, web_app: { url } });
60
- }
61
- loginUrl(text, url, opts) {
62
- return this.push({ text, login_url: { url, ...opts ?? {} } });
63
- }
64
- switchInline(text, query) {
65
- return this.push({ text, switch_inline_query: query });
66
- }
67
- switchInlineCurrentChat(text, query) {
68
- return this.push({ text, switch_inline_query_current_chat: query });
69
- }
70
- switchInlineChosenChat(text, opts) {
71
- if (!opts) throw new Error("switch_inline_query_chosen_chat options required");
72
- return this.push({ text, switch_inline_query_chosen_chat: opts });
73
- }
74
- copyText(text, copy) {
75
- return this.push({ text, copy_text: { text: copy } });
76
- }
77
- build() {
78
- const cleaned = this.keyboard.filter((r) => r.length > 0);
79
- if (cleaned.length === 0) throw new Error("Keyboard is empty");
80
- 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 });
81
15
  }
16
+ return to;
82
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
+ tgcore: () => tgcore
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
83
28
 
84
29
  // src/http.ts
85
30
  var Http = class {
@@ -190,6 +135,9 @@ var CallMethods = class {
190
135
  };
191
136
 
192
137
  // src/client.ts
138
+ function tgcore(options) {
139
+ return new Client(options);
140
+ }
193
141
  var Client = class {
194
142
  constructor(opts) {
195
143
  if (!opts?.api_key) {
@@ -204,7 +152,92 @@ var Client = class {
204
152
  this.raw = new RawMethods(this.http);
205
153
  }
206
154
  };
207
- export {
208
- Client,
209
- KeyboardBuilder
155
+
156
+ // src/builders/keyboard.ts
157
+ var KeyboardBuilder = class _KeyboardBuilder {
158
+ constructor() {
159
+ this.keyboard = [[]];
160
+ this._maxPerRow = null;
161
+ }
162
+ static inline() {
163
+ return new _KeyboardBuilder();
164
+ }
165
+ maxPerRow(n) {
166
+ if (!Number.isInteger(n) || n <= 0) throw new Error("maxPerRow must be a positive integer");
167
+ this._maxPerRow = n;
168
+ return this;
169
+ }
170
+ currentRow() {
171
+ return this.keyboard[this.keyboard.length - 1];
172
+ }
173
+ row() {
174
+ if (this.currentRow().length === 0) return this;
175
+ this.keyboard.push([]);
176
+ return this;
177
+ }
178
+ push(btn) {
179
+ if (!btn.text?.trim()) throw new Error("Button text is required");
180
+ if (btn.text.length > 64) throw new Error("Button text too long (max 64 chars)");
181
+ const actionKeys = [
182
+ "url",
183
+ "callback_data",
184
+ "web_app",
185
+ "login_url",
186
+ "switch_inline_query",
187
+ "switch_inline_query_current_chat",
188
+ "switch_inline_query_chosen_chat",
189
+ "copy_text"
190
+ ];
191
+ const used = actionKeys.filter((k) => btn[k] != null);
192
+ if (used.length !== 1) {
193
+ throw new Error(`InlineKeyboardButton must have exactly 1 action field, got: ${used.join(", ") || "none"}`);
194
+ }
195
+ if (btn.callback_data && btn.callback_data.length > 64) {
196
+ throw new Error("callback_data too long (max 64 chars)");
197
+ }
198
+ if (this._maxPerRow && this.currentRow().length >= this._maxPerRow) {
199
+ this.row();
200
+ }
201
+ this.currentRow().push(btn);
202
+ return this;
203
+ }
204
+ url(text, url) {
205
+ return this.push({ text, url });
206
+ }
207
+ style(text, style, url) {
208
+ return this.push({ text, style, url });
209
+ }
210
+ callback(text, data) {
211
+ return this.push({ text, callback_data: data });
212
+ }
213
+ webApp(text, url) {
214
+ return this.push({ text, web_app: { url } });
215
+ }
216
+ loginUrl(text, url, opts) {
217
+ return this.push({ text, login_url: { url, ...opts ?? {} } });
218
+ }
219
+ switchInline(text, query) {
220
+ return this.push({ text, switch_inline_query: query });
221
+ }
222
+ switchInlineCurrentChat(text, query) {
223
+ return this.push({ text, switch_inline_query_current_chat: query });
224
+ }
225
+ switchInlineChosenChat(text, opts) {
226
+ if (!opts) throw new Error("switch_inline_query_chosen_chat options required");
227
+ return this.push({ text, switch_inline_query_chosen_chat: opts });
228
+ }
229
+ copyText(text, copy) {
230
+ return this.push({ text, copy_text: { text: copy } });
231
+ }
232
+ build() {
233
+ const cleaned = this.keyboard.filter((r) => r.length > 0);
234
+ if (cleaned.length === 0) throw new Error("Keyboard is empty");
235
+ return { inline_keyboard: cleaned };
236
+ }
210
237
  };
238
+ // Annotate the CommonJS export names for ESM import in node:
239
+ 0 && (module.exports = {
240
+ Client,
241
+ KeyboardBuilder,
242
+ tgcore
243
+ });
@@ -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;
@@ -103,6 +53,7 @@ type ClientOptions = {
103
53
  base_url?: string;
104
54
  timeout_ms?: number;
105
55
  };
56
+ declare function tgcore(options: ClientOptions): Client;
106
57
  declare class Client {
107
58
  private http;
108
59
  raw: RawMethods;
@@ -110,4 +61,54 @@ declare class Client {
110
61
  constructor(opts: ClientOptions);
111
62
  }
112
63
 
113
- export { Client, type ClientOptions, type InlineKeyboardButton, type InlineKeyboardMarkup, KeyboardBuilder };
64
+ type InlineKeyboardButton = {
65
+ text: string;
66
+ url?: string;
67
+ style?: string;
68
+ callback_data?: string;
69
+ web_app?: {
70
+ url: string;
71
+ };
72
+ login_url?: {
73
+ url: string;
74
+ forward_text?: string;
75
+ bot_username?: string;
76
+ request_write_access?: boolean;
77
+ };
78
+ switch_inline_query?: string;
79
+ switch_inline_query_current_chat?: string;
80
+ switch_inline_query_chosen_chat?: {
81
+ query?: string;
82
+ allow_user_chats?: boolean;
83
+ allow_bot_chats?: boolean;
84
+ allow_group_chats?: boolean;
85
+ allow_channel_chats?: boolean;
86
+ };
87
+ copy_text?: {
88
+ text: string;
89
+ };
90
+ };
91
+ type InlineKeyboardMarkup = {
92
+ inline_keyboard: InlineKeyboardButton[][];
93
+ };
94
+ declare class KeyboardBuilder {
95
+ private keyboard;
96
+ private _maxPerRow;
97
+ static inline(): KeyboardBuilder;
98
+ maxPerRow(n: number): this;
99
+ private currentRow;
100
+ row(): this;
101
+ private push;
102
+ url(text: string, url: string): this;
103
+ style(text: string, style: string, url: string): this;
104
+ callback(text: string, data: string): this;
105
+ webApp(text: string, url: string): this;
106
+ loginUrl(text: string, url: string, opts?: Omit<NonNullable<InlineKeyboardButton["login_url"]>, "url">): this;
107
+ switchInline(text: string, query: string): this;
108
+ switchInlineCurrentChat(text: string, query: string): this;
109
+ switchInlineChosenChat(text: string, opts: InlineKeyboardButton["switch_inline_query_chosen_chat"]): this;
110
+ copyText(text: string, copy: string): this;
111
+ build(): InlineKeyboardMarkup;
112
+ }
113
+
114
+ export { Client, type ClientOptions, type InlineKeyboardButton, type InlineKeyboardMarkup, KeyboardBuilder, tgcore };
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;
@@ -103,6 +53,7 @@ type ClientOptions = {
103
53
  base_url?: string;
104
54
  timeout_ms?: number;
105
55
  };
56
+ declare function tgcore(options: ClientOptions): Client;
106
57
  declare class Client {
107
58
  private http;
108
59
  raw: RawMethods;
@@ -110,4 +61,54 @@ declare class Client {
110
61
  constructor(opts: ClientOptions);
111
62
  }
112
63
 
113
- export { Client, type ClientOptions, type InlineKeyboardButton, type InlineKeyboardMarkup, KeyboardBuilder };
64
+ type InlineKeyboardButton = {
65
+ text: string;
66
+ url?: string;
67
+ style?: string;
68
+ callback_data?: string;
69
+ web_app?: {
70
+ url: string;
71
+ };
72
+ login_url?: {
73
+ url: string;
74
+ forward_text?: string;
75
+ bot_username?: string;
76
+ request_write_access?: boolean;
77
+ };
78
+ switch_inline_query?: string;
79
+ switch_inline_query_current_chat?: string;
80
+ switch_inline_query_chosen_chat?: {
81
+ query?: string;
82
+ allow_user_chats?: boolean;
83
+ allow_bot_chats?: boolean;
84
+ allow_group_chats?: boolean;
85
+ allow_channel_chats?: boolean;
86
+ };
87
+ copy_text?: {
88
+ text: string;
89
+ };
90
+ };
91
+ type InlineKeyboardMarkup = {
92
+ inline_keyboard: InlineKeyboardButton[][];
93
+ };
94
+ declare class KeyboardBuilder {
95
+ private keyboard;
96
+ private _maxPerRow;
97
+ static inline(): KeyboardBuilder;
98
+ maxPerRow(n: number): this;
99
+ private currentRow;
100
+ row(): this;
101
+ private push;
102
+ url(text: string, url: string): this;
103
+ style(text: string, style: string, url: string): this;
104
+ callback(text: string, data: string): this;
105
+ webApp(text: string, url: string): this;
106
+ loginUrl(text: string, url: string, opts?: Omit<NonNullable<InlineKeyboardButton["login_url"]>, "url">): this;
107
+ switchInline(text: string, query: string): this;
108
+ switchInlineCurrentChat(text: string, query: string): this;
109
+ switchInlineChosenChat(text: string, opts: InlineKeyboardButton["switch_inline_query_chosen_chat"]): this;
110
+ copyText(text: string, copy: string): this;
111
+ build(): InlineKeyboardMarkup;
112
+ }
113
+
114
+ export { Client, type ClientOptions, type InlineKeyboardButton, type InlineKeyboardMarkup, KeyboardBuilder, tgcore };
package/dist/index.js CHANGED
@@ -1,113 +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
- if (!btn.text?.trim()) throw new Error("Button text is required");
52
- if (btn.text.length > 64) throw new Error("Button text too long (max 64 chars)");
53
- const actionKeys = [
54
- "url",
55
- "callback_data",
56
- "web_app",
57
- "login_url",
58
- "switch_inline_query",
59
- "switch_inline_query_current_chat",
60
- "switch_inline_query_chosen_chat",
61
- "copy_text"
62
- ];
63
- const used = actionKeys.filter((k) => btn[k] != null);
64
- if (used.length !== 1) {
65
- throw new Error(`InlineKeyboardButton must have exactly 1 action field, got: ${used.join(", ") || "none"}`);
66
- }
67
- if (btn.callback_data && btn.callback_data.length > 64) {
68
- throw new Error("callback_data too long (max 64 chars)");
69
- }
70
- if (this._maxPerRow && this.currentRow().length >= this._maxPerRow) {
71
- this.row();
72
- }
73
- this.currentRow().push(btn);
74
- return this;
75
- }
76
- url(text, url) {
77
- return this.push({ text, url });
78
- }
79
- style(text, style, url) {
80
- return this.push({ text, style, url });
81
- }
82
- callback(text, data) {
83
- return this.push({ text, callback_data: data });
84
- }
85
- webApp(text, url) {
86
- return this.push({ text, web_app: { url } });
87
- }
88
- loginUrl(text, url, opts) {
89
- return this.push({ text, login_url: { url, ...opts ?? {} } });
90
- }
91
- switchInline(text, query) {
92
- return this.push({ text, switch_inline_query: query });
93
- }
94
- switchInlineCurrentChat(text, query) {
95
- return this.push({ text, switch_inline_query_current_chat: query });
96
- }
97
- switchInlineChosenChat(text, opts) {
98
- if (!opts) throw new Error("switch_inline_query_chosen_chat options required");
99
- return this.push({ text, switch_inline_query_chosen_chat: opts });
100
- }
101
- copyText(text, copy) {
102
- return this.push({ text, copy_text: { text: copy } });
103
- }
104
- build() {
105
- const cleaned = this.keyboard.filter((r) => r.length > 0);
106
- if (cleaned.length === 0) throw new Error("Keyboard is empty");
107
- return { inline_keyboard: cleaned };
108
- }
109
- };
110
-
111
1
  // src/http.ts
112
2
  var Http = class {
113
3
  constructor(opts) {
@@ -217,6 +107,9 @@ var CallMethods = class {
217
107
  };
218
108
 
219
109
  // src/client.ts
110
+ function tgcore(options) {
111
+ return new Client(options);
112
+ }
220
113
  var Client = class {
221
114
  constructor(opts) {
222
115
  if (!opts?.api_key) {
@@ -231,8 +124,91 @@ var Client = class {
231
124
  this.raw = new RawMethods(this.http);
232
125
  }
233
126
  };
234
- // Annotate the CommonJS export names for ESM import in node:
235
- 0 && (module.exports = {
127
+
128
+ // src/builders/keyboard.ts
129
+ var KeyboardBuilder = class _KeyboardBuilder {
130
+ constructor() {
131
+ this.keyboard = [[]];
132
+ this._maxPerRow = null;
133
+ }
134
+ static inline() {
135
+ return new _KeyboardBuilder();
136
+ }
137
+ maxPerRow(n) {
138
+ if (!Number.isInteger(n) || n <= 0) throw new Error("maxPerRow must be a positive integer");
139
+ this._maxPerRow = n;
140
+ return this;
141
+ }
142
+ currentRow() {
143
+ return this.keyboard[this.keyboard.length - 1];
144
+ }
145
+ row() {
146
+ if (this.currentRow().length === 0) return this;
147
+ this.keyboard.push([]);
148
+ return this;
149
+ }
150
+ push(btn) {
151
+ if (!btn.text?.trim()) throw new Error("Button text is required");
152
+ if (btn.text.length > 64) throw new Error("Button text too long (max 64 chars)");
153
+ const actionKeys = [
154
+ "url",
155
+ "callback_data",
156
+ "web_app",
157
+ "login_url",
158
+ "switch_inline_query",
159
+ "switch_inline_query_current_chat",
160
+ "switch_inline_query_chosen_chat",
161
+ "copy_text"
162
+ ];
163
+ const used = actionKeys.filter((k) => btn[k] != null);
164
+ if (used.length !== 1) {
165
+ throw new Error(`InlineKeyboardButton must have exactly 1 action field, got: ${used.join(", ") || "none"}`);
166
+ }
167
+ if (btn.callback_data && btn.callback_data.length > 64) {
168
+ throw new Error("callback_data too long (max 64 chars)");
169
+ }
170
+ if (this._maxPerRow && this.currentRow().length >= this._maxPerRow) {
171
+ this.row();
172
+ }
173
+ this.currentRow().push(btn);
174
+ return this;
175
+ }
176
+ url(text, url) {
177
+ return this.push({ text, url });
178
+ }
179
+ style(text, style, url) {
180
+ return this.push({ text, style, url });
181
+ }
182
+ callback(text, data) {
183
+ return this.push({ text, callback_data: data });
184
+ }
185
+ webApp(text, url) {
186
+ return this.push({ text, web_app: { url } });
187
+ }
188
+ loginUrl(text, url, opts) {
189
+ return this.push({ text, login_url: { url, ...opts ?? {} } });
190
+ }
191
+ switchInline(text, query) {
192
+ return this.push({ text, switch_inline_query: query });
193
+ }
194
+ switchInlineCurrentChat(text, query) {
195
+ return this.push({ text, switch_inline_query_current_chat: query });
196
+ }
197
+ switchInlineChosenChat(text, opts) {
198
+ if (!opts) throw new Error("switch_inline_query_chosen_chat options required");
199
+ return this.push({ text, switch_inline_query_chosen_chat: opts });
200
+ }
201
+ copyText(text, copy) {
202
+ return this.push({ text, copy_text: { text: copy } });
203
+ }
204
+ build() {
205
+ const cleaned = this.keyboard.filter((r) => r.length > 0);
206
+ if (cleaned.length === 0) throw new Error("Keyboard is empty");
207
+ return { inline_keyboard: cleaned };
208
+ }
209
+ };
210
+ export {
236
211
  Client,
237
- KeyboardBuilder
238
- });
212
+ KeyboardBuilder,
213
+ tgcore
214
+ };
package/package.json CHANGED
@@ -1,10 +1,19 @@
1
1
  {
2
2
  "name": "@xtsea/tgcore-ts",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
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": {