teledzik 1.0.3 → 1.0.5

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/src/telegram.ts CHANGED
@@ -1680,23 +1680,127 @@ export class Telegram extends ApiClient {
1680
1680
  }
1681
1681
 
1682
1682
  /**
1683
- * Edit a sent rich message.
1683
+ * Universal editRichMessage to update text or media captions in-place with Omni-Format support.
1684
+ * Auto-detects Text vs Media Caption and gracefully handles 'message is not modified'.
1684
1685
  */
1685
- editRichMessage(
1686
+ async editRichMessage(
1686
1687
  chatId: number | string | undefined,
1687
- messageId: number | undefined,
1688
+ messageId: number | string | undefined,
1689
+ content: any,
1690
+ extra?: any
1691
+ ): Promise<any>
1692
+ async editRichMessage(
1693
+ chatId: number | string | undefined,
1694
+ messageId: number | string | undefined,
1688
1695
  inlineMessageId: string | undefined,
1689
- richMessage: tg.InputRichMessage,
1690
- extra?: object
1691
- ) {
1692
- return this.callApi('editMessageText' as never, {
1693
- chat_id: chatId,
1694
- message_id: messageId,
1695
- inline_message_id: inlineMessageId,
1696
- text: richMessage.html ?? richMessage.markdown ?? '',
1697
- parse_mode: richMessage.html ? 'HTML' : richMessage.markdown ? 'MarkdownV2' : undefined,
1696
+ content: any,
1697
+ extra?: any
1698
+ ): Promise<any>
1699
+ async editRichMessage(
1700
+ chatId: number | string | undefined,
1701
+ messageId: number | string | undefined,
1702
+ contentOrInline: any,
1703
+ contentOrExtra?: any,
1704
+ maybeExtra?: any
1705
+ ): Promise<any> {
1706
+ let inlineMessageId: string | undefined
1707
+ let content: any
1708
+ let extra: any = {}
1709
+
1710
+ if (
1711
+ typeof contentOrInline === 'string' &&
1712
+ (typeof contentOrExtra === 'object' || typeof contentOrExtra === 'string') &&
1713
+ maybeExtra !== undefined
1714
+ ) {
1715
+ inlineMessageId = contentOrInline
1716
+ content = contentOrExtra
1717
+ extra = maybeExtra || {}
1718
+ } else {
1719
+ content = contentOrInline
1720
+ extra = contentOrExtra || {}
1721
+ inlineMessageId = extra?.inline_message_id
1722
+ }
1723
+
1724
+ let htmlText = ''
1725
+ let replyMarkup = extra?.reply_markup
1726
+
1727
+ // 1. Omni-format input extraction
1728
+ if (content && typeof content.build === 'function') {
1729
+ const built = content.build()
1730
+ if (typeof built === 'object' && built !== null) {
1731
+ htmlText = built.html || built.text || built.caption || ''
1732
+ if (built.reply_markup) {
1733
+ replyMarkup = replyMarkup || built.reply_markup
1734
+ }
1735
+ } else {
1736
+ htmlText = String(built || '')
1737
+ }
1738
+ } else if (typeof content === 'object' && content !== null) {
1739
+ htmlText = content.html || content.text || content.caption || content.markdown || ''
1740
+ if (content.reply_markup) {
1741
+ replyMarkup = replyMarkup || content.reply_markup
1742
+ }
1743
+ } else if (typeof content === 'string') {
1744
+ htmlText = content
1745
+ }
1746
+
1747
+ // Sanitize rich HTML formatting (tables, headers, details, etc.)
1748
+ htmlText = sanitizeRichHtml(htmlText)
1749
+
1750
+ // 2. Prepare Base Payload
1751
+ const isInline = Boolean(inlineMessageId || extra?.inline_message_id)
1752
+ const basePayload: any = {
1753
+ parse_mode: 'HTML',
1698
1754
  ...extra,
1699
- } as never)
1755
+ }
1756
+
1757
+ if (isInline) {
1758
+ basePayload.inline_message_id = inlineMessageId || extra.inline_message_id
1759
+ } else {
1760
+ basePayload.chat_id = chatId
1761
+ basePayload.message_id = messageId != null ? Number(messageId) : undefined
1762
+ }
1763
+
1764
+ if (replyMarkup) {
1765
+ basePayload.reply_markup = replyMarkup
1766
+ }
1767
+
1768
+ // 3. Execution with Auto-Detect (Text -> Caption Fallback) and Silent Error Handling
1769
+ try {
1770
+ return await this.callApi('editMessageText' as never, {
1771
+ ...basePayload,
1772
+ text: htmlText,
1773
+ } as never)
1774
+ } catch (err: any) {
1775
+ const desc = String(err?.description || err?.message || '')
1776
+
1777
+ // Fallback: If target is a Media message (Photo, Video, Audio, Document, Animation)
1778
+ if (
1779
+ desc.includes('no text in the message') ||
1780
+ desc.includes('there is no text in the message to edit') ||
1781
+ desc.includes('message to edit not found')
1782
+ ) {
1783
+ try {
1784
+ return await this.callApi('editMessageCaption' as never, {
1785
+ ...basePayload,
1786
+ caption: htmlText,
1787
+ } as never)
1788
+ } catch (captionErr: any) {
1789
+ const capDesc = String(captionErr?.description || captionErr?.message || '')
1790
+ if (capDesc.includes('message is not modified')) {
1791
+ return false
1792
+ }
1793
+ throw captionErr
1794
+ }
1795
+ }
1796
+
1797
+ // Gracefully handle 'message is not modified'
1798
+ if (desc.includes('message is not modified')) {
1799
+ return false
1800
+ }
1801
+
1802
+ throw err
1803
+ }
1700
1804
  }
1701
1805
  }
