@mks2508/telegram-message-builder 0.2.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.
Files changed (44) hide show
  1. package/dist/index.cjs +445 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.js +422 -0
  4. package/dist/index.js.map +1 -0
  5. package/package.json +39 -0
  6. package/src/builder/builder.d.ts +33 -0
  7. package/src/builder/builder.d.ts.map +1 -0
  8. package/src/builder/builder.ts +124 -0
  9. package/src/builder/index.d.ts +2 -0
  10. package/src/builder/index.d.ts.map +1 -0
  11. package/src/builder/index.ts +1 -0
  12. package/src/escaping.test.ts +133 -0
  13. package/src/formatters/index.d.ts +40 -0
  14. package/src/formatters/index.d.ts.map +1 -0
  15. package/src/formatters/index.ts +117 -0
  16. package/src/formatters.test.ts +163 -0
  17. package/src/index.d.ts +10 -0
  18. package/src/index.d.ts.map +1 -0
  19. package/src/index.ts +22 -0
  20. package/src/keyboard/index.d.ts +114 -0
  21. package/src/keyboard/index.d.ts.map +1 -0
  22. package/src/keyboard/index.ts +286 -0
  23. package/src/keyboard.test.ts +217 -0
  24. package/src/types/constants.d.ts +14 -0
  25. package/src/types/constants.d.ts.map +1 -0
  26. package/src/types/constants.ts +15 -0
  27. package/src/types/core.types.d.ts +75 -0
  28. package/src/types/core.types.d.ts.map +1 -0
  29. package/src/types/core.types.ts +80 -0
  30. package/src/types/index.d.ts +4 -0
  31. package/src/types/index.d.ts.map +1 -0
  32. package/src/types/index.ts +3 -0
  33. package/src/types/keyboard-types.index.d.ts +2 -0
  34. package/src/types/keyboard-types.index.d.ts.map +1 -0
  35. package/src/types/keyboard-types.index.ts +1 -0
  36. package/src/types/keyboard.types.d.ts +96 -0
  37. package/src/types/keyboard.types.d.ts.map +1 -0
  38. package/src/types/keyboard.types.ts +95 -0
  39. package/src/types/main.types.d.ts +23 -0
  40. package/src/types/main.types.d.ts.map +1 -0
  41. package/src/types/main.types.ts +25 -0
  42. package/src/utils/index.d.ts +6 -0
  43. package/src/utils/index.d.ts.map +1 -0
  44. package/src/utils/index.ts +5 -0
