@mtcute/dispatcher 0.17.2 → 0.18.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/callback-data-builder.cjs +126 -0
- package/callback-data-builder.d.cts +49 -0
- package/callback-data-builder.js +121 -0
- package/callback-data-builder.test.d.cts +1 -0
- package/context/base.d.cts +9 -0
- package/context/business-message.cjs +143 -0
- package/context/business-message.d.cts +60 -0
- package/context/business-message.js +138 -0
- package/context/callback-query.cjs +92 -0
- package/context/callback-query.d.cts +62 -0
- package/context/callback-query.js +87 -0
- package/context/chat-join-request.cjs +32 -0
- package/context/chat-join-request.d.cts +17 -0
- package/context/chat-join-request.d.ts +1 -1
- package/context/chat-join-request.js +27 -0
- package/context/chosen-inline-result.cjs +30 -0
- package/context/chosen-inline-result.d.cts +22 -0
- package/context/chosen-inline-result.d.ts +1 -1
- package/context/chosen-inline-result.js +25 -0
- package/context/index.d.cts +9 -0
- package/context/inline-query.cjs +20 -0
- package/context/inline-query.d.cts +15 -0
- package/context/inline-query.js +15 -0
- package/context/message.cjs +182 -0
- package/context/message.d.cts +82 -0
- package/context/message.d.ts +2 -2
- package/context/message.js +177 -0
- package/context/parse.cjs +45 -0
- package/context/parse.d.cts +13 -0
- package/context/parse.js +40 -0
- package/context/pre-checkout-query.cjs +24 -0
- package/context/pre-checkout-query.d.cts +17 -0
- package/context/pre-checkout-query.d.ts +1 -1
- package/context/pre-checkout-query.js +19 -0
- package/context/scene-transition.cjs +52 -0
- package/context/scene-transition.d.cts +24 -0
- package/context/scene-transition.d.ts +1 -1
- package/context/scene-transition.js +47 -0
- package/dispatcher.cjs +860 -0
- package/dispatcher.d.cts +880 -0
- package/dispatcher.d.ts +4 -4
- package/dispatcher.js +855 -0
- package/filters/bots.cjs +94 -0
- package/filters/bots.d.cts +62 -0
- package/filters/bots.d.ts +2 -4
- package/filters/bots.js +89 -0
- package/filters/bots.test.d.cts +1 -0
- package/filters/bundle.cjs +79 -0
- package/filters/bundle.d.cts +10 -0
- package/filters/bundle.js +74 -0
- package/filters/chat.cjs +43 -0
- package/filters/chat.d.cts +29 -0
- package/filters/chat.d.ts +8 -6
- package/filters/chat.js +38 -0
- package/filters/group.cjs +49 -0
- package/filters/group.d.cts +26 -0
- package/filters/group.js +44 -0
- package/filters/index.d.cts +4 -0
- package/filters/logic.cjs +57 -0
- package/filters/logic.d.cts +29 -0
- package/filters/logic.js +52 -0
- package/filters/logic.test.d.cts +1 -0
- package/filters/message.cjs +130 -0
- package/filters/message.d.cts +223 -0
- package/filters/message.d.ts +5 -1
- package/filters/message.js +125 -0
- package/filters/state.cjs +21 -0
- package/filters/state.d.cts +15 -0
- package/filters/state.js +16 -0
- package/filters/text.cjs +87 -0
- package/filters/text.d.cts +64 -0
- package/filters/text.d.ts +2 -2
- package/filters/text.js +82 -0
- package/filters/types.d.cts +91 -0
- package/filters/updates.cjs +27 -0
- package/filters/updates.d.cts +39 -0
- package/filters/updates.js +22 -0
- package/filters/user.cjs +57 -0
- package/filters/user.d.cts +24 -0
- package/filters/user.js +52 -0
- package/handler.d.cts +41 -0
- package/handler.d.ts +1 -1
- package/index.cjs +37 -2528
- package/index.js +16 -2507
- package/package.json +10 -9
- package/propagation.cjs +15 -0
- package/propagation.d.cts +22 -0
- package/propagation.js +10 -0
- package/state/index.d.cts +5 -0
- package/state/key.cjs +32 -0
- package/state/key.d.cts +24 -0
- package/state/key.js +27 -0
- package/state/provider.d.cts +5 -0
- package/state/providers/index.d.cts +2 -0
- package/state/providers/memory.cjs +79 -0
- package/state/providers/memory.d.cts +29 -0
- package/state/providers/memory.js +74 -0
- package/state/providers/sqlite.cjs +99 -0
- package/state/providers/sqlite.d.cts +28 -0
- package/state/providers/sqlite.js +94 -0
- package/state/repository.d.cts +62 -0
- package/state/service.cjs +69 -0
- package/state/service.d.cts +20 -0
- package/state/service.js +64 -0
- package/state/update-state.cjs +206 -0
- package/state/update-state.d.cts +151 -0
- package/state/update-state.d.ts +1 -1
- package/state/update-state.js +201 -0
- package/wizard.cjs +90 -0
- package/wizard.d.cts +64 -0
- package/wizard.js +85 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
|
|
2
|
+
globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
|
|
3
|
+
console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
|
|
4
|
+
console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
|
|
5
|
+
}
|
|
6
|
+
"use strict";
|
|
7
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
+
const core = require("@mtcute/core");
|
|
9
|
+
class CallbackQueryContext extends core.CallbackQuery {
|
|
10
|
+
constructor(client, query) {
|
|
11
|
+
super(query.raw, query._peers);
|
|
12
|
+
this.client = client;
|
|
13
|
+
}
|
|
14
|
+
_name = "callback_query";
|
|
15
|
+
/** Answer to this callback query */
|
|
16
|
+
answer(params) {
|
|
17
|
+
return this.client.answerCallbackQuery(this.id, params);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get the message containing the callback button being clicked.
|
|
21
|
+
*
|
|
22
|
+
* Note that the message may have been deleted, in which case
|
|
23
|
+
* `null` will be returned.
|
|
24
|
+
*/
|
|
25
|
+
async getMessage() {
|
|
26
|
+
return this.client.getCallbackQueryMessage(this);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Edit the message that contained the callback button that was clicked.
|
|
30
|
+
*/
|
|
31
|
+
async editMessage(params) {
|
|
32
|
+
return this.client.editMessage({
|
|
33
|
+
chatId: this.raw.peer,
|
|
34
|
+
message: this.raw.msgId,
|
|
35
|
+
...params
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Shortcut for getting the message and editing it.
|
|
40
|
+
*/
|
|
41
|
+
async editMessageWith(handler) {
|
|
42
|
+
const msg = await this.getMessage();
|
|
43
|
+
if (!msg) return;
|
|
44
|
+
const res = await handler(msg);
|
|
45
|
+
if (!res) return;
|
|
46
|
+
return this.editMessage(res);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
class InlineCallbackQueryContext extends core.InlineCallbackQuery {
|
|
50
|
+
constructor(client, query) {
|
|
51
|
+
super(query.raw, query._peers);
|
|
52
|
+
this.client = client;
|
|
53
|
+
}
|
|
54
|
+
_name = "inline_callback_query";
|
|
55
|
+
/** Answer to this callback query */
|
|
56
|
+
answer(params) {
|
|
57
|
+
return this.client.answerCallbackQuery(this.id, params);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Edit the message that contained the callback button that was clicked.
|
|
61
|
+
*/
|
|
62
|
+
async editMessage(params) {
|
|
63
|
+
return this.client.editInlineMessage({
|
|
64
|
+
messageId: this.raw.msgId,
|
|
65
|
+
...params
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
class BusinessCallbackQueryContext extends core.BusinessCallbackQuery {
|
|
70
|
+
constructor(client, query) {
|
|
71
|
+
super(query.raw, query._peers);
|
|
72
|
+
this.client = client;
|
|
73
|
+
}
|
|
74
|
+
_name = "business_callback_query";
|
|
75
|
+
/** Answer to this callback query */
|
|
76
|
+
answer(params) {
|
|
77
|
+
return this.client.answerCallbackQuery(this.id, params);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Edit the message that contained the callback button that was clicked.
|
|
81
|
+
*/
|
|
82
|
+
async editMessage(params) {
|
|
83
|
+
return this.client.editMessage({
|
|
84
|
+
message: this.message,
|
|
85
|
+
businessConnectionId: this.connectionId,
|
|
86
|
+
...params
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.BusinessCallbackQueryContext = BusinessCallbackQueryContext;
|
|
91
|
+
exports.CallbackQueryContext = CallbackQueryContext;
|
|
92
|
+
exports.InlineCallbackQueryContext = InlineCallbackQueryContext;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { MaybePromise, Message, BusinessCallbackQuery, CallbackQuery, InlineCallbackQuery } from '@mtcute/core';
|
|
2
|
+
import { TelegramClient } from '@mtcute/core/client.js';
|
|
3
|
+
import { UpdateContext } from './base.js';
|
|
4
|
+
/**
|
|
5
|
+
* Context of a callback query update.
|
|
6
|
+
*
|
|
7
|
+
* This is a subclass of {@link CallbackQuery}, so all its fields are also available.
|
|
8
|
+
*/
|
|
9
|
+
export declare class CallbackQueryContext extends CallbackQuery implements UpdateContext<CallbackQuery> {
|
|
10
|
+
readonly client: TelegramClient;
|
|
11
|
+
readonly _name: "callback_query";
|
|
12
|
+
constructor(client: TelegramClient, query: CallbackQuery);
|
|
13
|
+
/** Answer to this callback query */
|
|
14
|
+
answer(params: Parameters<TelegramClient['answerCallbackQuery']>[1]): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Get the message containing the callback button being clicked.
|
|
17
|
+
*
|
|
18
|
+
* Note that the message may have been deleted, in which case
|
|
19
|
+
* `null` will be returned.
|
|
20
|
+
*/
|
|
21
|
+
getMessage(): Promise<Message | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Edit the message that contained the callback button that was clicked.
|
|
24
|
+
*/
|
|
25
|
+
editMessage(params: Omit<Parameters<TelegramClient['editInlineMessage']>[0], 'messageId'>): Promise<Message>;
|
|
26
|
+
/**
|
|
27
|
+
* Shortcut for getting the message and editing it.
|
|
28
|
+
*/
|
|
29
|
+
editMessageWith(handler: (msg: Message) => MaybePromise<Parameters<CallbackQueryContext['editMessage']>[0]>): Promise<Message | undefined>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Context of an inline-originated callback query update.
|
|
33
|
+
*
|
|
34
|
+
* This is a subclass of {@link InlineCallbackQuery}, so all its fields are also available.
|
|
35
|
+
*/
|
|
36
|
+
export declare class InlineCallbackQueryContext extends InlineCallbackQuery implements UpdateContext<InlineCallbackQuery> {
|
|
37
|
+
readonly client: TelegramClient;
|
|
38
|
+
readonly _name: "inline_callback_query";
|
|
39
|
+
constructor(client: TelegramClient, query: InlineCallbackQuery);
|
|
40
|
+
/** Answer to this callback query */
|
|
41
|
+
answer(params: Parameters<TelegramClient['answerCallbackQuery']>[1]): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Edit the message that contained the callback button that was clicked.
|
|
44
|
+
*/
|
|
45
|
+
editMessage(params: Omit<Parameters<TelegramClient['editInlineMessage']>[0], 'messageId'>): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Context of an callback query update originated from a business connection message
|
|
49
|
+
*
|
|
50
|
+
* This is a subclass of {@link BusinessCallbackQuery}, so all its fields are also available.
|
|
51
|
+
*/
|
|
52
|
+
export declare class BusinessCallbackQueryContext extends BusinessCallbackQuery implements UpdateContext<BusinessCallbackQuery> {
|
|
53
|
+
readonly client: TelegramClient;
|
|
54
|
+
readonly _name: "business_callback_query";
|
|
55
|
+
constructor(client: TelegramClient, query: BusinessCallbackQuery);
|
|
56
|
+
/** Answer to this callback query */
|
|
57
|
+
answer(params: Parameters<TelegramClient['answerCallbackQuery']>[1]): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Edit the message that contained the callback button that was clicked.
|
|
60
|
+
*/
|
|
61
|
+
editMessage(params: Omit<Parameters<TelegramClient['editInlineMessage']>[0], 'messageId'>): Promise<Message>;
|
|
62
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { CallbackQuery, InlineCallbackQuery, BusinessCallbackQuery } from "@mtcute/core";
|
|
2
|
+
class CallbackQueryContext extends CallbackQuery {
|
|
3
|
+
constructor(client, query) {
|
|
4
|
+
super(query.raw, query._peers);
|
|
5
|
+
this.client = client;
|
|
6
|
+
}
|
|
7
|
+
_name = "callback_query";
|
|
8
|
+
/** Answer to this callback query */
|
|
9
|
+
answer(params) {
|
|
10
|
+
return this.client.answerCallbackQuery(this.id, params);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get the message containing the callback button being clicked.
|
|
14
|
+
*
|
|
15
|
+
* Note that the message may have been deleted, in which case
|
|
16
|
+
* `null` will be returned.
|
|
17
|
+
*/
|
|
18
|
+
async getMessage() {
|
|
19
|
+
return this.client.getCallbackQueryMessage(this);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Edit the message that contained the callback button that was clicked.
|
|
23
|
+
*/
|
|
24
|
+
async editMessage(params) {
|
|
25
|
+
return this.client.editMessage({
|
|
26
|
+
chatId: this.raw.peer,
|
|
27
|
+
message: this.raw.msgId,
|
|
28
|
+
...params
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Shortcut for getting the message and editing it.
|
|
33
|
+
*/
|
|
34
|
+
async editMessageWith(handler) {
|
|
35
|
+
const msg = await this.getMessage();
|
|
36
|
+
if (!msg) return;
|
|
37
|
+
const res = await handler(msg);
|
|
38
|
+
if (!res) return;
|
|
39
|
+
return this.editMessage(res);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
class InlineCallbackQueryContext extends InlineCallbackQuery {
|
|
43
|
+
constructor(client, query) {
|
|
44
|
+
super(query.raw, query._peers);
|
|
45
|
+
this.client = client;
|
|
46
|
+
}
|
|
47
|
+
_name = "inline_callback_query";
|
|
48
|
+
/** Answer to this callback query */
|
|
49
|
+
answer(params) {
|
|
50
|
+
return this.client.answerCallbackQuery(this.id, params);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Edit the message that contained the callback button that was clicked.
|
|
54
|
+
*/
|
|
55
|
+
async editMessage(params) {
|
|
56
|
+
return this.client.editInlineMessage({
|
|
57
|
+
messageId: this.raw.msgId,
|
|
58
|
+
...params
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
class BusinessCallbackQueryContext extends BusinessCallbackQuery {
|
|
63
|
+
constructor(client, query) {
|
|
64
|
+
super(query.raw, query._peers);
|
|
65
|
+
this.client = client;
|
|
66
|
+
}
|
|
67
|
+
_name = "business_callback_query";
|
|
68
|
+
/** Answer to this callback query */
|
|
69
|
+
answer(params) {
|
|
70
|
+
return this.client.answerCallbackQuery(this.id, params);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Edit the message that contained the callback button that was clicked.
|
|
74
|
+
*/
|
|
75
|
+
async editMessage(params) {
|
|
76
|
+
return this.client.editMessage({
|
|
77
|
+
message: this.message,
|
|
78
|
+
businessConnectionId: this.connectionId,
|
|
79
|
+
...params
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
BusinessCallbackQueryContext,
|
|
85
|
+
CallbackQueryContext,
|
|
86
|
+
InlineCallbackQueryContext
|
|
87
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
|
|
2
|
+
globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
|
|
3
|
+
console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
|
|
4
|
+
console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
|
|
5
|
+
}
|
|
6
|
+
"use strict";
|
|
7
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
+
const core = require("@mtcute/core");
|
|
9
|
+
class ChatJoinRequestUpdateContext extends core.BotChatJoinRequestUpdate {
|
|
10
|
+
constructor(client, update) {
|
|
11
|
+
super(update.raw, update._peers);
|
|
12
|
+
this.client = client;
|
|
13
|
+
}
|
|
14
|
+
_name = "bot_chat_join_request";
|
|
15
|
+
/** Approve the request */
|
|
16
|
+
approve() {
|
|
17
|
+
return this.client.hideJoinRequest({
|
|
18
|
+
action: "approve",
|
|
19
|
+
user: this.user.inputPeer,
|
|
20
|
+
chatId: this.chat.inputPeer
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/** Decline the request */
|
|
24
|
+
decline() {
|
|
25
|
+
return this.client.hideJoinRequest({
|
|
26
|
+
action: "decline",
|
|
27
|
+
user: this.user.inputPeer,
|
|
28
|
+
chatId: this.chat.inputPeer
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.ChatJoinRequestUpdateContext = ChatJoinRequestUpdateContext;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TelegramClient } from '@mtcute/core/client.js';
|
|
2
|
+
import { UpdateContext } from './base.js';
|
|
3
|
+
import { BotChatJoinRequestUpdate } from '@mtcute/core';
|
|
4
|
+
/**
|
|
5
|
+
* Context of a chat join request update (for bots).
|
|
6
|
+
*
|
|
7
|
+
* This is a subclass of {@link BotChatJoinRequestUpdate}, so all its fields are also available.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ChatJoinRequestUpdateContext extends BotChatJoinRequestUpdate implements UpdateContext<BotChatJoinRequestUpdate> {
|
|
10
|
+
readonly client: TelegramClient;
|
|
11
|
+
readonly _name: "bot_chat_join_request";
|
|
12
|
+
constructor(client: TelegramClient, update: BotChatJoinRequestUpdate);
|
|
13
|
+
/** Approve the request */
|
|
14
|
+
approve(): Promise<void>;
|
|
15
|
+
/** Decline the request */
|
|
16
|
+
decline(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BotChatJoinRequestUpdate } from '@mtcute/core';
|
|
2
1
|
import { TelegramClient } from '@mtcute/core/client.js';
|
|
3
2
|
import { UpdateContext } from './base.js';
|
|
3
|
+
import { BotChatJoinRequestUpdate } from '@mtcute/core';
|
|
4
4
|
/**
|
|
5
5
|
* Context of a chat join request update (for bots).
|
|
6
6
|
*
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BotChatJoinRequestUpdate } from "@mtcute/core";
|
|
2
|
+
class ChatJoinRequestUpdateContext extends BotChatJoinRequestUpdate {
|
|
3
|
+
constructor(client, update) {
|
|
4
|
+
super(update.raw, update._peers);
|
|
5
|
+
this.client = client;
|
|
6
|
+
}
|
|
7
|
+
_name = "bot_chat_join_request";
|
|
8
|
+
/** Approve the request */
|
|
9
|
+
approve() {
|
|
10
|
+
return this.client.hideJoinRequest({
|
|
11
|
+
action: "approve",
|
|
12
|
+
user: this.user.inputPeer,
|
|
13
|
+
chatId: this.chat.inputPeer
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/** Decline the request */
|
|
17
|
+
decline() {
|
|
18
|
+
return this.client.hideJoinRequest({
|
|
19
|
+
action: "decline",
|
|
20
|
+
user: this.user.inputPeer,
|
|
21
|
+
chatId: this.chat.inputPeer
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
ChatJoinRequestUpdateContext
|
|
27
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
|
|
2
|
+
globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
|
|
3
|
+
console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
|
|
4
|
+
console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
|
|
5
|
+
}
|
|
6
|
+
"use strict";
|
|
7
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
+
const core = require("@mtcute/core");
|
|
9
|
+
class ChosenInlineResultContext extends core.ChosenInlineResult {
|
|
10
|
+
constructor(client, result) {
|
|
11
|
+
super(result.raw, result._peers);
|
|
12
|
+
this.client = client;
|
|
13
|
+
}
|
|
14
|
+
_name = "chosen_inline_result";
|
|
15
|
+
/**
|
|
16
|
+
* Edit the message that was sent when this inline result that was chosen.
|
|
17
|
+
*
|
|
18
|
+
* > **Note**: This method can only be used if the message contained a reply markup
|
|
19
|
+
*/
|
|
20
|
+
async editMessage(params) {
|
|
21
|
+
if (!this.raw.msgId) {
|
|
22
|
+
throw new core.MtArgumentError("No message ID, make sure you have included reply markup!");
|
|
23
|
+
}
|
|
24
|
+
return this.client.editInlineMessage({
|
|
25
|
+
...params,
|
|
26
|
+
messageId: this.raw.msgId
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.ChosenInlineResultContext = ChosenInlineResultContext;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TelegramClient } from '@mtcute/core/client.js';
|
|
2
|
+
import { UpdateContext } from './base.js';
|
|
3
|
+
import { ChosenInlineResult } from '@mtcute/core';
|
|
4
|
+
/**
|
|
5
|
+
* Context of a chosen inline result update.
|
|
6
|
+
*
|
|
7
|
+
* This is a subclass of {@link ChosenInlineResult}, so all its fields are also available.
|
|
8
|
+
*
|
|
9
|
+
* > **Note**: To receive these updates, you must enable
|
|
10
|
+
* > Inline feedback in [@BotFather](//t.me/botfather)
|
|
11
|
+
*/
|
|
12
|
+
export declare class ChosenInlineResultContext extends ChosenInlineResult implements UpdateContext<ChosenInlineResult> {
|
|
13
|
+
readonly client: TelegramClient;
|
|
14
|
+
readonly _name: "chosen_inline_result";
|
|
15
|
+
constructor(client: TelegramClient, result: ChosenInlineResult);
|
|
16
|
+
/**
|
|
17
|
+
* Edit the message that was sent when this inline result that was chosen.
|
|
18
|
+
*
|
|
19
|
+
* > **Note**: This method can only be used if the message contained a reply markup
|
|
20
|
+
*/
|
|
21
|
+
editMessage(params: Parameters<TelegramClient['editInlineMessage']>[0]): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ChosenInlineResult, MtArgumentError } from "@mtcute/core";
|
|
2
|
+
class ChosenInlineResultContext extends ChosenInlineResult {
|
|
3
|
+
constructor(client, result) {
|
|
4
|
+
super(result.raw, result._peers);
|
|
5
|
+
this.client = client;
|
|
6
|
+
}
|
|
7
|
+
_name = "chosen_inline_result";
|
|
8
|
+
/**
|
|
9
|
+
* Edit the message that was sent when this inline result that was chosen.
|
|
10
|
+
*
|
|
11
|
+
* > **Note**: This method can only be used if the message contained a reply markup
|
|
12
|
+
*/
|
|
13
|
+
async editMessage(params) {
|
|
14
|
+
if (!this.raw.msgId) {
|
|
15
|
+
throw new MtArgumentError("No message ID, make sure you have included reply markup!");
|
|
16
|
+
}
|
|
17
|
+
return this.client.editInlineMessage({
|
|
18
|
+
...params,
|
|
19
|
+
messageId: this.raw.msgId
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
ChosenInlineResultContext
|
|
25
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './base.js';
|
|
2
|
+
export * from './business-message.js';
|
|
3
|
+
export * from './callback-query.js';
|
|
4
|
+
export * from './chat-join-request.js';
|
|
5
|
+
export * from './chosen-inline-result.js';
|
|
6
|
+
export * from './inline-query.js';
|
|
7
|
+
export * from './message.js';
|
|
8
|
+
export type { UpdateContextType } from './parse.js';
|
|
9
|
+
export * from './pre-checkout-query.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
|
|
2
|
+
globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
|
|
3
|
+
console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
|
|
4
|
+
console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
|
|
5
|
+
}
|
|
6
|
+
"use strict";
|
|
7
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
+
const core = require("@mtcute/core");
|
|
9
|
+
class InlineQueryContext extends core.InlineQuery {
|
|
10
|
+
constructor(client, query) {
|
|
11
|
+
super(query.raw, query._peers);
|
|
12
|
+
this.client = client;
|
|
13
|
+
}
|
|
14
|
+
_name = "inline_query";
|
|
15
|
+
/** Answer to this inline query */
|
|
16
|
+
answer(...params) {
|
|
17
|
+
return this.client.answerInlineQuery(this.id, ...params);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.InlineQueryContext = InlineQueryContext;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ParametersSkip1, InlineQuery } from '@mtcute/core';
|
|
2
|
+
import { TelegramClient } from '@mtcute/core/client.js';
|
|
3
|
+
import { UpdateContext } from './base.js';
|
|
4
|
+
/**
|
|
5
|
+
* Context of an inline query update.
|
|
6
|
+
*
|
|
7
|
+
* This is a subclass of {@link InlineQuery}, so all its fields are also available.
|
|
8
|
+
*/
|
|
9
|
+
export declare class InlineQueryContext extends InlineQuery implements UpdateContext<InlineQuery> {
|
|
10
|
+
readonly client: TelegramClient;
|
|
11
|
+
readonly _name: "inline_query";
|
|
12
|
+
constructor(client: TelegramClient, query: InlineQuery);
|
|
13
|
+
/** Answer to this inline query */
|
|
14
|
+
answer(...params: ParametersSkip1<TelegramClient['answerInlineQuery']>): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { InlineQuery } from "@mtcute/core";
|
|
2
|
+
class InlineQueryContext extends InlineQuery {
|
|
3
|
+
constructor(client, query) {
|
|
4
|
+
super(query.raw, query._peers);
|
|
5
|
+
this.client = client;
|
|
6
|
+
}
|
|
7
|
+
_name = "inline_query";
|
|
8
|
+
/** Answer to this inline query */
|
|
9
|
+
answer(...params) {
|
|
10
|
+
return this.client.answerInlineQuery(this.id, ...params);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
InlineQueryContext
|
|
15
|
+
};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
|
|
2
|
+
globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
|
|
3
|
+
console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
|
|
4
|
+
console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
|
|
5
|
+
}
|
|
6
|
+
"use strict";
|
|
7
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
+
const core = require("@mtcute/core");
|
|
9
|
+
class MessageContext extends core.Message {
|
|
10
|
+
constructor(client, message) {
|
|
11
|
+
const msg = Array.isArray(message) ? message[message.length - 1] : message;
|
|
12
|
+
super(msg.raw, msg._peers, msg.isScheduled);
|
|
13
|
+
this.client = client;
|
|
14
|
+
this.messages = Array.isArray(message) ? message.map((it) => new MessageContext(client, it)) : [this];
|
|
15
|
+
this.isMessageGroup = Array.isArray(message);
|
|
16
|
+
}
|
|
17
|
+
// this is primarily for proper types in filters, so don't bother much with actual value
|
|
18
|
+
_name = "new_message";
|
|
19
|
+
/**
|
|
20
|
+
* List of messages in the message group.
|
|
21
|
+
*
|
|
22
|
+
* For other updates, this is a list with a single element (`this`).
|
|
23
|
+
*/
|
|
24
|
+
messages;
|
|
25
|
+
/** Whether this update is about a message group */
|
|
26
|
+
isMessageGroup;
|
|
27
|
+
/**
|
|
28
|
+
* Get complete information about {@link sender}
|
|
29
|
+
*
|
|
30
|
+
* Learn more: [Incomplete peers](https://mtcute.dev/guide/topics/peers.html#incomplete-peers)
|
|
31
|
+
*/
|
|
32
|
+
async getCompleteSender() {
|
|
33
|
+
if (!this.sender.isMin) return this.sender;
|
|
34
|
+
let res;
|
|
35
|
+
if (this.sender.type === "user") {
|
|
36
|
+
res = await this.client.getUser(this.sender);
|
|
37
|
+
} else {
|
|
38
|
+
res = await this.client.getChat(this.sender);
|
|
39
|
+
}
|
|
40
|
+
if (!res) throw new core.MtPeerNotFoundError("Failed to fetch sender");
|
|
41
|
+
Object.defineProperty(this, "sender", { value: res });
|
|
42
|
+
return res;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get complete information about {@link chat}
|
|
46
|
+
*
|
|
47
|
+
* Learn more: [Incomplete peers](https://mtcute.dev/guide/topics/peers.html#incomplete-peers)
|
|
48
|
+
*/
|
|
49
|
+
async getCompleteChat() {
|
|
50
|
+
if (!this.chat.isMin) return this.chat;
|
|
51
|
+
let res;
|
|
52
|
+
if (this.chat.type === "user") {
|
|
53
|
+
res = await this.client.getUser(this.chat);
|
|
54
|
+
} else {
|
|
55
|
+
res = await this.client.getChat(this.chat);
|
|
56
|
+
}
|
|
57
|
+
if (!res) throw new core.MtPeerNotFoundError("Failed to fetch chat");
|
|
58
|
+
Object.defineProperty(this, "chat", { value: res });
|
|
59
|
+
return res;
|
|
60
|
+
}
|
|
61
|
+
/** Get a message that this message is a reply to */
|
|
62
|
+
getReplyTo() {
|
|
63
|
+
return this.client.getReplyTo(this);
|
|
64
|
+
}
|
|
65
|
+
/** If this is a channel post, get its automatic forward in the discussion group */
|
|
66
|
+
getDiscussionMessage() {
|
|
67
|
+
return this.client.getDiscussionMessage({ chatId: this.chat.inputPeer, message: this.id });
|
|
68
|
+
}
|
|
69
|
+
/** Get all custom emojis contained in this message (message group), if any */
|
|
70
|
+
getCustomEmojis() {
|
|
71
|
+
return this.client.getCustomEmojisFromMessages(this.messages);
|
|
72
|
+
}
|
|
73
|
+
/** Send a text message to the same chat (and topic, if applicable) as a given message */
|
|
74
|
+
answerText(...params) {
|
|
75
|
+
return this.client.answerText(this, ...params);
|
|
76
|
+
}
|
|
77
|
+
/** Send a media to the same chat (and topic, if applicable) as a given message */
|
|
78
|
+
answerMedia(...params) {
|
|
79
|
+
return this.client.answerMedia(this, ...params);
|
|
80
|
+
}
|
|
81
|
+
/** Send a media group to the same chat (and topic, if applicable) as a given message */
|
|
82
|
+
answerMediaGroup(...params) {
|
|
83
|
+
return this.client.answerMediaGroup(this, ...params);
|
|
84
|
+
}
|
|
85
|
+
/** Send a text message in reply to this message */
|
|
86
|
+
replyText(...params) {
|
|
87
|
+
return this.client.replyText(this, ...params);
|
|
88
|
+
}
|
|
89
|
+
/** Send a media in reply to this message */
|
|
90
|
+
replyMedia(...params) {
|
|
91
|
+
return this.client.replyMedia(this, ...params);
|
|
92
|
+
}
|
|
93
|
+
/** Send a media group in reply to this message */
|
|
94
|
+
replyMediaGroup(...params) {
|
|
95
|
+
return this.client.replyMediaGroup(this, ...params);
|
|
96
|
+
}
|
|
97
|
+
/** Send a text message in reply to this message */
|
|
98
|
+
quoteWithText(params) {
|
|
99
|
+
return this.client.quoteWithText(this, params);
|
|
100
|
+
}
|
|
101
|
+
/** Send a media in reply to this message */
|
|
102
|
+
quoteWithMedia(params) {
|
|
103
|
+
return this.client.quoteWithMedia(this, params);
|
|
104
|
+
}
|
|
105
|
+
/** Send a media group in reply to this message */
|
|
106
|
+
quoteWithMediaGroup(params) {
|
|
107
|
+
return this.client.quoteWithMediaGroup(this, params);
|
|
108
|
+
}
|
|
109
|
+
/** Send a text as a comment to this message */
|
|
110
|
+
commentText(...params) {
|
|
111
|
+
return this.client.commentText(this, ...params);
|
|
112
|
+
}
|
|
113
|
+
/** Send a media as a comment to this message */
|
|
114
|
+
commentMedia(...params) {
|
|
115
|
+
return this.client.commentMedia(this, ...params);
|
|
116
|
+
}
|
|
117
|
+
/** Send a media group as a comment to this message */
|
|
118
|
+
commentMediaGroup(...params) {
|
|
119
|
+
return this.client.commentMediaGroup(this, ...params);
|
|
120
|
+
}
|
|
121
|
+
/** Delete this message (message group) */
|
|
122
|
+
delete(params) {
|
|
123
|
+
return this.client.deleteMessagesById(
|
|
124
|
+
this.chat.inputPeer,
|
|
125
|
+
this.messages.map((it) => it.id),
|
|
126
|
+
params
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
/** Pin this message */
|
|
130
|
+
pin(params) {
|
|
131
|
+
return this.client.pinMessage({
|
|
132
|
+
chatId: this.chat.inputPeer,
|
|
133
|
+
message: this.id,
|
|
134
|
+
...params
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/** Unpin this message */
|
|
138
|
+
unpin() {
|
|
139
|
+
return this.client.unpinMessage({
|
|
140
|
+
chatId: this.chat.inputPeer,
|
|
141
|
+
message: this.id
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/** Edit this message */
|
|
145
|
+
edit(params) {
|
|
146
|
+
return this.client.editMessage({
|
|
147
|
+
chatId: this.chat.inputPeer,
|
|
148
|
+
message: this.id,
|
|
149
|
+
...params
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/** Forward this message (message group) */
|
|
153
|
+
forwardTo(params) {
|
|
154
|
+
return this.client.forwardMessagesById({
|
|
155
|
+
fromChatId: this.chat.inputPeer,
|
|
156
|
+
messages: this.messages.map((it) => it.id),
|
|
157
|
+
...params
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/** Send a copy of this message (message group) */
|
|
161
|
+
copy(params) {
|
|
162
|
+
if (this.isMessageGroup) {
|
|
163
|
+
return this.client.sendCopyGroup({
|
|
164
|
+
messages: this.messages,
|
|
165
|
+
...params
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return this.client.sendCopy({
|
|
169
|
+
message: this,
|
|
170
|
+
...params
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/** React to this message */
|
|
174
|
+
react(params) {
|
|
175
|
+
return this.client.sendReaction({
|
|
176
|
+
chatId: this.chat.inputPeer,
|
|
177
|
+
message: this.id,
|
|
178
|
+
...params
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
exports.MessageContext = MessageContext;
|