1702
1806
 
@@ -20,8 +20,15 @@ type KeyboardButtonRequestChannel = Omit<KeyboardButtonRequestChat, 'request_id'
20
20
  export declare function channelRequest(text: string,
21
21
  /** Must fit in a signed 32 bit int */
22
22
  request_id: number, extra?: KeyboardButtonRequestChannel, hide?: boolean): Hideable<KeyboardButton.RequestChatButton>;
23
- export declare function url(text: string, url: string, hide?: boolean): Hideable<InlineKeyboardButton.UrlButton>;
24
- export declare function callback(text: string, data: string, hide?: boolean): Hideable<InlineKeyboardButton.CallbackButton>;
23
+ export type ButtonStyle = 'primary' | 'success' | 'danger';
24
+ export declare function url(text: string, url: string, hide?: boolean, style?: ButtonStyle, icon_custom_emoji_id?: string): Hideable<InlineKeyboardButton.UrlButton & {
25
+ style?: ButtonStyle;
26
+ icon_custom_emoji_id?: string;
27
+ }>;
28
+ export declare function callback(text: string, data: string, hide?: boolean, style?: ButtonStyle, icon_custom_emoji_id?: string): Hideable<InlineKeyboardButton.CallbackButton & {
29
+ style?: ButtonStyle;
30
+ icon_custom_emoji_id?: string;
31
+ }>;
25
32
  export declare function switchToChat(text: string, value: string, hide?: boolean): Hideable<InlineKeyboardButton.SwitchInlineButton>;
26
33
  export declare function switchToCurrentChat(text: string, value: string, hide?: boolean): Hideable<InlineKeyboardButton.SwitchInlineCurrentChatButton>;
27
34
  export declare function game(text: string, hide?: boolean): Hideable<InlineKeyboardButton.GameButton>;
@@ -32,4 +39,46 @@ export declare function login(text: string, url: string, opts?: {
32
39
  request_write_access?: boolean;
33
40
  }, hide?: boolean): Hideable<InlineKeyboardButton.LoginButton>;
34
41
  export declare function webApp(text: string, url: string, hide?: boolean): Hideable<InlineKeyboardButton.WebAppButton>;
