1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.useNewReplies = void 0;
|
4 | function makeReply(ctx, extra) {
|
5 | var _a;
|
6 | const reply_to_message_id = (_a = ctx.message) === null || _a === void 0 ? void 0 : _a.message_id;
|
7 | return { reply_to_message_id, ...extra };
|
8 | }
|
9 | const replyContext = {
|
10 | replyWithChatAction: function () {
|
11 | throw new TypeError('ctx.replyWithChatAction has been removed, use ctx.sendChatAction instead');
|
12 | },
|
13 | reply(text, extra) {
|
14 | this.assert(this.chat, 'reply');
|
15 | return this.telegram.sendMessage(this.chat.id, text, makeReply(this, extra));
|
16 | },
|
17 | replyWithAnimation(animation, extra) {
|
18 | this.assert(this.chat, 'replyWithAnimation');
|
19 | return this.telegram.sendAnimation(this.chat.id, animation, makeReply(this, extra));
|
20 | },
|
21 | replyWithAudio(audio, extra) {
|
22 | this.assert(this.chat, 'replyWithAudio');
|
23 | return this.telegram.sendAudio(this.chat.id, audio, makeReply(this, extra));
|
24 | },
|
25 | replyWithContact(phoneNumber, firstName, extra) {
|
26 | this.assert(this.chat, 'replyWithContact');
|
27 | return this.telegram.sendContact(this.chat.id, phoneNumber, firstName, makeReply(this, extra));
|
28 | },
|
29 | replyWithDice(extra) {
|
30 | this.assert(this.chat, 'replyWithDice');
|
31 | return this.telegram.sendDice(this.chat.id, makeReply(this, extra));
|
32 | },
|
33 | replyWithDocument(document, extra) {
|
34 | this.assert(this.chat, 'replyWithDocument');
|
35 | return this.telegram.sendDocument(this.chat.id, document, makeReply(this, extra));
|
36 | },
|
37 | replyWithGame(gameName, extra) {
|
38 | this.assert(this.chat, 'replyWithGame');
|
39 | return this.telegram.sendGame(this.chat.id, gameName, makeReply(this, extra));
|
40 | },
|
41 | replyWithHTML(html, extra) {
|
42 | var _a;
|
43 | this.assert(this.chat, 'replyWithHTML');
|
44 | return this.telegram.sendMessage(this.chat.id, html, {
|
45 | parse_mode: 'HTML',
|
46 | reply_to_message_id: (_a = this.message) === null || _a === void 0 ? void 0 : _a.message_id,
|
47 | ...extra,
|
48 | });
|
49 | },
|
50 | replyWithInvoice(invoice, extra) {
|
51 | this.assert(this.chat, 'replyWithInvoice');
|
52 | return this.telegram.sendInvoice(this.chat.id, invoice, makeReply(this, extra));
|
53 | },
|
54 | replyWithLocation(latitude, longitude, extra) {
|
55 | this.assert(this.chat, 'replyWithLocation');
|
56 | return this.telegram.sendLocation(this.chat.id, latitude, longitude, makeReply(this, extra));
|
57 | },
|
58 | replyWithMarkdown(markdown, extra) {
|
59 | var _a;
|
60 | this.assert(this.chat, 'replyWithMarkdown');
|
61 | return this.telegram.sendMessage(this.chat.id, markdown, {
|
62 | parse_mode: 'Markdown',
|
63 | reply_to_message_id: (_a = this.message) === null || _a === void 0 ? void 0 : _a.message_id,
|
64 | ...extra,
|
65 | });
|
66 | },
|
67 | replyWithMarkdownV2(markdown, extra) {
|
68 | var _a;
|
69 | this.assert(this.chat, 'replyWithMarkdownV2');
|
70 | return this.telegram.sendMessage(this.chat.id, markdown, {
|
71 | parse_mode: 'MarkdownV2',
|
72 | reply_to_message_id: (_a = this.message) === null || _a === void 0 ? void 0 : _a.message_id,
|
73 | ...extra,
|
74 | });
|
75 | },
|
76 | replyWithMediaGroup(media, extra) {
|
77 | this.assert(this.chat, 'replyWithMediaGroup');
|
78 | return this.telegram.sendMediaGroup(this.chat.id, media, makeReply(this, extra));
|
79 | },
|
80 | replyWithPhoto(photo, extra) {
|
81 | this.assert(this.chat, 'replyWithPhoto');
|
82 | return this.telegram.sendPhoto(this.chat.id, photo, makeReply(this, extra));
|
83 | },
|
84 | replyWithPoll(question, options, extra) {
|
85 | this.assert(this.chat, 'replyWithPoll');
|
86 | return this.telegram.sendPoll(this.chat.id, question, options, makeReply(this, extra));
|
87 | },
|
88 | replyWithQuiz(question, options, extra) {
|
89 | this.assert(this.chat, 'replyWithQuiz');
|
90 | return this.telegram.sendQuiz(this.chat.id, question, options, makeReply(this, extra));
|
91 | },
|
92 | replyWithSticker(sticker, extra) {
|
93 | this.assert(this.chat, 'replyWithSticker');
|
94 | return this.telegram.sendSticker(this.chat.id, sticker, makeReply(this, extra));
|
95 | },
|
96 | replyWithVenue(latitude, longitude, title, address, extra) {
|
97 | this.assert(this.chat, 'replyWithVenue');
|
98 | return this.telegram.sendVenue(this.chat.id, latitude, longitude, title, address, makeReply(this, extra));
|
99 | },
|
100 | replyWithVideo(video, extra) {
|
101 | this.assert(this.chat, 'replyWithVideo');
|
102 | return this.telegram.sendVideo(this.chat.id, video, makeReply(this, extra));
|
103 | },
|
104 | replyWithVideoNote(videoNote, extra) {
|
105 | this.assert(this.chat, 'replyWithVideoNote');
|
106 | return this.telegram.sendVideoNote(this.chat.id, videoNote, makeReply(this, extra));
|
107 | },
|
108 | replyWithVoice(voice, extra) {
|
109 | this.assert(this.chat, 'replyWithVoice');
|
110 | return this.telegram.sendVoice(this.chat.id, voice, makeReply(this, extra));
|
111 | },
|
112 | };
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 | function useNewReplies() {
|
122 | return (ctx, next) => {
|
123 | ctx.reply = replyContext.reply;
|
124 | ctx.replyWithPhoto = replyContext.replyWithPhoto;
|
125 | ctx.replyWithMediaGroup = replyContext.replyWithMediaGroup;
|
126 | ctx.replyWithAudio = replyContext.replyWithAudio;
|
127 | ctx.replyWithDice = replyContext.replyWithDice;
|
128 | ctx.replyWithDocument = replyContext.replyWithDocument;
|
129 | ctx.replyWithSticker = replyContext.replyWithSticker;
|
130 | ctx.replyWithVideo = replyContext.replyWithVideo;
|
131 | ctx.replyWithAnimation = replyContext.replyWithAnimation;
|
132 | ctx.replyWithVideoNote = replyContext.replyWithVideoNote;
|
133 | ctx.replyWithInvoice = replyContext.replyWithInvoice;
|
134 | ctx.replyWithGame = replyContext.replyWithGame;
|
135 | ctx.replyWithVoice = replyContext.replyWithVoice;
|
136 | ctx.replyWithPoll = replyContext.replyWithPoll;
|
137 | ctx.replyWithQuiz = replyContext.replyWithQuiz;
|
138 | ctx.replyWithChatAction = replyContext.replyWithChatAction;
|
139 | ctx.replyWithLocation = replyContext.replyWithLocation;
|
140 | ctx.replyWithVenue = replyContext.replyWithVenue;
|
141 | ctx.replyWithContact = replyContext.replyWithContact;
|
142 | ctx.replyWithMarkdown = replyContext.replyWithMarkdown;
|
143 | ctx.replyWithMarkdownV2 = replyContext.replyWithMarkdownV2;
|
144 | ctx.replyWithHTML = replyContext.replyWithHTML;
|
145 | return next();
|
146 | };
|
147 | }
|
148 | exports.useNewReplies = useNewReplies;
|