@@ -0,0 +1,286 @@
1
+ /**
2
+ * @fileoverview Keyboard Builders
3
+ * @description Fluent API for building Telegram keyboards
4
+ * @module telegram-message-builder/keyboard
5
+ */
6
+
7
+ import type {
8
+ IInlineKeyboardMarkup,
9
+ IInlineKeyboardButton,
10
+ IReplyKeyboardMarkup,
11
+ IKeyboardButton,
12
+ IForceReplyMarkup,
13
+ } from "../types";
14
+
15
+ /**
16
+ * Telegram Keyboard Builder - Fluent API for building keyboards
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const keyboard = TelegramKeyboardBuilder.inline()
21
+ * .urlButton('Google', 'https://google.com')
22
+ * .row()
23
+ * .callbackButton('Yes', 'yes')
24
+ * .callbackButton('No', 'no')
25
+ * .buildMarkup()
26
+ * ```
27
+ */
28
+ export class TelegramKeyboardBuilder {
29
+ private rows: IInlineKeyboardButton[][] | IKeyboardButton[][] = [];
30
+ private type: "inline" | "reply" | "force" = "inline";
31
+ private currentRow: IInlineKeyboardButton[] | IKeyboardButton[] = [];
32
+
33
+ private constructor(type: "inline" | "reply" | "force") {
34
+ this.type = type;
35
+ }
36
+
37
+ /**
38
+ * Create an inline keyboard builder
39
+ */
40
+ static inline(): TelegramKeyboardBuilder {
41
+ return new TelegramKeyboardBuilder("inline");
42
+ }
43
+
44
+ /**
45
+ * Create a reply keyboard builder
46
+ */
47
+ static reply(): TelegramKeyboardBuilder {
48
+ return new TelegramKeyboardBuilder("reply");
49
+ }
50
+
51
+ /**
52
+ * Create a force reply builder
53
+ */
54
+ static forceReply(): TelegramKeyboardBuilder {
55
+ return new TelegramKeyboardBuilder("force");
56
+ }
57
+
58
+ /**
59
+ * Add a URL button (inline only)
60
+ */
61
+ urlButton(text: string, url: string): this {
62
+ if (this.type !== "inline") {
63
+ throw new Error("urlButton is only available for inline keyboards");
64
+ }
65
+ this.currentRow.push({ text, url });
66
+ return this;
67
+ }
68
+
69
+ /**
70
+ * Add a callback button (inline only)
71
+ */
72
+ callbackButton(text: string, data: string): this {
73
+ if (this.type !== "inline") {
74
+ throw new Error("callbackButton is only available for inline keyboards");
75
+ }
76
+ this.currentRow.push({ text, callback_data: data });
77
+ return this;
78
+ }
79
+
80
+ /**
81
+ * Add a web app button (inline only)
82
+ */
83
+ webAppButton(text: string, url: string): this {
84
+ if (this.type !== "inline") {
85
+ throw new Error("webAppButton is only available for inline keyboards");
86
+ }
87
+ this.currentRow.push({ text, web_app: { url } });
88
+ return this;
89
+ }
90
+
91
+ /**
92
+ * Add a login button (inline only)
93
+ */
94
+ loginButton(
95
+ text: string,
96
+ url: string,
97
+ options?: {
98
+ forwardText?: string;
99
+ botUsername?: string;
100
+ requestWriteAccess?: boolean;
101
+ },
102
+ ): this {
103
+ if (this.type !== "inline") {
104
+ throw new Error("loginButton is only available for inline keyboards");
105
+ }
106
+ this.currentRow.push({
107
+ text,
108
+ login_url: {
109
+ url,
110
+ forward_text: options?.forwardText,
111
+ bot_username: options?.botUsername,
112
+ request_write_access: options?.requestWriteAccess,
113
+ },
114
+ });
115
+ return this;
116
+ }
117
+
118
+ /**
119
+ * Add a switch inline query button (inline only)
120
+ */
121
+ switchInlineQueryButton(text: string, query: string): this {
122
+ if (this.type !== "inline") {
123
+ throw new Error(
124
+ "switchInlineQueryButton is only available for inline keyboards",
125
+ );
126
+ }
127
+ this.currentRow.push({ text, switch_inline_query: query });
128
+ return this;
129
+ }
130
+
131
+ /**
132
+ * Add a switch inline query current chat button (inline only)
133
+ */
134
+ switchInlineQueryCurrentChatButton(text: string, query: string): this {
135
+ if (this.type !== "inline") {
136
+ throw new Error(
137
+ "switchInlineQueryCurrentChatButton is only available for inline keyboards",
138
+ );
139
+ }
140
+ this.currentRow.push({ text, switch_inline_query_current_chat: query });
141
+ return this;
142
+ }
143
+
144
+ /**
145
+ * Add a callback game button (inline only)
146
+ */
147
+ callbackGameButton(text: string, shortName: string): this {
148
+ if (this.type !== "inline") {
149
+ throw new Error(
150
+ "callbackGameButton is only available for inline keyboards",
151
+ );
152
+ }
153
+ this.currentRow.push({ text, callback_game: shortName });
154
+ return this;
155
+ }
156
+
157
+ /**
158
+ * Add a pay button (inline only)
159
+ */
160
+ payButton(text: string): this {
161
+ if (this.type !== "inline") {
162
+ throw new Error("payButton is only available for inline keyboards");
163
+ }
164
+ this.currentRow.push({ text, pay: text });
165
+ return this;
166
+ }
167
+
168
+ /**
169
+ * Add a text button (reply keyboard only)
170
+ */
171
+ textButton(text: string): this {
172
+ if (this.type !== "reply") {
173
+ throw new Error("textButton is only available for reply keyboards");
174
+ }
175
+ this.currentRow.push({ text });
176
+ return this;
177
+ }
178
+
179
+ /**
180
+ * Add a request contact button (reply keyboard only)
181
+ */
182
+ requestContactButton(text: string): this {
183
+ if (this.type !== "reply") {
184
+ throw new Error(
185
+ "requestContactButton is only available for reply keyboards",
186
+ );
187
+ }
188
+ this.currentRow.push({ text, request_contact: true });
189
+ return this;
190
+ }
191
+
192
+ /**
193
+ * Add a request location button (reply keyboard only)
194
+ */
195
+ requestLocationButton(text: string): this {
196
+ if (this.type !== "reply") {
197
+ throw new Error(
198
+ "requestLocationButton is only available for reply keyboards",
199
+ );
200
+ }
201
+ this.currentRow.push({ text, request_location: true });
202
+ return this;
203
+ }
204
+
205
+ /**
206
+ * Add a request poll button (reply keyboard only)
207
+ */
208
+ requestPollButton(text: string, pollType: string): this {
209
+ if (this.type !== "reply") {
210
+ throw new Error(
211
+ "requestPollButton is only available for reply keyboards",
212
+ );
213
+ }
214
+ this.currentRow.push({ text, request_poll: { type: pollType } });
215
+ return this;
216
+ }
217
+
218
+ /**
219
+ * Add a custom button to current row
220
+ */
221
+ button(button: IInlineKeyboardButton | IKeyboardButton): this {
222
+ this.currentRow.push(button);
223
+ return this;
224
+ }
225
+
226
+ /**
227
+ * Finish current row and start a new one
228
+ */
229
+ row(): this {
230
+ if (this.currentRow.length > 0) {
231
+ this.rows.push([...this.currentRow]);
232
+ this.currentRow = [];
233
+ }
234
+ return this;
235
+ }
236
+
237
+ /**
238
+ * Build inline keyboard markup
239
+ */
240
+ buildMarkup(): IInlineKeyboardMarkup {
241
+ // Add last row if not empty
242
+ if (this.currentRow.length > 0) {
243
+ this.rows.push([...this.currentRow]);
244
+ }
245
+
246
+ return { inline_keyboard: this.rows as IInlineKeyboardButton[][] };
247
+ }
248
+
249
+ /**
250
+ * Build reply keyboard markup
251
+ */
252
+ buildReplyMarkup(): IReplyKeyboardMarkup {
253
+ // Add last row if not empty
254
+ if (this.currentRow.length > 0) {
255
+ this.rows.push([...this.currentRow]);
256
+ }
257
+
258
+ return {
259
+ keyboard: this.rows as IKeyboardButton[][],
260
+ resize_keyboard: true,
261
+ one_time_keyboard: false,
262
+ selective: false,
263
+ };
264
+ }
265
+
266
+ /**
267
+ * Build force reply markup
268
+ */
269
+ buildForceReplyMarkup(): IForceReplyMarkup {
270
+ return { force_reply: true };
271
+ }
272
+
273
+ /**
274
+ * Build markup based on keyboard type
275
+ */
276
+ build(): IInlineKeyboardMarkup | IReplyKeyboardMarkup | IForceReplyMarkup {
277
+ switch (this.type) {
278
+ case "inline":
279
+ return this.buildMarkup();
280
+ case "reply":
281
+ return this.buildReplyMarkup();
282
+ case "force":
283
+ return this.buildForceReplyMarkup();
284
+ }
285
+ }
286
+ }
@@ -0,0 +1,217 @@
1
+ import { describe, it, expect, beforeEach } from "bun:test";
2
+ import { TelegramKeyboardBuilder } from "../src";
3
+
4
+ describe("TelegramKeyboardBuilder", () => {
5
+ describe("Inline Keyboard", () => {
6
+ let builder: TelegramKeyboardBuilder;
7
+
8
+ beforeEach(() => {
9
+ builder = TelegramKeyboardBuilder.inline();
10
+ });
11
+
12
+ it("should create empty inline keyboard", () => {
13
+ const markup = builder.buildMarkup();
14
+ expect(markup.inline_keyboard).toEqual([]);
15
+ });
16
+
17
+ it("should add URL button", () => {
18
+ builder.urlButton("Google", "https://google.com");
19
+ const markup = builder.buildMarkup();
20
+ expect(markup.inline_keyboard).toEqual([
21
+ [{ text: "Google", url: "https://google.com" }],
22
+ ]);
23
+ });
24
+
25
+ it("should add callback button", () => {
26
+ builder.callbackButton("Click me", "action_1");
27
+ const markup = builder.buildMarkup();
28
+ expect(markup.inline_keyboard).toEqual([
29
+ [{ text: "Click me", callback_data: "action_1" }],
30
+ ]);
31
+ });
32
+
33
+ it("should add multiple buttons in one row", () => {
34
+ builder.urlButton("Google", "https://google.com");
35
+ builder.callbackButton("Click", "action");
36
+ const markup = builder.buildMarkup();
37
+ expect(markup.inline_keyboard).toHaveLength(1);
38
+ expect(markup.inline_keyboard[0]).toHaveLength(2);
39
+ });
40
+
41
+ it("should create multiple rows", () => {
42
+ builder.urlButton("Button 1", "https://example.com");
43
+ builder.row();
44
+ builder.callbackButton("Button 2", "action");
45
+ builder.row();
46
+ builder.urlButton("Button 3", "https://example.com");
47
+ const markup = builder.buildMarkup();
48
+ expect(markup.inline_keyboard).toHaveLength(3);
49
+ expect(markup.inline_keyboard[0]).toHaveLength(1);
50
+ expect(markup.inline_keyboard[1]).toHaveLength(1);
51
+ expect(markup.inline_keyboard[2]).toHaveLength(1);
52
+ });
53
+
54
+ it("should add web app button", () => {
55
+ builder.webAppButton("Open App", "https://example.com/app");
56
+ const markup = builder.buildMarkup();
57
+ expect(markup.inline_keyboard[0][0]).toMatchObject({
58
+ text: "Open App",
59
+ web_app: { url: "https://example.com/app" },
60
+ });
61
+ });
62
+
63
+ it("should add login button", () => {
64
+ builder.loginButton("Login", "https://example.com/login");
65
+ const markup = builder.buildMarkup();
66
+ expect(markup.inline_keyboard[0][0]).toMatchObject({
67
+ text: "Login",
68
+ login_url: { url: "https://example.com/login" },
69
+ });
70
+ });
71
+
72
+ it("should add switch inline query button", () => {
73
+ builder.switchInlineQueryButton("Search", "query");
74
+ const markup = builder.buildMarkup();
75
+ expect(markup.inline_keyboard[0][0]).toMatchObject({
76
+ text: "Search",
77
+ switch_inline_query: "query",
78
+ });
79
+ });
80
+
81
+ it("should add switch inline query current chat button", () => {
82
+ builder.switchInlineQueryCurrentChatButton("Search", "query");
83
+ const markup = builder.buildMarkup();
84
+ expect(markup.inline_keyboard[0][0]).toMatchObject({
85
+ text: "Search",
86
+ switch_inline_query_current_chat: "query",
87
+ });
88
+ });
89
+
90
+ it("should add callback game button", () => {
91
+ builder.callbackGameButton("Play", "my_game");
92
+ const markup = builder.buildMarkup();
93
+ expect(markup.inline_keyboard[0][0]).toMatchObject({
94
+ text: "Play",
95
+ callback_game: "my_game",
96
+ });
97
+ });
98
+
99
+ it("should add pay button", () => {
100
+ builder.payButton("Pay $10");
101
+ const markup = builder.buildMarkup();
102
+ expect(markup.inline_keyboard[0][0]).toMatchObject({
103
+ text: "Pay $10",
104
+ pay: "Pay $10",
105
+ });
106
+ });
107
+
108
+ it("should throw error when using reply keyboard methods on inline", () => {
109
+ expect(() => builder.textButton("Button")).toThrow();
110
+ expect(() => builder.requestContactButton("Contact")).toThrow();
111
+ });
112
+ });
113
+
114
+ describe("Reply Keyboard", () => {
115
+ let builder: TelegramKeyboardBuilder;
116
+
117
+ beforeEach(() => {
118
+ builder = TelegramKeyboardBuilder.reply();
119
+ });
120
+
121
+ it("should create empty reply keyboard", () => {
122
+ const markup = builder.buildReplyMarkup();
123
+ expect(markup.keyboard).toEqual([]);
124
+ });
125
+
126
+ it("should add text button", () => {
127
+ builder.textButton("Option 1");
128
+ const markup = builder.buildReplyMarkup();
129
+ expect(markup.keyboard).toEqual([[{ text: "Option 1" }]]);
130
+ });
131
+
132
+ it("should add request contact button", () => {
133
+ builder.requestContactButton("Share Contact");
134
+ const markup = builder.buildReplyMarkup();
135
+ expect(markup.keyboard).toEqual([
136
+ [{ text: "Share Contact", request_contact: true }],
137
+ ]);
138
+ });
139
+
140
+ it("should add request location button", () => {
141
+ builder.requestLocationButton("Share Location");
142
+ const markup = builder.buildReplyMarkup();
143
+ expect(markup.keyboard).toEqual([
144
+ [{ text: "Share Location", request_location: true }],
145
+ ]);
146
+ });
147
+
148
+ it("should add request poll button", () => {
149
+ builder.requestPollButton("Create Poll", "regular");
150
+ const markup = builder.buildReplyMarkup();
151
+ expect(markup.keyboard).toEqual([
152
+ [{ text: "Create Poll", request_poll: { type: "regular" } }],
153
+ ]);
154
+ });
155
+
156
+ it("should create multiple rows", () => {
157
+ builder.textButton("Button 1");
158
+ builder.row();
159
+ builder.textButton("Button 2");
160
+ builder.row();
161
+ builder.textButton("Button 3");
162
+ const markup = builder.buildReplyMarkup();
163
+ expect(markup.keyboard).toHaveLength(3);
164
+ expect(markup.keyboard[0]).toHaveLength(1);
165
+ expect(markup.keyboard[1]).toHaveLength(1);
166
+ expect(markup.keyboard[2]).toHaveLength(1);
167
+ });
168
+
169
+ it("should throw error when using inline keyboard methods on reply", () => {
170
+ expect(() => builder.urlButton("Google", "https://google.com")).toThrow();
171
+ expect(() => builder.callbackButton("Click", "action")).toThrow();
172
+ });
173
+ });
174
+
175
+ describe("Force Reply", () => {
176
+ it("should create force reply markup", () => {
177
+ const builder = TelegramKeyboardBuilder.forceReply();
178
+ const markup = builder.buildForceReplyMarkup();
179
+ expect(markup).toMatchObject({ force_reply: true });
180
+ });
181
+ });
182
+
183
+ describe("Combined Example", () => {
184
+ it("should build a complete inline keyboard", () => {
185
+ const markup = TelegramKeyboardBuilder.inline()
186
+ .urlButton("Google", "https://google.com")
187
+ .urlButton("GitHub", "https://github.com")
188
+ .row()
189
+ .callbackButton("✅ Yes", "yes")
190
+ .callbackButton("❌ No", "no")
191
+ .row()
192
+ .callbackButton("🔄 Refresh", "refresh")
193
+ .buildMarkup();
194
+
195
+ expect(markup.inline_keyboard).toHaveLength(3);
196
+ expect(markup.inline_keyboard[0]).toHaveLength(2);
197
+ expect(markup.inline_keyboard[1]).toHaveLength(2);
198
+ expect(markup.inline_keyboard[2]).toHaveLength(1);
199
+ });
200
+
201
+ it("should build a complete reply keyboard", () => {
202
+ const markup = TelegramKeyboardBuilder.reply()
203
+ .textButton("Option 1")
204
+ .textButton("Option 2")
205
+ .row()
206
+ .requestContactButton("Share Contact")
207
+ .row()
208
+ .requestLocationButton("Share Location")
209
+ .buildReplyMarkup();
210
+
211
+ expect(markup.keyboard).toHaveLength(3);
212
+ expect(markup.keyboard[0]).toHaveLength(2);
213
+ expect(markup.keyboard[1]).toHaveLength(1);
214
+ expect(markup.keyboard[2]).toHaveLength(1);
215
+ });
216
+ });
217
+ });
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Constantes del package.
3
+ *
4
+ * @module
5
+ */
6
+ /**
7
+ * Prefijo por defecto para saludos.
8
+ */
9
+ export declare const DEFAULT_PREFIX = "Hello";
10
+ /**
11
+ * Sufijo por defecto para saludos.
12
+ */
13
+ export declare const DEFAULT_SUFFIX = "!";
14
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,cAAc,MAAM,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Constantes del package.
3
+ *
4
+ * @module
5
+ */
6
+
7
+ /**
8
+ * Prefijo por defecto para saludos.
9
+ */
10
+ export const DEFAULT_PREFIX = "Hello";
11
+
12
+ /**
13
+ * Sufijo por defecto para saludos.
14
+ */
15
+ export const DEFAULT_SUFFIX = "!";
@@ -0,0 +1,75 @@
1
+ /**
2
+ * @fileoverview Core types for Telegram Message Builder
3
+ * @description Defines the base types used throughout the message builder
4
+ * @module telegram-message-builder/types
5
+ */
6
+ /**
7
+ * Parse mode for Telegram messages
8
+ */
9
+ export type ParseMode = "html" | "markdown" | "markdownv2";
10
+ /**
11
+ * Format options for inline formatting
12
+ */
13
+ export interface FormatOpts {
14
+ /** Make text bold */
15
+ bold?: boolean;
16
+ /** Make text italic */
17
+ italic?: boolean;
18
+ /** Make text monospace (code) */
19
+ code?: boolean;
20
+ /** Make text underlined */
21
+ underline?: boolean;
22
+ /** Make text strikethrough */
23
+ strikethrough?: boolean;
24
+ /** Make text spoiler */
25
+ spoiler?: boolean;
26
+ }
27
+ /**
28
+ * Options for line formatting
29
+ */
30
+ export interface LineOpts extends FormatOpts {
31
+ /** Custom format string instead of key: value */
32
+ format?: string;
33
+ }
34
+ /**
35
+ * Generic Telegram message type
36
+ */
37
+ export interface TelegramMessage {
38
+ /** Message text */
39
+ text?: string;
40
+ /** Message caption (for media) */
41
+ caption?: string;
42
+ /** Parse mode for the message */
43
+ parse_mode?: ParseMode | undefined;
44
+ /** Reply markup (inline or reply keyboard) */
45
+ reply_markup?: unknown;
46
+ /** Disable web page preview */
47
+ disable_web_page_preview?: boolean;
48
+ /** Disable notification */
49
+ disable_notification?: boolean;
50
+ /** Protect content from forwarding */
51
+ protect_content?: boolean;
52
+ /** Reply to specific message */
53
+ reply_to_message_id?: number;
54
+ }
55
+ /**
56
+ * Build result
57
+ */
58
+ export interface BuildResult {
59
+ /** Formatted message text or caption */
60
+ text: string;
61
+ /** Parse mode for the message */
62
+ parse_mode: ParseMode;
63
+ /** Reply markup if any */
64
+ reply_markup?: unknown;
65
+ /** Additional options */
66
+ options?: Record<string, unknown>;
67
+ }
68
+ /**
69
+ * Validation error
70
+ */
71
+ export interface ValidationError {
72
+ message: string;
73
+ code: string;
74
+ }
75
+ //# sourceMappingURL=core.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.types.d.ts","sourceRoot":"","sources":["core.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,YAAY,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,qBAAqB;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,uBAAuB;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iCAAiC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,2BAA2B;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8BAA8B;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,wBAAwB;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,QAAS,SAAQ,UAAU;IAC1C,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,mBAAmB;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,UAAU,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IACnC,8CAA8C;IAC9C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,+BAA+B;IAC/B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,2BAA2B;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,sCAAsC;IACtC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gCAAgC;IAChC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,UAAU,EAAE,SAAS,CAAC;IACtB,0BAA0B;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,yBAAyB;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @fileoverview Core types for Telegram Message Builder
3
+ * @description Defines the base types used throughout the message builder
4
+ * @module telegram-message-builder/types
5
+ */
6
+
7
+ /**
8
+ * Parse mode for Telegram messages
9
+ */
10
+ export type ParseMode = "html" | "markdown" | "markdownv2";
11
+
12
+ /**
13
+ * Format options for inline formatting
14
+ */
15
+ export interface FormatOpts {
16
+ /** Make text bold */
17
+ bold?: boolean;
18
+ /** Make text italic */
19
+ italic?: boolean;
20
+ /** Make text monospace (code) */
21
+ code?: boolean;
22
+ /** Make text underlined */
23
+ underline?: boolean;
24
+ /** Make text strikethrough */
25
+ strikethrough?: boolean;
26
+ /** Make text spoiler */
27
+ spoiler?: boolean;
28
+ }
29
+
30
+ /**
31
+ * Options for line formatting
32
+ */
33
+ export interface LineOpts extends FormatOpts {
34
+ /** Custom format string instead of key: value */
35
+ format?: string;
36
+ }
37
+
38
+ /**
39
+ * Generic Telegram message type
40
+ */
41
+ export interface TelegramMessage {
42
+ /** Message text */
43
+ text?: string;
44
+ /** Message caption (for media) */
45
+ caption?: string;
46
+ /** Parse mode for the message */
47
+ parse_mode?: ParseMode | undefined;
48
+ /** Reply markup (inline or reply keyboard) */
49
+ reply_markup?: unknown;
50
+ /** Disable web page preview */
51
+ disable_web_page_preview?: boolean;
52
+ /** Disable notification */
53
+ disable_notification?: boolean;
54
+ /** Protect content from forwarding */
55
+ protect_content?: boolean;
56
+ /** Reply to specific message */
57
+ reply_to_message_id?: number;
58
+ }
59
+
60
+ /**
61
+ * Build result
62
+ */
63
+ export interface BuildResult {
64
+ /** Formatted message text or caption */
65
+ text: string;
66
+ /** Parse mode for the message */
67
+ parse_mode: ParseMode;
68
+ /** Reply markup if any */
69
+ reply_markup?: unknown;
70
+ /** Additional options */
71
+ options?: Record<string, unknown>;
72
+ }
73
+
74
+ /**
75
+ * Validation error
76
+ */
77
+ export interface ValidationError {
78
+ message: string;
79
+ code: string;
80
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./core.types";
2
+ export * from "./constants";
3
+ export * from "./keyboard.types";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC"}