42
+ /**
43
+ * 🔵 Primary callback button (Blue background)
44
+ */
45
+ export declare function primary(text: string, data: string, hide?: boolean, icon_custom_emoji_id?: string): Hideable<InlineKeyboardButton.CallbackButton & {
46
+ style?: ButtonStyle | undefined;
47
+ icon_custom_emoji_id?: string | undefined;
48
+ }>;
49
+ /**
50
+ * 🟢 Success callback button (Green background)
51
+ */
52
+ export declare function success(text: string, data: string, hide?: boolean, icon_custom_emoji_id?: string): Hideable<InlineKeyboardButton.CallbackButton & {
53
+ style?: ButtonStyle | undefined;
54
+ icon_custom_emoji_id?: string | undefined;
55
+ }>;
56
+ /**
57
+ * 🔴 Danger / Delete callback button (Red background)
58
+ */
59
+ export declare function danger(text: string, data: string, hide?: boolean, icon_custom_emoji_id?: string): Hideable<InlineKeyboardButton.CallbackButton & {
60
+ style?: ButtonStyle | undefined;
61
+ icon_custom_emoji_id?: string | undefined;
62
+ }>;
63
+ /**
64
+ * 🔵 Primary URL button (Blue background)
65
+ */
66
+ export declare function primaryUrl(text: string, targetUrl: string, hide?: boolean, icon_custom_emoji_id?: string): Hideable<InlineKeyboardButton.UrlButton & {
67
+ style?: ButtonStyle | undefined;
68
+ icon_custom_emoji_id?: string | undefined;
69
+ }>;
70
+ /**
71
+ * 🟢 Success URL button (Green background)
72
+ */
73
+ export declare function successUrl(text: string, targetUrl: string, hide?: boolean, icon_custom_emoji_id?: string): Hideable<InlineKeyboardButton.UrlButton & {
74
+ style?: ButtonStyle | undefined;
75
+ icon_custom_emoji_id?: string | undefined;
76
+ }>;
77
+ /**
78
+ * 🔴 Danger URL button (Red background)
79
+ */
80
+ export declare function dangerUrl(text: string, targetUrl: string, hide?: boolean, icon_custom_emoji_id?: string): Hideable<InlineKeyboardButton.UrlButton & {
81
+ style?: ButtonStyle | undefined;
82
+ icon_custom_emoji_id?: string | undefined;
83
+ }>;
35
84
  export {};
