@tgify/tgify 0.1.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.
- package/LICENSE +23 -0
- package/README.md +356 -0
- package/filters.d.ts +1 -0
- package/filters.js +1 -0
- package/format.d.ts +1 -0
- package/format.js +1 -0
- package/future.d.ts +1 -0
- package/future.js +1 -0
- package/lib/button.js +100 -0
- package/lib/cli.mjs +105 -0
- package/lib/composer.js +582 -0
- package/lib/context.js +1219 -0
- package/lib/core/helpers/args.js +57 -0
- package/lib/core/helpers/check.js +55 -0
- package/lib/core/helpers/compact.js +16 -0
- package/lib/core/helpers/deunionize.js +12 -0
- package/lib/core/helpers/formatting.js +91 -0
- package/lib/core/helpers/util.js +50 -0
- package/lib/core/network/client.js +330 -0
- package/lib/core/network/error.js +21 -0
- package/lib/core/network/multipart-stream.js +71 -0
- package/lib/core/network/polling.js +87 -0
- package/lib/core/network/webhook.js +54 -0
- package/lib/core/types/typegram.js +27 -0
- package/lib/filters.js +69 -0
- package/lib/format.js +38 -0
- package/lib/future.js +149 -0
- package/lib/index.js +58 -0
- package/lib/input.js +61 -0
- package/lib/markup.js +121 -0
- package/lib/middleware.js +2 -0
- package/lib/reactions.js +84 -0
- package/lib/router.js +46 -0
- package/lib/scenes/base.js +39 -0
- package/lib/scenes/context.js +104 -0
- package/lib/scenes/index.js +21 -0
- package/lib/scenes/stage.js +49 -0
- package/lib/scenes/wizard/context.js +31 -0
- package/lib/scenes/wizard/index.js +45 -0
- package/lib/scenes.js +17 -0
- package/lib/session.js +166 -0
- package/lib/telegraf.js +256 -0
- package/lib/telegram-types.js +6 -0
- package/lib/telegram.js +1240 -0
- package/lib/types.js +2 -0
- package/lib/utils.js +5 -0
- package/markup.d.ts +1 -0
- package/markup.js +1 -0
- package/package.json +140 -0
- package/scenes.d.ts +1 -0
- package/scenes.js +1 -0
- package/session.d.ts +1 -0
- package/session.js +1 -0
- package/src/button.ts +182 -0
- package/src/composer.ts +1008 -0
- package/src/context.ts +1661 -0
- package/src/core/helpers/args.ts +63 -0
- package/src/core/helpers/check.ts +71 -0
- package/src/core/helpers/compact.ts +18 -0
- package/src/core/helpers/deunionize.ts +26 -0
- package/src/core/helpers/formatting.ts +119 -0
- package/src/core/helpers/util.ts +96 -0
- package/src/core/network/client.ts +396 -0
- package/src/core/network/error.ts +29 -0
- package/src/core/network/multipart-stream.ts +45 -0
- package/src/core/network/polling.ts +94 -0
- package/src/core/network/webhook.ts +58 -0
- package/src/core/types/typegram.ts +54 -0
- package/src/filters.ts +109 -0
- package/src/format.ts +110 -0
- package/src/future.ts +213 -0
- package/src/index.ts +17 -0
- package/src/input.ts +59 -0
- package/src/markup.ts +142 -0
- package/src/middleware.ts +24 -0
- package/src/reactions.ts +118 -0
- package/src/router.ts +55 -0
- package/src/scenes/base.ts +52 -0
- package/src/scenes/context.ts +136 -0
- package/src/scenes/index.ts +21 -0
- package/src/scenes/stage.ts +71 -0
- package/src/scenes/wizard/context.ts +58 -0
- package/src/scenes/wizard/index.ts +63 -0
- package/src/scenes.ts +1 -0
- package/src/session.ts +204 -0
- package/src/telegraf.ts +354 -0
- package/src/telegram-types.ts +219 -0
- package/src/telegram.ts +1635 -0
- package/src/types.ts +2 -0
- package/src/utils.ts +1 -0
- package/types.d.ts +1 -0
- package/types.js +1 -0
- package/typings/button.d.ts +36 -0
- package/typings/button.d.ts.map +1 -0
- package/typings/composer.d.ts +227 -0
- package/typings/composer.d.ts.map +1 -0
- package/typings/context.d.ts +655 -0
- package/typings/context.d.ts.map +1 -0
- package/typings/core/helpers/args.d.ts +11 -0
- package/typings/core/helpers/args.d.ts.map +1 -0
- package/typings/core/helpers/check.d.ts +56 -0
- package/typings/core/helpers/check.d.ts.map +1 -0
- package/typings/core/helpers/compact.d.ts +4 -0
- package/typings/core/helpers/compact.d.ts.map +1 -0
- package/typings/core/helpers/deunionize.d.ts +18 -0
- package/typings/core/helpers/deunionize.d.ts.map +1 -0
- package/typings/core/helpers/formatting.d.ts +30 -0
- package/typings/core/helpers/formatting.d.ts.map +1 -0
- package/typings/core/helpers/util.d.ts +26 -0
- package/typings/core/helpers/util.d.ts.map +1 -0
- package/typings/core/network/client.d.ts +53 -0
- package/typings/core/network/client.d.ts.map +1 -0
- package/typings/core/network/error.d.ts +16 -0
- package/typings/core/network/error.d.ts.map +1 -0
- package/typings/core/network/multipart-stream.d.ts +16 -0
- package/typings/core/network/multipart-stream.d.ts.map +1 -0
- package/typings/core/network/polling.d.ts +16 -0
- package/typings/core/network/polling.d.ts.map +1 -0
- package/typings/core/network/webhook.d.ts +6 -0
- package/typings/core/network/webhook.d.ts.map +1 -0
- package/typings/core/types/typegram.d.ts +42 -0
- package/typings/core/types/typegram.d.ts.map +1 -0
- package/typings/filters.d.ts +18 -0
- package/typings/filters.d.ts.map +1 -0
- package/typings/format.d.ts +22 -0
- package/typings/format.d.ts.map +1 -0
- package/typings/future.d.ts +12 -0
- package/typings/future.d.ts.map +1 -0
- package/typings/index.d.ts +15 -0
- package/typings/index.d.ts.map +1 -0
- package/typings/input.d.ts +50 -0
- package/typings/input.d.ts.map +1 -0
- package/typings/markup.d.ts +27 -0
- package/typings/markup.d.ts.map +1 -0
- package/typings/middleware.d.ts +8 -0
- package/typings/middleware.d.ts.map +1 -0
- package/typings/reactions.d.ts +32 -0
- package/typings/reactions.d.ts.map +1 -0
- package/typings/router.d.ts +21 -0
- package/typings/router.d.ts.map +1 -0
- package/typings/scenes/base.d.ts +22 -0
- package/typings/scenes/base.d.ts.map +1 -0
- package/typings/scenes/context.d.ts +36 -0
- package/typings/scenes/context.d.ts.map +1 -0
- package/typings/scenes/index.d.ts +11 -0
- package/typings/scenes/index.d.ts.map +1 -0
- package/typings/scenes/stage.d.ts +24 -0
- package/typings/scenes/stage.d.ts.map +1 -0
- package/typings/scenes/wizard/context.d.ts +29 -0
- package/typings/scenes/wizard/context.d.ts.map +1 -0
- package/typings/scenes/wizard/index.d.ts +16 -0
- package/typings/scenes/wizard/index.d.ts.map +1 -0
- package/typings/scenes.d.ts +2 -0
- package/typings/scenes.d.ts.map +1 -0
- package/typings/session.d.ts +55 -0
- package/typings/session.d.ts.map +1 -0
- package/typings/telegraf.d.ts +115 -0
- package/typings/telegraf.d.ts.map +1 -0
- package/typings/telegram-types.d.ts +117 -0
- package/typings/telegram-types.d.ts.map +1 -0
- package/typings/telegram.d.ts +675 -0
- package/typings/telegram.d.ts.map +1 -0
- package/typings/types.d.ts +3 -0
- package/typings/types.d.ts.map +1 -0
- package/typings/utils.d.ts +2 -0
- package/typings/utils.d.ts.map +1 -0
- package/utils.d.ts +1 -0
- package/utils.js +1 -0
package/lib/context.js
ADDED
|
@@ -0,0 +1,1219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Context = void 0;
|
|
7
|
+
const debug_1 = __importDefault(require("debug"));
|
|
8
|
+
const reactions_1 = require("./reactions");
|
|
9
|
+
const debug = (0, debug_1.default)('telegraf:context');
|
|
10
|
+
class Context {
|
|
11
|
+
constructor(update, telegram, botInfo) {
|
|
12
|
+
this.update = update;
|
|
13
|
+
this.telegram = telegram;
|
|
14
|
+
this.botInfo = botInfo;
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
this.state = {};
|
|
17
|
+
}
|
|
18
|
+
get updateType() {
|
|
19
|
+
for (const key in this.update) {
|
|
20
|
+
if (typeof this.update[key] === 'object')
|
|
21
|
+
return key;
|
|
22
|
+
}
|
|
23
|
+
throw new Error(`Cannot determine \`updateType\` of ${JSON.stringify(this.update)}`);
|
|
24
|
+
}
|
|
25
|
+
get me() {
|
|
26
|
+
var _a;
|
|
27
|
+
return (_a = this.botInfo) === null || _a === void 0 ? void 0 : _a.username;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated Use ctx.telegram instead
|
|
31
|
+
*/
|
|
32
|
+
get tg() {
|
|
33
|
+
return this.telegram;
|
|
34
|
+
}
|
|
35
|
+
get message() {
|
|
36
|
+
return this.update.message;
|
|
37
|
+
}
|
|
38
|
+
get editedMessage() {
|
|
39
|
+
return this.update.edited_message;
|
|
40
|
+
}
|
|
41
|
+
get inlineQuery() {
|
|
42
|
+
return this.update.inline_query;
|
|
43
|
+
}
|
|
44
|
+
get shippingQuery() {
|
|
45
|
+
return this.update.shipping_query;
|
|
46
|
+
}
|
|
47
|
+
get preCheckoutQuery() {
|
|
48
|
+
return this.update.pre_checkout_query;
|
|
49
|
+
}
|
|
50
|
+
get chosenInlineResult() {
|
|
51
|
+
return this.update.chosen_inline_result;
|
|
52
|
+
}
|
|
53
|
+
get channelPost() {
|
|
54
|
+
return this.update.channel_post;
|
|
55
|
+
}
|
|
56
|
+
get editedChannelPost() {
|
|
57
|
+
return this.update.edited_channel_post;
|
|
58
|
+
}
|
|
59
|
+
get messageReaction() {
|
|
60
|
+
return this.update.message_reaction;
|
|
61
|
+
}
|
|
62
|
+
get messageReactionCount() {
|
|
63
|
+
return this.update.message_reaction_count;
|
|
64
|
+
}
|
|
65
|
+
get callbackQuery() {
|
|
66
|
+
return this.update.callback_query;
|
|
67
|
+
}
|
|
68
|
+
get poll() {
|
|
69
|
+
return this.update.poll;
|
|
70
|
+
}
|
|
71
|
+
get pollAnswer() {
|
|
72
|
+
return this.update.poll_answer;
|
|
73
|
+
}
|
|
74
|
+
get myChatMember() {
|
|
75
|
+
return this.update.my_chat_member;
|
|
76
|
+
}
|
|
77
|
+
get chatMember() {
|
|
78
|
+
return this.update.chat_member;
|
|
79
|
+
}
|
|
80
|
+
get chatJoinRequest() {
|
|
81
|
+
return this.update.chat_join_request;
|
|
82
|
+
}
|
|
83
|
+
get chatBoost() {
|
|
84
|
+
return this.update.chat_boost;
|
|
85
|
+
}
|
|
86
|
+
get removedChatBoost() {
|
|
87
|
+
return this.update.removed_chat_boost;
|
|
88
|
+
}
|
|
89
|
+
/** Shorthand for any `message` object present in the current update. One of
|
|
90
|
+
* `message`, `edited_message`, `channel_post`, `edited_channel_post` or
|
|
91
|
+
* `callback_query.message`
|
|
92
|
+
*/
|
|
93
|
+
get msg() {
|
|
94
|
+
return getMessageFromAnySource(this);
|
|
95
|
+
}
|
|
96
|
+
/** Shorthand for any message_id present in the current update. */
|
|
97
|
+
get msgId() {
|
|
98
|
+
return getMsgIdFromAnySource(this);
|
|
99
|
+
}
|
|
100
|
+
get chat() {
|
|
101
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
102
|
+
return (_g = ((_f = (_e = (_d = (_c = (_b = (_a = this.msg) !== null && _a !== void 0 ? _a : this.messageReaction) !== null && _b !== void 0 ? _b : this.messageReactionCount) !== null && _c !== void 0 ? _c : this.chatJoinRequest) !== null && _d !== void 0 ? _d : this.chatMember) !== null && _e !== void 0 ? _e : this.myChatMember) !== null && _f !== void 0 ? _f : this.removedChatBoost)) === null || _g === void 0 ? void 0 : _g.chat;
|
|
103
|
+
}
|
|
104
|
+
get senderChat() {
|
|
105
|
+
const msg = this.msg;
|
|
106
|
+
return ((msg === null || msg === void 0 ? void 0 : msg.has('sender_chat')) && msg.sender_chat);
|
|
107
|
+
}
|
|
108
|
+
get from() {
|
|
109
|
+
return getUserFromAnySource(this);
|
|
110
|
+
}
|
|
111
|
+
get inlineMessageId() {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
return (_b = ((_a = this.callbackQuery) !== null && _a !== void 0 ? _a : this.chosenInlineResult)) === null || _b === void 0 ? void 0 : _b.inline_message_id;
|
|
114
|
+
}
|
|
115
|
+
get passportData() {
|
|
116
|
+
var _a;
|
|
117
|
+
if (this.message == null)
|
|
118
|
+
return undefined;
|
|
119
|
+
if (!('passport_data' in this.message))
|
|
120
|
+
return undefined;
|
|
121
|
+
return (_a = this.message) === null || _a === void 0 ? void 0 : _a.passport_data;
|
|
122
|
+
}
|
|
123
|
+
get webAppData() {
|
|
124
|
+
if (!(this.message && 'web_app_data' in this.message))
|
|
125
|
+
return undefined;
|
|
126
|
+
const { data, button_text } = this.message.web_app_data;
|
|
127
|
+
return {
|
|
128
|
+
data: {
|
|
129
|
+
json() {
|
|
130
|
+
return JSON.parse(data);
|
|
131
|
+
},
|
|
132
|
+
text() {
|
|
133
|
+
return data;
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
button_text,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated use {@link Telegram.webhookReply}
|
|
141
|
+
*/
|
|
142
|
+
get webhookReply() {
|
|
143
|
+
return this.telegram.webhookReply;
|
|
144
|
+
}
|
|
145
|
+
set webhookReply(enable) {
|
|
146
|
+
this.telegram.webhookReply = enable;
|
|
147
|
+
}
|
|
148
|
+
get reactions() {
|
|
149
|
+
return reactions_1.MessageReactions.from(this);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* @internal
|
|
153
|
+
*/
|
|
154
|
+
assert(value, method) {
|
|
155
|
+
if (value === undefined) {
|
|
156
|
+
throw new TypeError(`Telegraf: "${method}" isn't available for "${this.updateType}"`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
has(filters) {
|
|
160
|
+
if (!Array.isArray(filters))
|
|
161
|
+
filters = [filters];
|
|
162
|
+
for (const filter of filters)
|
|
163
|
+
if (
|
|
164
|
+
// TODO: this should change to === 'function' once TS bug is fixed
|
|
165
|
+
// https://github.com/microsoft/TypeScript/pull/51502
|
|
166
|
+
typeof filter !== 'string'
|
|
167
|
+
? // filter is a type guard
|
|
168
|
+
filter(this.update)
|
|
169
|
+
: // check if filter is the update type
|
|
170
|
+
filter in this.update)
|
|
171
|
+
return true;
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
get text() {
|
|
175
|
+
return getTextAndEntitiesFromAnySource(this)[0];
|
|
176
|
+
}
|
|
177
|
+
entities(...types) {
|
|
178
|
+
const [text = '', entities = []] = getTextAndEntitiesFromAnySource(this);
|
|
179
|
+
return (types.length
|
|
180
|
+
? entities.filter((entity) => types.includes(entity.type))
|
|
181
|
+
: entities).map((entity) => ({
|
|
182
|
+
...entity,
|
|
183
|
+
fragment: text.slice(entity.offset, entity.offset + entity.length),
|
|
184
|
+
}));
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* @see https://core.telegram.org/bots/api#answerinlinequery
|
|
188
|
+
*/
|
|
189
|
+
answerInlineQuery(...args) {
|
|
190
|
+
this.assert(this.inlineQuery, 'answerInlineQuery');
|
|
191
|
+
return this.telegram.answerInlineQuery(this.inlineQuery.id, ...args);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* @see https://core.telegram.org/bots/api#answercallbackquery
|
|
195
|
+
*/
|
|
196
|
+
answerCbQuery(...args) {
|
|
197
|
+
this.assert(this.callbackQuery, 'answerCbQuery');
|
|
198
|
+
return this.telegram.answerCbQuery(this.callbackQuery.id, ...args);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* @see https://core.telegram.org/bots/api#answercallbackquery
|
|
202
|
+
*/
|
|
203
|
+
answerGameQuery(...args) {
|
|
204
|
+
this.assert(this.callbackQuery, 'answerGameQuery');
|
|
205
|
+
return this.telegram.answerGameQuery(this.callbackQuery.id, ...args);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Shorthand for {@link Telegram.getUserChatBoosts}
|
|
209
|
+
*/
|
|
210
|
+
getUserChatBoosts() {
|
|
211
|
+
this.assert(this.chat, 'getUserChatBoosts');
|
|
212
|
+
this.assert(this.from, 'getUserChatBoosts');
|
|
213
|
+
return this.telegram.getUserChatBoosts(this.chat.id, this.from.id);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* @see https://core.telegram.org/bots/api#answershippingquery
|
|
217
|
+
*/
|
|
218
|
+
answerShippingQuery(...args) {
|
|
219
|
+
this.assert(this.shippingQuery, 'answerShippingQuery');
|
|
220
|
+
return this.telegram.answerShippingQuery(this.shippingQuery.id, ...args);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* @see https://core.telegram.org/bots/api#answerprecheckoutquery
|
|
224
|
+
*/
|
|
225
|
+
answerPreCheckoutQuery(...args) {
|
|
226
|
+
this.assert(this.preCheckoutQuery, 'answerPreCheckoutQuery');
|
|
227
|
+
return this.telegram.answerPreCheckoutQuery(this.preCheckoutQuery.id, ...args);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* @see https://core.telegram.org/bots/api#editmessagetext
|
|
231
|
+
*/
|
|
232
|
+
editMessageText(text, extra) {
|
|
233
|
+
var _a, _b;
|
|
234
|
+
this.assert((_a = this.msgId) !== null && _a !== void 0 ? _a : this.inlineMessageId, 'editMessageText');
|
|
235
|
+
return this.telegram.editMessageText((_b = this.chat) === null || _b === void 0 ? void 0 : _b.id, this.msgId, this.inlineMessageId, text, extra);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* @see https://core.telegram.org/bots/api#editmessagecaption
|
|
239
|
+
*/
|
|
240
|
+
editMessageCaption(caption, extra) {
|
|
241
|
+
var _a, _b;
|
|
242
|
+
this.assert((_a = this.msgId) !== null && _a !== void 0 ? _a : this.inlineMessageId, 'editMessageCaption');
|
|
243
|
+
return this.telegram.editMessageCaption((_b = this.chat) === null || _b === void 0 ? void 0 : _b.id, this.msgId, this.inlineMessageId, caption, extra);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* @see https://core.telegram.org/bots/api#editmessagemedia
|
|
247
|
+
*/
|
|
248
|
+
editMessageMedia(media, extra) {
|
|
249
|
+
var _a, _b;
|
|
250
|
+
this.assert((_a = this.msgId) !== null && _a !== void 0 ? _a : this.inlineMessageId, 'editMessageMedia');
|
|
251
|
+
return this.telegram.editMessageMedia((_b = this.chat) === null || _b === void 0 ? void 0 : _b.id, this.msgId, this.inlineMessageId, media, extra);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* @see https://core.telegram.org/bots/api#editmessagereplymarkup
|
|
255
|
+
*/
|
|
256
|
+
editMessageReplyMarkup(markup) {
|
|
257
|
+
var _a, _b;
|
|
258
|
+
this.assert((_a = this.msgId) !== null && _a !== void 0 ? _a : this.inlineMessageId, 'editMessageReplyMarkup');
|
|
259
|
+
return this.telegram.editMessageReplyMarkup((_b = this.chat) === null || _b === void 0 ? void 0 : _b.id, this.msgId, this.inlineMessageId, markup);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* @see https://core.telegram.org/bots/api#editmessagelivelocation
|
|
263
|
+
*/
|
|
264
|
+
editMessageLiveLocation(latitude, longitude, extra) {
|
|
265
|
+
var _a, _b;
|
|
266
|
+
this.assert((_a = this.msgId) !== null && _a !== void 0 ? _a : this.inlineMessageId, 'editMessageLiveLocation');
|
|
267
|
+
return this.telegram.editMessageLiveLocation((_b = this.chat) === null || _b === void 0 ? void 0 : _b.id, this.msgId, this.inlineMessageId, latitude, longitude, extra);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* @see https://core.telegram.org/bots/api#stopmessagelivelocation
|
|
271
|
+
*/
|
|
272
|
+
stopMessageLiveLocation(markup) {
|
|
273
|
+
var _a, _b;
|
|
274
|
+
this.assert((_a = this.msgId) !== null && _a !== void 0 ? _a : this.inlineMessageId, 'stopMessageLiveLocation');
|
|
275
|
+
return this.telegram.stopMessageLiveLocation((_b = this.chat) === null || _b === void 0 ? void 0 : _b.id, this.msgId, this.inlineMessageId, markup);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* @see https://core.telegram.org/bots/api#sendmessage
|
|
279
|
+
*/
|
|
280
|
+
sendMessage(text, extra) {
|
|
281
|
+
this.assert(this.chat, 'sendMessage');
|
|
282
|
+
return this.telegram.sendMessage(this.chat.id, text, {
|
|
283
|
+
message_thread_id: getThreadId(this),
|
|
284
|
+
...extra,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* @see https://core.telegram.org/bots/api#sendmessage
|
|
289
|
+
*/
|
|
290
|
+
reply(...args) {
|
|
291
|
+
return this.sendMessage(...args);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* @see https://core.telegram.org/bots/api#getchat
|
|
295
|
+
*/
|
|
296
|
+
getChat(...args) {
|
|
297
|
+
this.assert(this.chat, 'getChat');
|
|
298
|
+
return this.telegram.getChat(this.chat.id, ...args);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* @see https://core.telegram.org/bots/api#exportchatinvitelink
|
|
302
|
+
*/
|
|
303
|
+
exportChatInviteLink(...args) {
|
|
304
|
+
this.assert(this.chat, 'exportChatInviteLink');
|
|
305
|
+
return this.telegram.exportChatInviteLink(this.chat.id, ...args);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* @see https://core.telegram.org/bots/api#createchatinvitelink
|
|
309
|
+
*/
|
|
310
|
+
createChatInviteLink(...args) {
|
|
311
|
+
this.assert(this.chat, 'createChatInviteLink');
|
|
312
|
+
return this.telegram.createChatInviteLink(this.chat.id, ...args);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* @see https://core.telegram.org/bots/api#editchatinvitelink
|
|
316
|
+
*/
|
|
317
|
+
editChatInviteLink(...args) {
|
|
318
|
+
this.assert(this.chat, 'editChatInviteLink');
|
|
319
|
+
return this.telegram.editChatInviteLink(this.chat.id, ...args);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* @see https://core.telegram.org/bots/api#revokechatinvitelink
|
|
323
|
+
*/
|
|
324
|
+
revokeChatInviteLink(...args) {
|
|
325
|
+
this.assert(this.chat, 'revokeChatInviteLink');
|
|
326
|
+
return this.telegram.revokeChatInviteLink(this.chat.id, ...args);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* @see https://core.telegram.org/bots/api#banchatmember
|
|
330
|
+
*/
|
|
331
|
+
banChatMember(...args) {
|
|
332
|
+
this.assert(this.chat, 'banChatMember');
|
|
333
|
+
return this.telegram.banChatMember(this.chat.id, ...args);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* @see https://core.telegram.org/bots/api#banchatmember
|
|
337
|
+
* @deprecated since API 5.3. Use {@link Context.banChatMember}
|
|
338
|
+
*/
|
|
339
|
+
get kickChatMember() {
|
|
340
|
+
return this.banChatMember;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* @see https://core.telegram.org/bots/api#unbanchatmember
|
|
344
|
+
*/
|
|
345
|
+
unbanChatMember(...args) {
|
|
346
|
+
this.assert(this.chat, 'unbanChatMember');
|
|
347
|
+
return this.telegram.unbanChatMember(this.chat.id, ...args);
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* @see https://core.telegram.org/bots/api#restrictchatmember
|
|
351
|
+
*/
|
|
352
|
+
restrictChatMember(...args) {
|
|
353
|
+
this.assert(this.chat, 'restrictChatMember');
|
|
354
|
+
return this.telegram.restrictChatMember(this.chat.id, ...args);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* @see https://core.telegram.org/bots/api#promotechatmember
|
|
358
|
+
*/
|
|
359
|
+
promoteChatMember(...args) {
|
|
360
|
+
this.assert(this.chat, 'promoteChatMember');
|
|
361
|
+
return this.telegram.promoteChatMember(this.chat.id, ...args);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* @see https://core.telegram.org/bots/api#setchatadministratorcustomtitle
|
|
365
|
+
*/
|
|
366
|
+
setChatAdministratorCustomTitle(...args) {
|
|
367
|
+
this.assert(this.chat, 'setChatAdministratorCustomTitle');
|
|
368
|
+
return this.telegram.setChatAdministratorCustomTitle(this.chat.id, ...args);
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* @see https://core.telegram.org/bots/api#setchatphoto
|
|
372
|
+
*/
|
|
373
|
+
setChatPhoto(...args) {
|
|
374
|
+
this.assert(this.chat, 'setChatPhoto');
|
|
375
|
+
return this.telegram.setChatPhoto(this.chat.id, ...args);
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* @see https://core.telegram.org/bots/api#deletechatphoto
|
|
379
|
+
*/
|
|
380
|
+
deleteChatPhoto(...args) {
|
|
381
|
+
this.assert(this.chat, 'deleteChatPhoto');
|
|
382
|
+
return this.telegram.deleteChatPhoto(this.chat.id, ...args);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* @see https://core.telegram.org/bots/api#setchattitle
|
|
386
|
+
*/
|
|
387
|
+
setChatTitle(...args) {
|
|
388
|
+
this.assert(this.chat, 'setChatTitle');
|
|
389
|
+
return this.telegram.setChatTitle(this.chat.id, ...args);
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* @see https://core.telegram.org/bots/api#setchatdescription
|
|
393
|
+
*/
|
|
394
|
+
setChatDescription(...args) {
|
|
395
|
+
this.assert(this.chat, 'setChatDescription');
|
|
396
|
+
return this.telegram.setChatDescription(this.chat.id, ...args);
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* @see https://core.telegram.org/bots/api#pinchatmessage
|
|
400
|
+
*/
|
|
401
|
+
pinChatMessage(...args) {
|
|
402
|
+
this.assert(this.chat, 'pinChatMessage');
|
|
403
|
+
return this.telegram.pinChatMessage(this.chat.id, ...args);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* @see https://core.telegram.org/bots/api#unpinchatmessage
|
|
407
|
+
*/
|
|
408
|
+
unpinChatMessage(...args) {
|
|
409
|
+
this.assert(this.chat, 'unpinChatMessage');
|
|
410
|
+
return this.telegram.unpinChatMessage(this.chat.id, ...args);
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* @see https://core.telegram.org/bots/api#unpinallchatmessages
|
|
414
|
+
*/
|
|
415
|
+
unpinAllChatMessages(...args) {
|
|
416
|
+
this.assert(this.chat, 'unpinAllChatMessages');
|
|
417
|
+
return this.telegram.unpinAllChatMessages(this.chat.id, ...args);
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* @see https://core.telegram.org/bots/api#leavechat
|
|
421
|
+
*/
|
|
422
|
+
leaveChat(...args) {
|
|
423
|
+
this.assert(this.chat, 'leaveChat');
|
|
424
|
+
return this.telegram.leaveChat(this.chat.id, ...args);
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* @see https://core.telegram.org/bots/api#setchatpermissions
|
|
428
|
+
*/
|
|
429
|
+
setChatPermissions(...args) {
|
|
430
|
+
this.assert(this.chat, 'setChatPermissions');
|
|
431
|
+
return this.telegram.setChatPermissions(this.chat.id, ...args);
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* @see https://core.telegram.org/bots/api#getchatadministrators
|
|
435
|
+
*/
|
|
436
|
+
getChatAdministrators(...args) {
|
|
437
|
+
this.assert(this.chat, 'getChatAdministrators');
|
|
438
|
+
return this.telegram.getChatAdministrators(this.chat.id, ...args);
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* @see https://core.telegram.org/bots/api#getchatmember
|
|
442
|
+
*/
|
|
443
|
+
getChatMember(...args) {
|
|
444
|
+
this.assert(this.chat, 'getChatMember');
|
|
445
|
+
return this.telegram.getChatMember(this.chat.id, ...args);
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* @see https://core.telegram.org/bots/api#getchatmembercount
|
|
449
|
+
*/
|
|
450
|
+
getChatMembersCount(...args) {
|
|
451
|
+
this.assert(this.chat, 'getChatMembersCount');
|
|
452
|
+
return this.telegram.getChatMembersCount(this.chat.id, ...args);
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* @see https://core.telegram.org/bots/api#setpassportdataerrors
|
|
456
|
+
*/
|
|
457
|
+
setPassportDataErrors(errors) {
|
|
458
|
+
this.assert(this.from, 'setPassportDataErrors');
|
|
459
|
+
return this.telegram.setPassportDataErrors(this.from.id, errors);
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* @see https://core.telegram.org/bots/api#sendphoto
|
|
463
|
+
*/
|
|
464
|
+
sendPhoto(photo, extra) {
|
|
465
|
+
this.assert(this.chat, 'sendPhoto');
|
|
466
|
+
return this.telegram.sendPhoto(this.chat.id, photo, {
|
|
467
|
+
message_thread_id: getThreadId(this),
|
|
468
|
+
...extra,
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* @see https://core.telegram.org/bots/api#sendphoto
|
|
473
|
+
*/
|
|
474
|
+
replyWithPhoto(...args) {
|
|
475
|
+
return this.sendPhoto(...args);
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* @see https://core.telegram.org/bots/api#sendmediagroup
|
|
479
|
+
*/
|
|
480
|
+
sendMediaGroup(media, extra) {
|
|
481
|
+
this.assert(this.chat, 'sendMediaGroup');
|
|
482
|
+
return this.telegram.sendMediaGroup(this.chat.id, media, {
|
|
483
|
+
message_thread_id: getThreadId(this),
|
|
484
|
+
...extra,
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* @see https://core.telegram.org/bots/api#sendmediagroup
|
|
489
|
+
*/
|
|
490
|
+
replyWithMediaGroup(...args) {
|
|
491
|
+
return this.sendMediaGroup(...args);
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* @see https://core.telegram.org/bots/api#sendaudio
|
|
495
|
+
*/
|
|
496
|
+
sendAudio(audio, extra) {
|
|
497
|
+
this.assert(this.chat, 'sendAudio');
|
|
498
|
+
return this.telegram.sendAudio(this.chat.id, audio, {
|
|
499
|
+
message_thread_id: getThreadId(this),
|
|
500
|
+
...extra,
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* @see https://core.telegram.org/bots/api#sendaudio
|
|
505
|
+
*/
|
|
506
|
+
replyWithAudio(...args) {
|
|
507
|
+
return this.sendAudio(...args);
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* @see https://core.telegram.org/bots/api#senddice
|
|
511
|
+
*/
|
|
512
|
+
sendDice(extra) {
|
|
513
|
+
this.assert(this.chat, 'sendDice');
|
|
514
|
+
return this.telegram.sendDice(this.chat.id, {
|
|
515
|
+
message_thread_id: getThreadId(this),
|
|
516
|
+
...extra,
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* @see https://core.telegram.org/bots/api#senddice
|
|
521
|
+
*/
|
|
522
|
+
replyWithDice(...args) {
|
|
523
|
+
return this.sendDice(...args);
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* @see https://core.telegram.org/bots/api#senddocument
|
|
527
|
+
*/
|
|
528
|
+
sendDocument(document, extra) {
|
|
529
|
+
this.assert(this.chat, 'sendDocument');
|
|
530
|
+
return this.telegram.sendDocument(this.chat.id, document, {
|
|
531
|
+
message_thread_id: getThreadId(this),
|
|
532
|
+
...extra,
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* @see https://core.telegram.org/bots/api#senddocument
|
|
537
|
+
*/
|
|
538
|
+
replyWithDocument(...args) {
|
|
539
|
+
return this.sendDocument(...args);
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* @see https://core.telegram.org/bots/api#sendsticker
|
|
543
|
+
*/
|
|
544
|
+
sendSticker(sticker, extra) {
|
|
545
|
+
this.assert(this.chat, 'sendSticker');
|
|
546
|
+
return this.telegram.sendSticker(this.chat.id, sticker, {
|
|
547
|
+
message_thread_id: getThreadId(this),
|
|
548
|
+
...extra,
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* @see https://core.telegram.org/bots/api#sendsticker
|
|
553
|
+
*/
|
|
554
|
+
replyWithSticker(...args) {
|
|
555
|
+
return this.sendSticker(...args);
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* @see https://core.telegram.org/bots/api#sendvideo
|
|
559
|
+
*/
|
|
560
|
+
sendVideo(video, extra) {
|
|
561
|
+
this.assert(this.chat, 'sendVideo');
|
|
562
|
+
return this.telegram.sendVideo(this.chat.id, video, {
|
|
563
|
+
message_thread_id: getThreadId(this),
|
|
564
|
+
...extra,
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* @see https://core.telegram.org/bots/api#sendvideo
|
|
569
|
+
*/
|
|
570
|
+
replyWithVideo(...args) {
|
|
571
|
+
return this.sendVideo(...args);
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* @see https://core.telegram.org/bots/api#sendanimation
|
|
575
|
+
*/
|
|
576
|
+
sendAnimation(animation, extra) {
|
|
577
|
+
this.assert(this.chat, 'sendAnimation');
|
|
578
|
+
return this.telegram.sendAnimation(this.chat.id, animation, {
|
|
579
|
+
message_thread_id: getThreadId(this),
|
|
580
|
+
...extra,
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* @see https://core.telegram.org/bots/api#sendanimation
|
|
585
|
+
*/
|
|
586
|
+
replyWithAnimation(...args) {
|
|
587
|
+
return this.sendAnimation(...args);
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* @see https://core.telegram.org/bots/api#sendvideonote
|
|
591
|
+
*/
|
|
592
|
+
sendVideoNote(videoNote, extra) {
|
|
593
|
+
this.assert(this.chat, 'sendVideoNote');
|
|
594
|
+
return this.telegram.sendVideoNote(this.chat.id, videoNote, {
|
|
595
|
+
message_thread_id: getThreadId(this),
|
|
596
|
+
...extra,
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* @see https://core.telegram.org/bots/api#sendvideonote
|
|
601
|
+
*/
|
|
602
|
+
replyWithVideoNote(...args) {
|
|
603
|
+
return this.sendVideoNote(...args);
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* @see https://core.telegram.org/bots/api#sendinvoice
|
|
607
|
+
*/
|
|
608
|
+
sendInvoice(invoice, extra) {
|
|
609
|
+
this.assert(this.chat, 'sendInvoice');
|
|
610
|
+
return this.telegram.sendInvoice(this.chat.id, invoice, {
|
|
611
|
+
message_thread_id: getThreadId(this),
|
|
612
|
+
...extra,
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* @see https://core.telegram.org/bots/api#sendinvoice
|
|
617
|
+
*/
|
|
618
|
+
replyWithInvoice(...args) {
|
|
619
|
+
return this.sendInvoice(...args);
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* @see https://core.telegram.org/bots/api#sendgame
|
|
623
|
+
*/
|
|
624
|
+
sendGame(game, extra) {
|
|
625
|
+
this.assert(this.chat, 'sendGame');
|
|
626
|
+
return this.telegram.sendGame(this.chat.id, game, {
|
|
627
|
+
message_thread_id: getThreadId(this),
|
|
628
|
+
...extra,
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* @see https://core.telegram.org/bots/api#sendgame
|
|
633
|
+
*/
|
|
634
|
+
replyWithGame(...args) {
|
|
635
|
+
return this.sendGame(...args);
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* @see https://core.telegram.org/bots/api#sendvoice
|
|
639
|
+
*/
|
|
640
|
+
sendVoice(voice, extra) {
|
|
641
|
+
this.assert(this.chat, 'sendVoice');
|
|
642
|
+
return this.telegram.sendVoice(this.chat.id, voice, {
|
|
643
|
+
message_thread_id: getThreadId(this),
|
|
644
|
+
...extra,
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* @see https://core.telegram.org/bots/api#sendvoice
|
|
649
|
+
*/
|
|
650
|
+
replyWithVoice(...args) {
|
|
651
|
+
return this.sendVoice(...args);
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* @see https://core.telegram.org/bots/api#sendpoll
|
|
655
|
+
*/
|
|
656
|
+
sendPoll(poll, options, extra) {
|
|
657
|
+
this.assert(this.chat, 'sendPoll');
|
|
658
|
+
return this.telegram.sendPoll(this.chat.id, poll, options, {
|
|
659
|
+
message_thread_id: getThreadId(this),
|
|
660
|
+
...extra,
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* @see https://core.telegram.org/bots/api#sendpoll
|
|
665
|
+
*/
|
|
666
|
+
replyWithPoll(...args) {
|
|
667
|
+
return this.sendPoll(...args);
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* @see https://core.telegram.org/bots/api#sendpoll
|
|
671
|
+
*/
|
|
672
|
+
sendQuiz(quiz, options, extra) {
|
|
673
|
+
this.assert(this.chat, 'sendQuiz');
|
|
674
|
+
return this.telegram.sendQuiz(this.chat.id, quiz, options, {
|
|
675
|
+
message_thread_id: getThreadId(this),
|
|
676
|
+
...extra,
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* @see https://core.telegram.org/bots/api#sendpoll
|
|
681
|
+
*/
|
|
682
|
+
replyWithQuiz(...args) {
|
|
683
|
+
return this.sendQuiz(...args);
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* @see https://core.telegram.org/bots/api#stoppoll
|
|
687
|
+
*/
|
|
688
|
+
stopPoll(...args) {
|
|
689
|
+
this.assert(this.chat, 'stopPoll');
|
|
690
|
+
return this.telegram.stopPoll(this.chat.id, ...args);
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* @see https://core.telegram.org/bots/api#sendchataction
|
|
694
|
+
*/
|
|
695
|
+
sendChatAction(action, extra) {
|
|
696
|
+
this.assert(this.chat, 'sendChatAction');
|
|
697
|
+
return this.telegram.sendChatAction(this.chat.id, action, {
|
|
698
|
+
message_thread_id: getThreadId(this),
|
|
699
|
+
...extra,
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* @see https://core.telegram.org/bots/api#sendchataction
|
|
704
|
+
*
|
|
705
|
+
* Sends the sendChatAction request repeatedly, with a delay between requests,
|
|
706
|
+
* as long as the provided callback function is being processed.
|
|
707
|
+
*
|
|
708
|
+
* The sendChatAction errors should be ignored, because the goal is the actual long process completing and performing an action.
|
|
709
|
+
*
|
|
710
|
+
* @param action - chat action type.
|
|
711
|
+
* @param callback - a function to run along with the chat action.
|
|
712
|
+
* @param extra - extra parameters for sendChatAction.
|
|
713
|
+
* @param {number} [extra.intervalDuration=8000] - The duration (in milliseconds) between subsequent sendChatAction requests.
|
|
714
|
+
*/
|
|
715
|
+
async persistentChatAction(action, callback, { intervalDuration, ...extra } = {}) {
|
|
716
|
+
await this.sendChatAction(action, { ...extra });
|
|
717
|
+
const timer = setInterval(() => this.sendChatAction(action, { ...extra }).catch((err) => {
|
|
718
|
+
debug('Ignored error while persisting sendChatAction:', err);
|
|
719
|
+
}), intervalDuration !== null && intervalDuration !== void 0 ? intervalDuration : 4000);
|
|
720
|
+
try {
|
|
721
|
+
await callback();
|
|
722
|
+
}
|
|
723
|
+
finally {
|
|
724
|
+
clearInterval(timer);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* @deprecated use {@link Context.sendChatAction} instead
|
|
729
|
+
* @see https://core.telegram.org/bots/api#sendchataction
|
|
730
|
+
*/
|
|
731
|
+
replyWithChatAction(...args) {
|
|
732
|
+
return this.sendChatAction(...args);
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Shorthand for {@link Telegram.setMessageReaction}
|
|
736
|
+
* @param reaction An emoji or custom_emoji_id to set as reaction to current message. Leave empty to remove reactions.
|
|
737
|
+
* @param is_big Pass True to set the reaction with a big animation
|
|
738
|
+
*/
|
|
739
|
+
react(reaction, is_big) {
|
|
740
|
+
this.assert(this.chat, 'setMessageReaction');
|
|
741
|
+
this.assert(this.msgId, 'setMessageReaction');
|
|
742
|
+
const emojis = reaction
|
|
743
|
+
? Array.isArray(reaction)
|
|
744
|
+
? reaction
|
|
745
|
+
: [reaction]
|
|
746
|
+
: undefined;
|
|
747
|
+
const reactions = emojis === null || emojis === void 0 ? void 0 : emojis.map((emoji) => typeof emoji === 'string'
|
|
748
|
+
? reactions_1.Digit.has(emoji[0])
|
|
749
|
+
? { type: 'custom_emoji', custom_emoji_id: emoji }
|
|
750
|
+
: { type: 'emoji', emoji: emoji }
|
|
751
|
+
: emoji);
|
|
752
|
+
return this.telegram.setMessageReaction(this.chat.id, this.msgId, reactions, is_big);
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* @see https://core.telegram.org/bots/api#sendlocation
|
|
756
|
+
*/
|
|
757
|
+
sendLocation(latitude, longitude, extra) {
|
|
758
|
+
this.assert(this.chat, 'sendLocation');
|
|
759
|
+
return this.telegram.sendLocation(this.chat.id, latitude, longitude, {
|
|
760
|
+
message_thread_id: getThreadId(this),
|
|
761
|
+
...extra,
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* @see https://core.telegram.org/bots/api#sendlocation
|
|
766
|
+
*/
|
|
767
|
+
replyWithLocation(...args) {
|
|
768
|
+
return this.sendLocation(...args);
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* @see https://core.telegram.org/bots/api#sendvenue
|
|
772
|
+
*/
|
|
773
|
+
sendVenue(latitude, longitude, title, address, extra) {
|
|
774
|
+
this.assert(this.chat, 'sendVenue');
|
|
775
|
+
return this.telegram.sendVenue(this.chat.id, latitude, longitude, title, address, { message_thread_id: getThreadId(this), ...extra });
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* @see https://core.telegram.org/bots/api#sendvenue
|
|
779
|
+
*/
|
|
780
|
+
replyWithVenue(...args) {
|
|
781
|
+
return this.sendVenue(...args);
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* @see https://core.telegram.org/bots/api#sendcontact
|
|
785
|
+
*/
|
|
786
|
+
sendContact(phoneNumber, firstName, extra) {
|
|
787
|
+
this.assert(this.chat, 'sendContact');
|
|
788
|
+
return this.telegram.sendContact(this.chat.id, phoneNumber, firstName, {
|
|
789
|
+
message_thread_id: getThreadId(this),
|
|
790
|
+
...extra,
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* @see https://core.telegram.org/bots/api#sendcontact
|
|
795
|
+
*/
|
|
796
|
+
replyWithContact(...args) {
|
|
797
|
+
return this.sendContact(...args);
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* @deprecated use {@link Telegram.getStickerSet}
|
|
801
|
+
* @see https://core.telegram.org/bots/api#getstickerset
|
|
802
|
+
*/
|
|
803
|
+
getStickerSet(setName) {
|
|
804
|
+
return this.telegram.getStickerSet(setName);
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* @see https://core.telegram.org/bots/api#setchatstickerset
|
|
808
|
+
*/
|
|
809
|
+
setChatStickerSet(setName) {
|
|
810
|
+
this.assert(this.chat, 'setChatStickerSet');
|
|
811
|
+
return this.telegram.setChatStickerSet(this.chat.id, setName);
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* @see https://core.telegram.org/bots/api#deletechatstickerset
|
|
815
|
+
*/
|
|
816
|
+
deleteChatStickerSet() {
|
|
817
|
+
this.assert(this.chat, 'deleteChatStickerSet');
|
|
818
|
+
return this.telegram.deleteChatStickerSet(this.chat.id);
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this
|
|
822
|
+
* to work and must have the can_manage_topics administrator rights. Returns information about the created topic as a
|
|
823
|
+
* ForumTopic object.
|
|
824
|
+
*
|
|
825
|
+
* @see https://core.telegram.org/bots/api#createforumtopic
|
|
826
|
+
*/
|
|
827
|
+
createForumTopic(...args) {
|
|
828
|
+
this.assert(this.chat, 'createForumTopic');
|
|
829
|
+
return this.telegram.createForumTopic(this.chat.id, ...args);
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in
|
|
833
|
+
* the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the
|
|
834
|
+
* topic. Returns True on success.
|
|
835
|
+
*
|
|
836
|
+
* @see https://core.telegram.org/bots/api#editforumtopic
|
|
837
|
+
*/
|
|
838
|
+
editForumTopic(extra) {
|
|
839
|
+
var _a;
|
|
840
|
+
this.assert(this.chat, 'editForumTopic');
|
|
841
|
+
this.assert((_a = this.message) === null || _a === void 0 ? void 0 : _a.message_thread_id, 'editForumTopic');
|
|
842
|
+
return this.telegram.editForumTopic(this.chat.id, this.message.message_thread_id, extra);
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat
|
|
846
|
+
* for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
|
|
847
|
+
* Returns True on success.
|
|
848
|
+
*
|
|
849
|
+
* @see https://core.telegram.org/bots/api#closeforumtopic
|
|
850
|
+
*/
|
|
851
|
+
closeForumTopic() {
|
|
852
|
+
var _a;
|
|
853
|
+
this.assert(this.chat, 'closeForumTopic');
|
|
854
|
+
this.assert((_a = this.message) === null || _a === void 0 ? void 0 : _a.message_thread_id, 'closeForumTopic');
|
|
855
|
+
return this.telegram.closeForumTopic(this.chat.id, this.message.message_thread_id);
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat
|
|
859
|
+
* for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
|
|
860
|
+
* Returns True on success.
|
|
861
|
+
*
|
|
862
|
+
* @see https://core.telegram.org/bots/api#reopenforumtopic
|
|
863
|
+
*/
|
|
864
|
+
reopenForumTopic() {
|
|
865
|
+
var _a;
|
|
866
|
+
this.assert(this.chat, 'reopenForumTopic');
|
|
867
|
+
this.assert((_a = this.message) === null || _a === void 0 ? void 0 : _a.message_thread_id, 'reopenForumTopic');
|
|
868
|
+
return this.telegram.reopenForumTopic(this.chat.id, this.message.message_thread_id);
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an
|
|
872
|
+
* administrator in the chat for this to work and must have the can_delete_messages administrator rights.
|
|
873
|
+
* Returns True on success.
|
|
874
|
+
*
|
|
875
|
+
* @see https://core.telegram.org/bots/api#deleteforumtopic
|
|
876
|
+
*/
|
|
877
|
+
deleteForumTopic() {
|
|
878
|
+
var _a;
|
|
879
|
+
this.assert(this.chat, 'deleteForumTopic');
|
|
880
|
+
this.assert((_a = this.message) === null || _a === void 0 ? void 0 : _a.message_thread_id, 'deleteForumTopic');
|
|
881
|
+
return this.telegram.deleteForumTopic(this.chat.id, this.message.message_thread_id);
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat
|
|
885
|
+
* for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.
|
|
886
|
+
*
|
|
887
|
+
* @see https://core.telegram.org/bots/api#unpinallforumtopicmessages
|
|
888
|
+
*/
|
|
889
|
+
unpinAllForumTopicMessages() {
|
|
890
|
+
var _a;
|
|
891
|
+
this.assert(this.chat, 'unpinAllForumTopicMessages');
|
|
892
|
+
this.assert((_a = this.message) === null || _a === void 0 ? void 0 : _a.message_thread_id, 'unpinAllForumTopicMessages');
|
|
893
|
+
return this.telegram.unpinAllForumTopicMessages(this.chat.id, this.message.message_thread_id);
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator
|
|
897
|
+
* in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
|
|
898
|
+
*
|
|
899
|
+
* @see https://core.telegram.org/bots/api#editgeneralforumtopic
|
|
900
|
+
*/
|
|
901
|
+
editGeneralForumTopic(name) {
|
|
902
|
+
this.assert(this.chat, 'editGeneralForumTopic');
|
|
903
|
+
return this.telegram.editGeneralForumTopic(this.chat.id, name);
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the
|
|
907
|
+
* chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
|
|
908
|
+
*
|
|
909
|
+
* @see https://core.telegram.org/bots/api#closegeneralforumtopic
|
|
910
|
+
*/
|
|
911
|
+
closeGeneralForumTopic() {
|
|
912
|
+
this.assert(this.chat, 'closeGeneralForumTopic');
|
|
913
|
+
return this.telegram.closeGeneralForumTopic(this.chat.id);
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in
|
|
917
|
+
* the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically
|
|
918
|
+
* unhidden if it was hidden. Returns True on success.
|
|
919
|
+
*
|
|
920
|
+
* @see https://core.telegram.org/bots/api#reopengeneralforumtopic
|
|
921
|
+
*/
|
|
922
|
+
reopenGeneralForumTopic() {
|
|
923
|
+
this.assert(this.chat, 'reopenGeneralForumTopic');
|
|
924
|
+
return this.telegram.reopenGeneralForumTopic(this.chat.id);
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat
|
|
928
|
+
* for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed
|
|
929
|
+
* if it was open. Returns True on success.
|
|
930
|
+
*
|
|
931
|
+
* @see https://core.telegram.org/bots/api#hidegeneralforumtopic
|
|
932
|
+
*/
|
|
933
|
+
hideGeneralForumTopic() {
|
|
934
|
+
this.assert(this.chat, 'hideGeneralForumTopic');
|
|
935
|
+
return this.telegram.hideGeneralForumTopic(this.chat.id);
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the
|
|
939
|
+
* chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
|
|
940
|
+
*
|
|
941
|
+
* @see https://core.telegram.org/bots/api#unhidegeneralforumtopic
|
|
942
|
+
*/
|
|
943
|
+
unhideGeneralForumTopic() {
|
|
944
|
+
this.assert(this.chat, 'unhideGeneralForumTopic');
|
|
945
|
+
return this.telegram.unhideGeneralForumTopic(this.chat.id);
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* Use this method to clear the list of pinned messages in a General forum topic.
|
|
949
|
+
* The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator
|
|
950
|
+
* right in the supergroup.
|
|
951
|
+
*
|
|
952
|
+
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
|
953
|
+
*
|
|
954
|
+
* @see https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages
|
|
955
|
+
*/
|
|
956
|
+
unpinAllGeneralForumTopicMessages() {
|
|
957
|
+
this.assert(this.chat, 'unpinAllGeneralForumTopicMessages');
|
|
958
|
+
return this.telegram.unpinAllGeneralForumTopicMessages(this.chat.id);
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* @deprecated use {@link Telegram.setStickerPositionInSet}
|
|
962
|
+
* @see https://core.telegram.org/bots/api#setstickerpositioninset
|
|
963
|
+
*/
|
|
964
|
+
setStickerPositionInSet(sticker, position) {
|
|
965
|
+
return this.telegram.setStickerPositionInSet(sticker, position);
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* @deprecated use {@link Telegram.setStickerSetThumbnail}
|
|
969
|
+
* @see https://core.telegram.org/bots/api#setstickersetthumbnail
|
|
970
|
+
*/
|
|
971
|
+
setStickerSetThumb(...args) {
|
|
972
|
+
return this.telegram.setStickerSetThumbnail(...args);
|
|
973
|
+
}
|
|
974
|
+
setStickerSetThumbnail(...args) {
|
|
975
|
+
return this.telegram.setStickerSetThumbnail(...args);
|
|
976
|
+
}
|
|
977
|
+
setStickerMaskPosition(...args) {
|
|
978
|
+
return this.telegram.setStickerMaskPosition(...args);
|
|
979
|
+
}
|
|
980
|
+
setStickerKeywords(...args) {
|
|
981
|
+
return this.telegram.setStickerKeywords(...args);
|
|
982
|
+
}
|
|
983
|
+
setStickerEmojiList(...args) {
|
|
984
|
+
return this.telegram.setStickerEmojiList(...args);
|
|
985
|
+
}
|
|
986
|
+
deleteStickerSet(...args) {
|
|
987
|
+
return this.telegram.deleteStickerSet(...args);
|
|
988
|
+
}
|
|
989
|
+
setStickerSetTitle(...args) {
|
|
990
|
+
return this.telegram.setStickerSetTitle(...args);
|
|
991
|
+
}
|
|
992
|
+
setCustomEmojiStickerSetThumbnail(...args) {
|
|
993
|
+
return this.telegram.setCustomEmojiStickerSetThumbnail(...args);
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* @deprecated use {@link Telegram.deleteStickerFromSet}
|
|
997
|
+
* @see https://core.telegram.org/bots/api#deletestickerfromset
|
|
998
|
+
*/
|
|
999
|
+
deleteStickerFromSet(sticker) {
|
|
1000
|
+
return this.telegram.deleteStickerFromSet(sticker);
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* @see https://core.telegram.org/bots/api#uploadstickerfile
|
|
1004
|
+
*/
|
|
1005
|
+
uploadStickerFile(...args) {
|
|
1006
|
+
this.assert(this.from, 'uploadStickerFile');
|
|
1007
|
+
return this.telegram.uploadStickerFile(this.from.id, ...args);
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* @see https://core.telegram.org/bots/api#createnewstickerset
|
|
1011
|
+
*/
|
|
1012
|
+
createNewStickerSet(...args) {
|
|
1013
|
+
this.assert(this.from, 'createNewStickerSet');
|
|
1014
|
+
return this.telegram.createNewStickerSet(this.from.id, ...args);
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* @see https://core.telegram.org/bots/api#addstickertoset
|
|
1018
|
+
*/
|
|
1019
|
+
addStickerToSet(...args) {
|
|
1020
|
+
this.assert(this.from, 'addStickerToSet');
|
|
1021
|
+
return this.telegram.addStickerToSet(this.from.id, ...args);
|
|
1022
|
+
}
|
|
1023
|
+
/**
|
|
1024
|
+
* @deprecated use {@link Telegram.getMyCommands}
|
|
1025
|
+
* @see https://core.telegram.org/bots/api#getmycommands
|
|
1026
|
+
*/
|
|
1027
|
+
getMyCommands() {
|
|
1028
|
+
return this.telegram.getMyCommands();
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* @deprecated use {@link Telegram.setMyCommands}
|
|
1032
|
+
* @see https://core.telegram.org/bots/api#setmycommands
|
|
1033
|
+
*/
|
|
1034
|
+
setMyCommands(commands) {
|
|
1035
|
+
return this.telegram.setMyCommands(commands);
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* @deprecated use {@link Context.replyWithMarkdownV2}
|
|
1039
|
+
* @see https://core.telegram.org/bots/api#sendmessage
|
|
1040
|
+
*/
|
|
1041
|
+
replyWithMarkdown(markdown, extra) {
|
|
1042
|
+
return this.reply(markdown, { parse_mode: 'Markdown', ...extra });
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* @see https://core.telegram.org/bots/api#sendmessage
|
|
1046
|
+
*/
|
|
1047
|
+
replyWithMarkdownV2(markdown, extra) {
|
|
1048
|
+
return this.reply(markdown, { parse_mode: 'MarkdownV2', ...extra });
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* @see https://core.telegram.org/bots/api#sendmessage
|
|
1052
|
+
*/
|
|
1053
|
+
replyWithHTML(html, extra) {
|
|
1054
|
+
return this.reply(html, { parse_mode: 'HTML', ...extra });
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* @see https://core.telegram.org/bots/api#deletemessage
|
|
1058
|
+
*/
|
|
1059
|
+
deleteMessage(messageId) {
|
|
1060
|
+
this.assert(this.chat, 'deleteMessage');
|
|
1061
|
+
if (typeof messageId !== 'undefined')
|
|
1062
|
+
return this.telegram.deleteMessage(this.chat.id, messageId);
|
|
1063
|
+
this.assert(this.msgId, 'deleteMessage');
|
|
1064
|
+
return this.telegram.deleteMessage(this.chat.id, this.msgId);
|
|
1065
|
+
}
|
|
1066
|
+
/**
|
|
1067
|
+
* Context-aware shorthand for {@link Telegram.deleteMessages}
|
|
1068
|
+
* @param messageIds Identifiers of 1-100 messages to delete. See deleteMessage for limitations on which messages can be deleted
|
|
1069
|
+
*/
|
|
1070
|
+
deleteMessages(messageIds) {
|
|
1071
|
+
this.assert(this.chat, 'deleteMessages');
|
|
1072
|
+
return this.telegram.deleteMessages(this.chat.id, messageIds);
|
|
1073
|
+
}
|
|
1074
|
+
/**
|
|
1075
|
+
* @see https://core.telegram.org/bots/api#forwardmessage
|
|
1076
|
+
*/
|
|
1077
|
+
forwardMessage(chatId, extra) {
|
|
1078
|
+
this.assert(this.chat, 'forwardMessage');
|
|
1079
|
+
this.assert(this.msgId, 'forwardMessage');
|
|
1080
|
+
return this.telegram.forwardMessage(chatId, this.chat.id, this.msgId, extra);
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Shorthand for {@link Telegram.forwardMessages}
|
|
1084
|
+
* @see https://core.telegram.org/bots/api#forwardmessages
|
|
1085
|
+
*/
|
|
1086
|
+
forwardMessages(chatId, messageIds, extra) {
|
|
1087
|
+
this.assert(this.chat, 'forwardMessages');
|
|
1088
|
+
return this.telegram.forwardMessages(chatId, this.chat.id, messageIds, extra);
|
|
1089
|
+
}
|
|
1090
|
+
/**
|
|
1091
|
+
* @see https://core.telegram.org/bots/api#copymessage
|
|
1092
|
+
*/
|
|
1093
|
+
copyMessage(chatId, extra) {
|
|
1094
|
+
this.assert(this.chat, 'copyMessage');
|
|
1095
|
+
this.assert(this.msgId, 'copyMessage');
|
|
1096
|
+
return this.telegram.copyMessage(chatId, this.chat.id, this.msgId, extra);
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Context-aware shorthand for {@link Telegram.copyMessages}
|
|
1100
|
+
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
|
1101
|
+
* @param messageIds Identifiers of 1-100 messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order.
|
|
1102
|
+
*/
|
|
1103
|
+
copyMessages(chatId, messageIds, extra) {
|
|
1104
|
+
var _a;
|
|
1105
|
+
this.assert(this.chat, 'copyMessages');
|
|
1106
|
+
return this.telegram.copyMessages(chatId, (_a = this.chat) === null || _a === void 0 ? void 0 : _a.id, messageIds, extra);
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* @see https://core.telegram.org/bots/api#approvechatjoinrequest
|
|
1110
|
+
*/
|
|
1111
|
+
approveChatJoinRequest(userId) {
|
|
1112
|
+
this.assert(this.chat, 'approveChatJoinRequest');
|
|
1113
|
+
return this.telegram.approveChatJoinRequest(this.chat.id, userId);
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* @see https://core.telegram.org/bots/api#declinechatjoinrequest
|
|
1117
|
+
*/
|
|
1118
|
+
declineChatJoinRequest(userId) {
|
|
1119
|
+
this.assert(this.chat, 'declineChatJoinRequest');
|
|
1120
|
+
return this.telegram.declineChatJoinRequest(this.chat.id, userId);
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* @see https://core.telegram.org/bots/api#banchatsenderchat
|
|
1124
|
+
*/
|
|
1125
|
+
banChatSenderChat(senderChatId) {
|
|
1126
|
+
this.assert(this.chat, 'banChatSenderChat');
|
|
1127
|
+
return this.telegram.banChatSenderChat(this.chat.id, senderChatId);
|
|
1128
|
+
}
|
|
1129
|
+
/**
|
|
1130
|
+
* @see https://core.telegram.org/bots/api#unbanchatsenderchat
|
|
1131
|
+
*/
|
|
1132
|
+
unbanChatSenderChat(senderChatId) {
|
|
1133
|
+
this.assert(this.chat, 'unbanChatSenderChat');
|
|
1134
|
+
return this.telegram.unbanChatSenderChat(this.chat.id, senderChatId);
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* Use this method to change the bot's menu button in the current private chat. Returns true on success.
|
|
1138
|
+
* @see https://core.telegram.org/bots/api#setchatmenubutton
|
|
1139
|
+
*/
|
|
1140
|
+
setChatMenuButton(menuButton) {
|
|
1141
|
+
this.assert(this.chat, 'setChatMenuButton');
|
|
1142
|
+
return this.telegram.setChatMenuButton({ chatId: this.chat.id, menuButton });
|
|
1143
|
+
}
|
|
1144
|
+
/**
|
|
1145
|
+
* Use this method to get the current value of the bot's menu button in the current private chat. Returns MenuButton on success.
|
|
1146
|
+
* @see https://core.telegram.org/bots/api#getchatmenubutton
|
|
1147
|
+
*/
|
|
1148
|
+
getChatMenuButton() {
|
|
1149
|
+
this.assert(this.chat, 'getChatMenuButton');
|
|
1150
|
+
return this.telegram.getChatMenuButton({ chatId: this.chat.id });
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* @see https://core.telegram.org/bots/api#setmydefaultadministratorrights
|
|
1154
|
+
*/
|
|
1155
|
+
setMyDefaultAdministratorRights(extra) {
|
|
1156
|
+
return this.telegram.setMyDefaultAdministratorRights(extra);
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* @see https://core.telegram.org/bots/api#getmydefaultadministratorrights
|
|
1160
|
+
*/
|
|
1161
|
+
getMyDefaultAdministratorRights(extra) {
|
|
1162
|
+
return this.telegram.getMyDefaultAdministratorRights(extra);
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
exports.Context = Context;
|
|
1166
|
+
exports.default = Context;
|
|
1167
|
+
const Msg = {
|
|
1168
|
+
isAccessible() {
|
|
1169
|
+
return 'date' in this && this.date !== 0;
|
|
1170
|
+
},
|
|
1171
|
+
has(...keys) {
|
|
1172
|
+
return keys.some((key) =>
|
|
1173
|
+
// @ts-expect-error TS doesn't understand key
|
|
1174
|
+
this[key] != undefined);
|
|
1175
|
+
},
|
|
1176
|
+
};
|
|
1177
|
+
function getMessageFromAnySource(ctx) {
|
|
1178
|
+
var _a, _b, _c, _d, _e;
|
|
1179
|
+
const msg = (_e = (_d = (_b = (_a = ctx.message) !== null && _a !== void 0 ? _a : ctx.editedMessage) !== null && _b !== void 0 ? _b : (_c = ctx.callbackQuery) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : ctx.channelPost) !== null && _e !== void 0 ? _e : ctx.editedChannelPost;
|
|
1180
|
+
if (msg)
|
|
1181
|
+
return Object.assign(Object.create(Msg), msg);
|
|
1182
|
+
}
|
|
1183
|
+
function getUserFromAnySource(ctx) {
|
|
1184
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1185
|
+
if (ctx.callbackQuery)
|
|
1186
|
+
return ctx.callbackQuery.from;
|
|
1187
|
+
const msg = ctx.msg;
|
|
1188
|
+
if (msg === null || msg === void 0 ? void 0 : msg.has('from'))
|
|
1189
|
+
return msg.from;
|
|
1190
|
+
return ((_h = (_g = ((_f = (_e = (_d = (_c = (_b = (_a = ctx.inlineQuery) !== null && _a !== void 0 ? _a : ctx.shippingQuery) !== null && _b !== void 0 ? _b : ctx.preCheckoutQuery) !== null && _c !== void 0 ? _c : ctx.chosenInlineResult) !== null && _d !== void 0 ? _d : ctx.chatMember) !== null && _e !== void 0 ? _e : ctx.myChatMember) !== null && _f !== void 0 ? _f : ctx.chatJoinRequest)) === null || _g === void 0 ? void 0 : _g.from) !== null && _h !== void 0 ? _h : (_m = ((_k = (_j = ctx.messageReaction) !== null && _j !== void 0 ? _j : ctx.pollAnswer) !== null && _k !== void 0 ? _k : (_l = ctx.chatBoost) === null || _l === void 0 ? void 0 : _l.boost.source)) === null || _m === void 0 ? void 0 : _m.user);
|
|
1191
|
+
}
|
|
1192
|
+
function getMsgIdFromAnySource(ctx) {
|
|
1193
|
+
var _a, _b;
|
|
1194
|
+
const msg = getMessageFromAnySource(ctx);
|
|
1195
|
+
return (_b = ((_a = msg !== null && msg !== void 0 ? msg : ctx.messageReaction) !== null && _a !== void 0 ? _a : ctx.messageReactionCount)) === null || _b === void 0 ? void 0 : _b.message_id;
|
|
1196
|
+
}
|
|
1197
|
+
function getTextAndEntitiesFromAnySource(ctx) {
|
|
1198
|
+
const msg = ctx.msg;
|
|
1199
|
+
let text, entities;
|
|
1200
|
+
if (msg) {
|
|
1201
|
+
if ('text' in msg)
|
|
1202
|
+
(text = msg.text), (entities = msg.entities);
|
|
1203
|
+
else if ('caption' in msg)
|
|
1204
|
+
(text = msg.caption), (entities = msg.caption_entities);
|
|
1205
|
+
else if ('game' in msg)
|
|
1206
|
+
(text = msg.game.text), (entities = msg.game.text_entities);
|
|
1207
|
+
}
|
|
1208
|
+
else if (ctx.poll)
|
|
1209
|
+
(text = ctx.poll.explanation), (entities = ctx.poll.explanation_entities);
|
|
1210
|
+
return [text, entities];
|
|
1211
|
+
}
|
|
1212
|
+
const getThreadId = (ctx) => {
|
|
1213
|
+
const msg = ctx.msg;
|
|
1214
|
+
return (msg === null || msg === void 0 ? void 0 : msg.isAccessible())
|
|
1215
|
+
? msg.is_topic_message
|
|
1216
|
+
? msg.message_thread_id
|
|
1217
|
+
: undefined
|
|
1218
|
+
: undefined;
|
|
1219
|
+
};
|