@@ -591,9 +591,11 @@ export declare class Context<U extends Deunionize<tg.Update> = tg.Update> {
591
591
  */
592
592
  sendRichMessageDraft(draftId: number, richMessage: tg.InputRichMessage, extra?: tt.ExtraSendRichMessageDraft): Promise<never>;
593
593
  /**
594
- * Edit current message with a rich message format.
594
+ * Universal Context shortcut to edit message with Omni-Format support (RichHTMLBuilder, Object, or String),
595
+ * auto-detection of Text vs Media Caption, and silent 'not modified' error handling.
595
596
  */
596
- editRichMessage(richMessage: tg.InputRichMessage, extra?: object): Promise<never>;
597
+ editRichMessage(content: tg.RichContentInput, extra?: tg.EditRichOptions): Promise<any>;
598
+ editRichMessage(messageId: number | string, content: tg.RichContentInput, extra?: tg.EditRichOptions): Promise<any>;
597
599
  /**
598
600
  * Enqueue a Telegram API call for the current chat to prevent 429 Too Many Requests errors.
599
601
  */
@@ -24,6 +24,26 @@ export interface InputRichMessage {
24
24
  export interface InputRichMessageContent {
25
25
  rich_message: InputRichMessage;
26
26
  }
27
+ export interface EditRichOptions {
28
+ reply_markup?: any;
29
+ disable_web_page_preview?: boolean;
30
+ link_preview_options?: any;
31
+ inline_message_id?: string;
32
+ [key: string]: any;
33
+ }
34
+ export type RichContentInput = string | {
35
+ html?: string;
36
+ text?: string;
37
+ caption?: string;
38
+ markdown?: string;
39
+ reply_markup?: any;
40
+ } | {
41
+ build(): string | InputRichMessage | {
42
+ html?: string;
43
+ text?: string;
44
+ reply_markup?: any;
45
+ };
46
+ } | InputRichMessage;
27
47
  /**
28
48
  * Fluent builder for Rich Messages using HTML format.
29
49
  *
@@ -13,6 +13,7 @@ export { deunionize } from './core/helpers/deunionize';
13
13
  export { session, MemorySessionStore, SessionStore } from './session';
14
14
  export * as Scenes from './scenes';
15
15
  export * as RichMessage from './core/types/rich-message';
16
+ export { RichHTMLBuilder, RichMarkdownBuilder, RichHTMLBuilder as HTML, MD } from './core/types/rich-message';
16
17
  export { SmartQueue } from './core/helpers/smart-queue';
17
18
  export { AIStreamAdapter } from './core/helpers/ai-stream';
18
19
  export { sanitizeRichHtml } from './core/helpers/rich-sanitizer';
@@ -690,8 +690,10 @@ export declare class Telegram extends ApiClient {
690
690
  */
691
691
  sendRichMessageDraft(chatId: number, draftId: number, richMessage: tg.InputRichMessage, extra?: tt.ExtraSendRichMessageDraft): Promise<never>;
692
692
  /**
693
- * Edit a sent rich message.
693
+ * Universal editRichMessage to update text or media captions in-place with Omni-Format support.
694
+ * Auto-detects Text vs Media Caption and gracefully handles 'message is not modified'.
694
695
  */
695
- editRichMessage(chatId: number | string | undefined, messageId: number | undefined, inlineMessageId: string | undefined, richMessage: tg.InputRichMessage, extra?: object): Promise<never>;
696
+ editRichMessage(chatId: number | string | undefined, messageId: number | string | undefined, content: any, extra?: any): Promise<any>;
697
+ editRichMessage(chatId: number | string | undefined, messageId: number | string | undefined, inlineMessageId: string | undefined, content: any, extra?: any): Promise<any>;
696
698
  }
697
699
  export default Telegram;
package/src/filters.js DELETED
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.allOf = exports.anyOf = exports.callbackQuery = exports.editedChannelPost = exports.channelPost = exports.editedMessage = exports.message = void 0;
4
- const message = (...keys) => (update) => {
5
- if (!('message' in update))
6
- return false;
7
- for (const key of keys) {
8
- if (!(key in update.message))
9
- return false;
10
- }
11
- return true;
12
- };
13
- exports.message = message;
14
- const editedMessage = (...keys) => (update) => {
15
- if (!('edited_message' in update))
16
- return false;
17
- for (const key of keys) {
18
- if (!(key in update.edited_message))
19
- return false;
20
- }
21
- return true;
22
- };
23
- exports.editedMessage = editedMessage;
24
- const channelPost = (...keys) => (update) => {
25
- if (!('channel_post' in update))
26
- return false;
27
- for (const key of keys) {
28
- if (!(key in update.channel_post))
29
- return false;
30
- }
31
- return true;
32
- };
33
- exports.channelPost = channelPost;
34
- const editedChannelPost = (...keys) => (update) => {
35
- if (!('edited_channel_post' in update))
36
- return false;
37
- for (const key of keys) {
38
- if (!(key in update.edited_channel_post))
39
- return false;
40
- }
41
- return true;
42
- };
43
- exports.editedChannelPost = editedChannelPost;
44
- const callbackQuery = (...keys) => (update) => {
45
- if (!('callback_query' in update))
46
- return false;
47
- for (const key of keys) {
48
- if (!(key in update.callback_query))
49
- return false;
50
- }
51
- return true;
52
- };
53
- exports.callbackQuery = callbackQuery;
54
- /** Any of the provided filters must match */
55
- const anyOf = (...filters) => (update) => {
56
- for (const filter of filters)
57
- if (filter(update))
58
- return true;
59
- return false;
60
- };
61
- exports.anyOf = anyOf;
62
- /** All of the provided filters must match */
63
- const allOf = (...filters) => (update) => {
64
- for (const filter of filters)
65
- if (!filter(update))
66
- return false;
67
- return true;
68
- };
69
- exports.allOf = allOf;
package/src/format.js DELETED
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mention = exports.link = exports.pre = exports.code = exports.quote = exports.underline = exports.strikethrough = exports.spoiler = exports.italic = exports.bold = exports.fmt = exports.join = exports.FmtString = void 0;
4
- const formatting_1 = require("./core/helpers/formatting");
5
- Object.defineProperty(exports, "FmtString", { enumerable: true, get: function () { return formatting_1.FmtString; } });
6
- // Nests<A, B> means the function will return A, and it can nest B
7
- // Nests<'fmt', string> means it will nest anything
8
- // Nests<'code', never> means it will not nest anything
9
- // Allowing everything to nest 'fmt' is a necessary evil; it allows to indirectly nest illegal entities
10
- // Except for 'code' and 'pre', which don't nest anything anyway, so they only deal with strings
11
- exports.join = formatting_1.join;
12
- exports.fmt = (0, formatting_1.createFmt)();
13
- exports.bold = (0, formatting_1.createFmt)('bold');
14
- exports.italic = (0, formatting_1.createFmt)('italic');
15
- exports.spoiler = (0, formatting_1.createFmt)('spoiler');
16
- exports.strikethrough =
17
- //
18
- (0, formatting_1.createFmt)('strikethrough');
19
- exports.underline =
20
- //
21
- (0, formatting_1.createFmt)('underline');
22
- exports.quote =
23
- //
24
- (0, formatting_1.createFmt)('blockquote');
25
- exports.code = (0, formatting_1.createFmt)('code');
26
- const pre = (language) => (0, formatting_1.createFmt)('pre', { language });
27
- exports.pre = pre;
28
- const link = (content, url) =>
29
- //
30
- (0, formatting_1.linkOrMention)(content, { type: 'text_link', url });
31
- exports.link = link;
32
- const mention = (name, user) => typeof user === 'number'
33
- ? (0, exports.link)(name, 'tg://user?id=' + user)
34
- : (0, formatting_1.linkOrMention)(name, {
35
- type: 'text_mention',
36
- user,
37
- });
38
- exports.mention = mention;
package/src/future.js DELETED
@@ -1,147 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useNewReplies = void 0;
4
- function makeReply(ctx, extra) {
5
- if (ctx.msgId)
6
- return Object.assign({
7
- // overrides in this order so user can override all properties
8
- reply_parameters: Object.assign({ message_id: ctx.msgId }, extra === null || extra === void 0 ? void 0 : extra.reply_parameters) }, extra);
9
- else
10
- return extra;
11
- }
12
- const replyContext = {
13
- replyWithChatAction: function () {
14
- throw new TypeError('ctx.replyWithChatAction has been removed, use ctx.sendChatAction instead');
15
- },
16
- reply(text, extra) {
17
- this.assert(this.chat, 'reply');
18
- return this.telegram.sendMessage(this.chat.id, text, makeReply(this, extra));
19
- },
20
- replyWithAnimation(animation, extra) {
21
- this.assert(this.chat, 'replyWithAnimation');
22
- return this.telegram.sendAnimation(this.chat.id, animation, makeReply(this, extra));
23
- },
24
- replyWithAudio(audio, extra) {
25
- this.assert(this.chat, 'replyWithAudio');
26
- return this.telegram.sendAudio(this.chat.id, audio, makeReply(this, extra));
27
- },
28
- replyWithContact(phoneNumber, firstName, extra) {
29
- this.assert(this.chat, 'replyWithContact');
30
- return this.telegram.sendContact(this.chat.id, phoneNumber, firstName, makeReply(this, extra));
31
- },
32
- replyWithDice(extra) {
33
- this.assert(this.chat, 'replyWithDice');
34
- return this.telegram.sendDice(this.chat.id, makeReply(this, extra));
35
- },
36
- replyWithDocument(document, extra) {
37
- this.assert(this.chat, 'replyWithDocument');
38
- return this.telegram.sendDocument(this.chat.id, document, makeReply(this, extra));
39
- },
40
- replyWithGame(gameName, extra) {
41
- this.assert(this.chat, 'replyWithGame');
42
- return this.telegram.sendGame(this.chat.id, gameName, makeReply(this, extra));
43
- },
44
- replyWithHTML(html, extra) {
45
- this.assert(this.chat, 'replyWithHTML');
46
- return this.telegram.sendMessage(this.chat.id, html, Object.assign({ parse_mode: 'HTML' }, makeReply(this, extra)));
47
- },
48
- replyWithInvoice(invoice, extra) {
49
- this.assert(this.chat, 'replyWithInvoice');
50
- return this.telegram.sendInvoice(this.chat.id, invoice, makeReply(this, extra));
51
- },
52
- replyWithLocation(latitude, longitude, extra) {
53
- this.assert(this.chat, 'replyWithLocation');
54
- return this.telegram.sendLocation(this.chat.id, latitude, longitude, makeReply(this, extra));
55
- },
56
- replyWithMarkdown(markdown, extra) {
57
- this.assert(this.chat, 'replyWithMarkdown');
58
- return this.telegram.sendMessage(this.chat.id, markdown, Object.assign({ parse_mode: 'Markdown' }, makeReply(this, extra)));
59
- },
60
- replyWithMarkdownV2(markdown, extra) {
61
- this.assert(this.chat, 'replyWithMarkdownV2');
62
- return this.telegram.sendMessage(this.chat.id, markdown, Object.assign({ parse_mode: 'MarkdownV2' }, makeReply(this, extra)));
63
- },
64
- replyWithMediaGroup(media, extra) {
65
- this.assert(this.chat, 'replyWithMediaGroup');
66
- return this.telegram.sendMediaGroup(this.chat.id, media, makeReply(this, extra));
67
- },
68
- replyWithPhoto(photo, extra) {
69
- this.assert(this.chat, 'replyWithPhoto');
70
- return this.telegram.sendPhoto(this.chat.id, photo, makeReply(this, extra));
71
- },
72
- replyWithPoll(question, options, extra) {
73
- this.assert(this.chat, 'replyWithPoll');
74
- return this.telegram.sendPoll(this.chat.id, question, options, makeReply(this, extra));
75
- },
76
- replyWithQuiz(question, options, extra) {
77
- this.assert(this.chat, 'replyWithQuiz');
78
- return this.telegram.sendQuiz(this.chat.id, question, options, makeReply(this, extra));
79
- },
80
- replyWithSticker(sticker, extra) {
81
- this.assert(this.chat, 'replyWithSticker');
82
- return this.telegram.sendSticker(this.chat.id, sticker, makeReply(this, extra));
83
- },
84
- replyWithVenue(latitude, longitude, title, address, extra) {
85
- this.assert(this.chat, 'replyWithVenue');
86
- return this.telegram.sendVenue(this.chat.id, latitude, longitude, title, address, makeReply(this, extra));
87
- },
88
- replyWithVideo(video, extra) {
89
- this.assert(this.chat, 'replyWithVideo');
90
- return this.telegram.sendVideo(this.chat.id, video, makeReply(this, extra));
91
- },
92
- replyWithVideoNote(videoNote, extra) {
93
- this.assert(this.chat, 'replyWithVideoNote');
94
- return this.telegram.sendVideoNote(this.chat.id, videoNote, makeReply(this, extra));
95
- },
96
- replyWithVoice(voice, extra) {
97
- this.assert(this.chat, 'replyWithVoice');
98
- return this.telegram.sendVoice(this.chat.id, voice, makeReply(this, extra));
99
- },
100
- replyWithRichMessage(options) {
101
- this.assert(this.chat, 'replyWithRichMessage');
102
- const { text, parseMode = 'HTML', buttons, disableLinkPreview, extra } = options;
103
- return this.telegram.sendMessage(this.chat.id, text, makeReply(this, Object.assign({ parse_mode: parseMode, link_preview_options: disableLinkPreview ? { is_disabled: true } : undefined, reply_markup: (buttons === null || buttons === void 0 ? void 0 : buttons.length) ? { inline_keyboard: buttons } : undefined }, extra)));
104
- },
105
- replyWithRichMessageContent(richMessage, extra) {
106
- this.assert(this.chat, 'replyWithRichMessageContent');
107
- return this.telegram.sendRichMessage(this.chat.id, richMessage, makeReply(this, extra));
108
- },
109
- };
110
- /**
111
- * Sets up Context to use the new reply methods.
112
- * This middleware makes `ctx.reply()` and `ctx.replyWith*()` methods will actually reply to the message they are replying to.
113
- * Use `ctx.sendMessage()` to send a message in chat without replying to it.
114
- *
115
- * If the message to reply is deleted, `reply()` will send a normal message.
116
- * If the update is not a message and we are unable to reply, `reply()` will send a normal message.
117
- */
118
- function useNewReplies() {
119
- return (ctx, next) => {
120
- ctx.reply = replyContext.reply;
121
- ctx.replyWithPhoto = replyContext.replyWithPhoto;
122
- ctx.replyWithMediaGroup = replyContext.replyWithMediaGroup;
123
- ctx.replyWithAudio = replyContext.replyWithAudio;
124
- ctx.replyWithDice = replyContext.replyWithDice;
125
- ctx.replyWithDocument = replyContext.replyWithDocument;
126
- ctx.replyWithSticker = replyContext.replyWithSticker;
127
- ctx.replyWithVideo = replyContext.replyWithVideo;
128
- ctx.replyWithAnimation = replyContext.replyWithAnimation;
129
- ctx.replyWithVideoNote = replyContext.replyWithVideoNote;
130
- ctx.replyWithInvoice = replyContext.replyWithInvoice;
131
- ctx.replyWithGame = replyContext.replyWithGame;
132
- ctx.replyWithVoice = replyContext.replyWithVoice;
133
- ctx.replyWithPoll = replyContext.replyWithPoll;
134
- ctx.replyWithQuiz = replyContext.replyWithQuiz;
135
- ctx.replyWithChatAction = replyContext.replyWithChatAction;
136
- ctx.replyWithLocation = replyContext.replyWithLocation;
137
- ctx.replyWithVenue = replyContext.replyWithVenue;
138
- ctx.replyWithContact = replyContext.replyWithContact;
139
- ctx.replyWithMarkdown = replyContext.replyWithMarkdown;
140
- ctx.replyWithMarkdownV2 = replyContext.replyWithMarkdownV2;
141
- ctx.replyWithHTML = replyContext.replyWithHTML;
142
- ctx.replyWithRichMessage = replyContext.replyWithRichMessage;
143
- ctx.replyWithRichMessageContent = replyContext.replyWithRichMessageContent;
144
- return next();
145
- };
146
- }
147
- exports.useNewReplies = useNewReplies;
package/src/markup.js DELETED
@@ -1,93 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.inlineKeyboard = exports.keyboard = exports.forceReply = exports.removeKeyboard = exports.button = exports.Markup = void 0;
27
- const check_1 = require("./core/helpers/check");
28
- class Markup {
29
- constructor(reply_markup) {
30
- this.reply_markup = reply_markup;
31
- }
32
- selective(value = true) {
33
- return new Markup(Object.assign(Object.assign({}, this.reply_markup), { selective: value }));
34
- }
35
- placeholder(placeholder) {
36
- return new Markup(Object.assign(Object.assign({}, this.reply_markup), { input_field_placeholder: placeholder }));
37
- }
38
- resize(value = true) {
39
- return new Markup(Object.assign(Object.assign({}, this.reply_markup), { resize_keyboard: value }));
40
- }
41
- oneTime(value = true) {
42
- return new Markup(Object.assign(Object.assign({}, this.reply_markup), { one_time_keyboard: value }));
43
- }
44
- persistent(value = true) {
45
- return new Markup(Object.assign(Object.assign({}, this.reply_markup), { is_persistent: value }));
46
- }
47
- }
48
- exports.Markup = Markup;
49
- exports.button = __importStar(require("./button"));
50
- function removeKeyboard() {
51
- return new Markup({ remove_keyboard: true });
52
- }
53
- exports.removeKeyboard = removeKeyboard;
54
- function forceReply() {
55
- return new Markup({ force_reply: true });
56
- }
57
- exports.forceReply = forceReply;
58
- function keyboard(buttons, options) {
59
- const keyboard = buildKeyboard(buttons, Object.assign({ columns: 1 }, options));
60
- return new Markup({ keyboard });
61
- }
62
- exports.keyboard = keyboard;
63
- function inlineKeyboard(buttons, options) {
64
- const inlineKeyboard = buildKeyboard(buttons, Object.assign({ columns: buttons.length }, options));
65
- return new Markup({ inline_keyboard: inlineKeyboard });
66
- }
67
- exports.inlineKeyboard = inlineKeyboard;
68
- function buildKeyboard(buttons, options) {
69
- const result = [];
70
- if (!Array.isArray(buttons)) {
71
- return result;
72
- }
73
- if ((0, check_1.is2D)(buttons)) {
74
- return buttons.map((row) => row.filter((button) => !button.hide));
75
- }
76
- const wrapFn = options.wrap !== undefined
77
- ? options.wrap
78
- : (_btn, _index, currentRow) => currentRow.length >= options.columns;
79
- let currentRow = [];
80
- let index = 0;
81
- for (const btn of buttons.filter((button) => !button.hide)) {
82
- if (wrapFn(btn, index, currentRow) && currentRow.length > 0) {
83
- result.push(currentRow);
84
- currentRow = [];
85
- }
86
- currentRow.push(btn);
87
- index++;
88
- }
89
- if (currentRow.length > 0) {
90
- result.push(currentRow);
91
- }
92
- return result;
93
- }
package/src/scenes.js DELETED
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./scenes/index.js"), exports);