@mtcute/dispatcher 0.16.7 → 0.16.13
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/{cjs/callback-data-builder.d.ts → callback-data-builder.d.ts} +2 -2
- package/callback-data-builder.test.d.ts +1 -0
- package/{esm/context → context}/base.d.ts +2 -2
- package/{esm/context → context}/business-message.d.ts +5 -6
- package/{esm/context → context}/callback-query.d.ts +6 -7
- package/{cjs/context → context}/chat-join-request.d.ts +3 -3
- package/{esm/context → context}/chosen-inline-result.d.ts +3 -3
- package/{esm/context → context}/inline-query.d.ts +4 -5
- package/{cjs/context → context}/message.d.ts +11 -6
- package/{cjs/context → context}/parse.d.ts +3 -3
- package/{esm/context → context}/pre-checkout-query.d.ts +3 -3
- package/{esm/context → context}/scene-transition.d.ts +1 -1
- package/{cjs/dispatcher.d.ts → dispatcher.d.ts} +9 -10
- package/{cjs/filters → filters}/bots.d.ts +4 -4
- package/filters/bots.test.d.ts +1 -0
- package/{cjs/filters → filters}/chat.d.ts +3 -3
- package/{esm/filters → filters}/group.d.ts +4 -4
- package/{cjs/filters → filters}/logic.d.ts +1 -1
- package/filters/logic.test.d.ts +1 -0
- package/{esm/filters → filters}/message.d.ts +9 -5
- package/{cjs/filters → filters}/state.d.ts +2 -2
- package/{esm/filters → filters}/text.d.ts +3 -3
- package/{cjs/filters → filters}/types.d.ts +2 -2
- package/{cjs/filters → filters}/updates.d.ts +2 -2
- package/{cjs/filters → filters}/user.d.ts +3 -4
- package/{cjs/handler.d.ts → handler.d.ts} +5 -5
- package/index.cjs +2534 -0
- package/index.d.ts +8 -1
- package/index.js +2529 -1
- package/package.json +28 -24
- package/{cjs/state → state}/key.d.ts +3 -3
- package/state/provider.d.ts +5 -0
- package/{cjs/state → state}/providers/memory.d.ts +3 -4
- package/{esm/state → state}/providers/sqlite.d.ts +3 -3
- package/{cjs/state → state}/repository.d.ts +1 -1
- package/{esm/state → state}/service.d.ts +2 -2
- package/{cjs/state → state}/update-state.d.ts +2 -2
- package/{esm/wizard.d.ts → wizard.d.ts} +5 -6
- package/cjs/callback-data-builder.js +0 -141
- package/cjs/callback-data-builder.js.map +0 -1
- package/cjs/context/base.d.ts +0 -9
- package/cjs/context/base.js +0 -3
- package/cjs/context/base.js.map +0 -1
- package/cjs/context/business-message.d.ts +0 -61
- package/cjs/context/business-message.js +0 -146
- package/cjs/context/business-message.js.map +0 -1
- package/cjs/context/callback-query.d.ts +0 -63
- package/cjs/context/callback-query.js +0 -109
- package/cjs/context/callback-query.js.map +0 -1
- package/cjs/context/chat-join-request.js +0 -35
- package/cjs/context/chat-join-request.js.map +0 -1
- package/cjs/context/chosen-inline-result.d.ts +0 -22
- package/cjs/context/chosen-inline-result.js +0 -36
- package/cjs/context/chosen-inline-result.js.map +0 -1
- package/cjs/context/index.js +0 -25
- package/cjs/context/index.js.map +0 -1
- package/cjs/context/inline-query.d.ts +0 -16
- package/cjs/context/inline-query.js +0 -23
- package/cjs/context/inline-query.js.map +0 -1
- package/cjs/context/message.js +0 -171
- package/cjs/context/message.js.map +0 -1
- package/cjs/context/parse.js +0 -42
- package/cjs/context/parse.js.map +0 -1
- package/cjs/context/pre-checkout-query.d.ts +0 -17
- package/cjs/context/pre-checkout-query.js +0 -27
- package/cjs/context/pre-checkout-query.js.map +0 -1
- package/cjs/context/scene-transition.d.ts +0 -24
- package/cjs/context/scene-transition.js +0 -52
- package/cjs/context/scene-transition.js.map +0 -1
- package/cjs/dispatcher.js +0 -908
- package/cjs/dispatcher.js.map +0 -1
- package/cjs/filters/bots.js +0 -135
- package/cjs/filters/bots.js.map +0 -1
- package/cjs/filters/bundle.js +0 -27
- package/cjs/filters/bundle.js.map +0 -1
- package/cjs/filters/chat.js +0 -56
- package/cjs/filters/chat.js.map +0 -1
- package/cjs/filters/group.d.ts +0 -26
- package/cjs/filters/group.js +0 -69
- package/cjs/filters/group.js.map +0 -1
- package/cjs/filters/index.js +0 -29
- package/cjs/filters/index.js.map +0 -1
- package/cjs/filters/logic.js +0 -112
- package/cjs/filters/logic.js.map +0 -1
- package/cjs/filters/message.d.ts +0 -215
- package/cjs/filters/message.js +0 -191
- package/cjs/filters/message.js.map +0 -1
- package/cjs/filters/state.js +0 -33
- package/cjs/filters/state.js.map +0 -1
- package/cjs/filters/text.d.ts +0 -64
- package/cjs/filters/text.js +0 -136
- package/cjs/filters/text.js.map +0 -1
- package/cjs/filters/types.js +0 -3
- package/cjs/filters/types.js.map +0 -1
- package/cjs/filters/updates.js +0 -40
- package/cjs/filters/updates.js.map +0 -1
- package/cjs/filters/user.js +0 -77
- package/cjs/filters/user.js.map +0 -1
- package/cjs/handler.js +0 -4
- package/cjs/handler.js.map +0 -1
- package/cjs/index.js +0 -31
- package/cjs/index.js.map +0 -1
- package/cjs/package.json +0 -3
- package/cjs/propagation.js +0 -27
- package/cjs/propagation.js.map +0 -1
- package/cjs/state/index.js +0 -22
- package/cjs/state/index.js.map +0 -1
- package/cjs/state/key.js +0 -43
- package/cjs/state/key.js.map +0 -1
- package/cjs/state/provider.d.ts +0 -5
- package/cjs/state/provider.js +0 -3
- package/cjs/state/provider.js.map +0 -1
- package/cjs/state/providers/index.js +0 -19
- package/cjs/state/providers/index.js.map +0 -1
- package/cjs/state/providers/memory.js +0 -81
- package/cjs/state/providers/memory.js.map +0 -1
- package/cjs/state/providers/sqlite.d.ts +0 -28
- package/cjs/state/providers/sqlite.js +0 -100
- package/cjs/state/providers/sqlite.js.map +0 -1
- package/cjs/state/repository.js +0 -3
- package/cjs/state/repository.js.map +0 -1
- package/cjs/state/service.d.ts +0 -20
- package/cjs/state/service.js +0 -70
- package/cjs/state/service.js.map +0 -1
- package/cjs/state/update-state.js +0 -219
- package/cjs/state/update-state.js.map +0 -1
- package/cjs/wizard.d.ts +0 -65
- package/cjs/wizard.js +0 -105
- package/cjs/wizard.js.map +0 -1
- package/esm/callback-data-builder.d.ts +0 -49
- package/esm/callback-data-builder.js +0 -137
- package/esm/callback-data-builder.js.map +0 -1
- package/esm/context/base.js +0 -2
- package/esm/context/base.js.map +0 -1
- package/esm/context/business-message.js +0 -142
- package/esm/context/business-message.js.map +0 -1
- package/esm/context/callback-query.js +0 -103
- package/esm/context/callback-query.js.map +0 -1
- package/esm/context/chat-join-request.d.ts +0 -17
- package/esm/context/chat-join-request.js +0 -31
- package/esm/context/chat-join-request.js.map +0 -1
- package/esm/context/chosen-inline-result.js +0 -32
- package/esm/context/chosen-inline-result.js.map +0 -1
- package/esm/context/index.d.ts +0 -9
- package/esm/context/index.js +0 -9
- package/esm/context/index.js.map +0 -1
- package/esm/context/inline-query.js +0 -19
- package/esm/context/inline-query.js.map +0 -1
- package/esm/context/message.d.ts +0 -77
- package/esm/context/message.js +0 -167
- package/esm/context/message.js.map +0 -1
- package/esm/context/parse.d.ts +0 -13
- package/esm/context/parse.js +0 -39
- package/esm/context/parse.js.map +0 -1
- package/esm/context/pre-checkout-query.js +0 -23
- package/esm/context/pre-checkout-query.js.map +0 -1
- package/esm/context/scene-transition.js +0 -48
- package/esm/context/scene-transition.js.map +0 -1
- package/esm/dispatcher.d.ts +0 -881
- package/esm/dispatcher.js +0 -904
- package/esm/dispatcher.js.map +0 -1
- package/esm/filters/bots.d.ts +0 -64
- package/esm/filters/bots.js +0 -131
- package/esm/filters/bots.js.map +0 -1
- package/esm/filters/bundle.d.ts +0 -10
- package/esm/filters/bundle.js +0 -11
- package/esm/filters/bundle.js.map +0 -1
- package/esm/filters/chat.d.ts +0 -27
- package/esm/filters/chat.js +0 -51
- package/esm/filters/chat.js.map +0 -1
- package/esm/filters/group.js +0 -65
- package/esm/filters/group.js.map +0 -1
- package/esm/filters/index.d.ts +0 -4
- package/esm/filters/index.js +0 -3
- package/esm/filters/index.js.map +0 -1
- package/esm/filters/logic.d.ts +0 -29
- package/esm/filters/logic.js +0 -105
- package/esm/filters/logic.js.map +0 -1
- package/esm/filters/message.js +0 -168
- package/esm/filters/message.js.map +0 -1
- package/esm/filters/state.d.ts +0 -15
- package/esm/filters/state.js +0 -28
- package/esm/filters/state.js.map +0 -1
- package/esm/filters/text.js +0 -129
- package/esm/filters/text.js.map +0 -1
- package/esm/filters/types.d.ts +0 -91
- package/esm/filters/types.js +0 -2
- package/esm/filters/types.js.map +0 -1
- package/esm/filters/updates.d.ts +0 -39
- package/esm/filters/updates.js +0 -34
- package/esm/filters/updates.js.map +0 -1
- package/esm/filters/user.d.ts +0 -25
- package/esm/filters/user.js +0 -71
- package/esm/filters/user.js.map +0 -1
- package/esm/handler.d.ts +0 -41
- package/esm/handler.js +0 -3
- package/esm/handler.js.map +0 -1
- package/esm/index.d.ts +0 -8
- package/esm/index.js +0 -9
- package/esm/index.js.map +0 -1
- package/esm/propagation.d.ts +0 -22
- package/esm/propagation.js +0 -24
- package/esm/propagation.js.map +0 -1
- package/esm/state/index.d.ts +0 -5
- package/esm/state/index.js +0 -6
- package/esm/state/index.js.map +0 -1
- package/esm/state/key.d.ts +0 -24
- package/esm/state/key.js +0 -39
- package/esm/state/key.js.map +0 -1
- package/esm/state/provider.d.ts +0 -5
- package/esm/state/provider.js +0 -2
- package/esm/state/provider.js.map +0 -1
- package/esm/state/providers/index.d.ts +0 -2
- package/esm/state/providers/index.js +0 -3
- package/esm/state/providers/index.js.map +0 -1
- package/esm/state/providers/memory.d.ts +0 -30
- package/esm/state/providers/memory.js +0 -77
- package/esm/state/providers/memory.js.map +0 -1
- package/esm/state/providers/sqlite.js +0 -96
- package/esm/state/providers/sqlite.js.map +0 -1
- package/esm/state/repository.d.ts +0 -62
- package/esm/state/repository.js +0 -2
- package/esm/state/repository.js.map +0 -1
- package/esm/state/service.js +0 -66
- package/esm/state/service.js.map +0 -1
- package/esm/state/update-state.d.ts +0 -151
- package/esm/state/update-state.js +0 -214
- package/esm/state/update-state.js.map +0 -1
- package/esm/wizard.js +0 -101
- package/esm/wizard.js.map +0 -1
- /package/{cjs/context → context}/index.d.ts +0 -0
- /package/{cjs/filters → filters}/bundle.d.ts +0 -0
- /package/{cjs/filters → filters}/index.d.ts +0 -0
- /package/{cjs/index.d.ts → index.d.cts} +0 -0
- /package/{cjs/propagation.d.ts → propagation.d.ts} +0 -0
- /package/{cjs/state → state}/index.d.ts +0 -0
- /package/{cjs/state → state}/providers/index.d.ts +0 -0
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BusinessCallbackQueryContext = exports.InlineCallbackQueryContext = exports.CallbackQueryContext = void 0;
|
|
4
|
-
const core_1 = require("@mtcute/core");
|
|
5
|
-
/**
|
|
6
|
-
* Context of a callback query update.
|
|
7
|
-
*
|
|
8
|
-
* This is a subclass of {@link CallbackQuery}, so all its fields are also available.
|
|
9
|
-
*/
|
|
10
|
-
class CallbackQueryContext extends core_1.CallbackQuery {
|
|
11
|
-
client;
|
|
12
|
-
_name = 'callback_query';
|
|
13
|
-
constructor(client, query) {
|
|
14
|
-
super(query.raw, query._peers);
|
|
15
|
-
this.client = client;
|
|
16
|
-
}
|
|
17
|
-
/** Answer to this callback query */
|
|
18
|
-
answer(params) {
|
|
19
|
-
return this.client.answerCallbackQuery(this.id, params);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Get the message containing the callback button being clicked.
|
|
23
|
-
*
|
|
24
|
-
* Note that the message may have been deleted, in which case
|
|
25
|
-
* `null` will be returned.
|
|
26
|
-
*/
|
|
27
|
-
async getMessage() {
|
|
28
|
-
return this.client.getCallbackQueryMessage(this);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Edit the message that contained the callback button that was clicked.
|
|
32
|
-
*/
|
|
33
|
-
async editMessage(params) {
|
|
34
|
-
return this.client.editMessage({
|
|
35
|
-
chatId: this.raw.peer,
|
|
36
|
-
message: this.raw.msgId,
|
|
37
|
-
...params,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Shortcut for getting the message and editing it.
|
|
42
|
-
*/
|
|
43
|
-
async editMessageWith(handler) {
|
|
44
|
-
const msg = await this.getMessage();
|
|
45
|
-
if (!msg)
|
|
46
|
-
return;
|
|
47
|
-
const res = await handler(msg);
|
|
48
|
-
if (!res)
|
|
49
|
-
return;
|
|
50
|
-
return this.editMessage(res);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.CallbackQueryContext = CallbackQueryContext;
|
|
54
|
-
/**
|
|
55
|
-
* Context of an inline-originated callback query update.
|
|
56
|
-
*
|
|
57
|
-
* This is a subclass of {@link InlineCallbackQuery}, so all its fields are also available.
|
|
58
|
-
*/
|
|
59
|
-
class InlineCallbackQueryContext extends core_1.InlineCallbackQuery {
|
|
60
|
-
client;
|
|
61
|
-
_name = 'inline_callback_query';
|
|
62
|
-
constructor(client, query) {
|
|
63
|
-
super(query.raw, query._peers);
|
|
64
|
-
this.client = client;
|
|
65
|
-
}
|
|
66
|
-
/** Answer to this callback query */
|
|
67
|
-
answer(params) {
|
|
68
|
-
return this.client.answerCallbackQuery(this.id, params);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Edit the message that contained the callback button that was clicked.
|
|
72
|
-
*/
|
|
73
|
-
async editMessage(params) {
|
|
74
|
-
return this.client.editInlineMessage({
|
|
75
|
-
messageId: this.raw.msgId,
|
|
76
|
-
...params,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.InlineCallbackQueryContext = InlineCallbackQueryContext;
|
|
81
|
-
/**
|
|
82
|
-
* Context of an callback query update originated from a business connection message
|
|
83
|
-
*
|
|
84
|
-
* This is a subclass of {@link BusinessCallbackQuery}, so all its fields are also available.
|
|
85
|
-
*/
|
|
86
|
-
class BusinessCallbackQueryContext extends core_1.BusinessCallbackQuery {
|
|
87
|
-
client;
|
|
88
|
-
_name = 'business_callback_query';
|
|
89
|
-
constructor(client, query) {
|
|
90
|
-
super(query.raw, query._peers);
|
|
91
|
-
this.client = client;
|
|
92
|
-
}
|
|
93
|
-
/** Answer to this callback query */
|
|
94
|
-
answer(params) {
|
|
95
|
-
return this.client.answerCallbackQuery(this.id, params);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Edit the message that contained the callback button that was clicked.
|
|
99
|
-
*/
|
|
100
|
-
async editMessage(params) {
|
|
101
|
-
return this.client.editMessage({
|
|
102
|
-
message: this.message,
|
|
103
|
-
businessConnectionId: this.connectionId,
|
|
104
|
-
...params,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
exports.BusinessCallbackQueryContext = BusinessCallbackQueryContext;
|
|
109
|
-
//# sourceMappingURL=callback-query.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"callback-query.js","sourceRoot":"","sources":["../../../src/context/callback-query.ts"],"names":[],"mappings":";;;AACA,uCAAwF;AAKxF;;;;GAIG;AACH,MAAa,oBAAqB,SAAQ,oBAAa;IAItC;IAHJ,KAAK,GAAG,gBAAgB,CAAA;IAEjC,YACa,MAAsB,EAC/B,KAAoB;QAEpB,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;QAHrB,WAAM,GAAN,MAAM,CAAgB;IAInC,CAAC;IAED,oCAAoC;IACpC,MAAM,CAAC,MAA4D;QAC/D,OAAO,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;IAC3D,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,UAAU;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAA;IACpD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,MAA6E;QAC3F,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;YAC3B,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI;YACrB,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK;YACvB,GA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,MAAM,CAAC,MAA4D;QAC/D,OAAO,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;IAC3D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,MAA6E;QAC3F,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,oBAAoB,EAAE,IAAI,CAAC,YAAY;YACvC,GAAG,MAAM;SACZ,CAAC,CAAA;IACN,CAAC;CACJ;AA3BD,oEA2BC","sourcesContent":["import type { MaybePromise, Message } from '@mtcute/core'\nimport { BusinessCallbackQuery, CallbackQuery, InlineCallbackQuery } from '@mtcute/core'\nimport type { TelegramClient } from '@mtcute/core/client.js'\n\nimport type { UpdateContext } from './base.js'\n\n/**\n * Context of a callback query update.\n *\n * This is a subclass of {@link CallbackQuery}, so all its fields are also available.\n */\nexport class CallbackQueryContext extends CallbackQuery implements UpdateContext<CallbackQuery> {\n readonly _name = 'callback_query'\n\n constructor(\n readonly client: TelegramClient,\n query: CallbackQuery,\n ) {\n super(query.raw, query._peers)\n }\n\n /** Answer to this callback query */\n answer(params: Parameters<TelegramClient['answerCallbackQuery']>[1]): Promise<void> {\n return this.client.answerCallbackQuery(this.id, params)\n }\n\n /**\n * Get the message containing the callback button being clicked.\n *\n * Note that the message may have been deleted, in which case\n * `null` will be returned.\n */\n async getMessage(): Promise<Message | null> {\n return this.client.getCallbackQueryMessage(this)\n }\n\n /**\n * Edit the message that contained the callback button that was clicked.\n */\n async editMessage(params: Omit<Parameters<TelegramClient['editInlineMessage']>[0], 'messageId'>): Promise<Message> {\n return this.client.editMessage({\n chatId: this.raw.peer,\n message: this.raw.msgId,\n ...params,\n })\n }\n\n /**\n * Shortcut for getting the message and editing it.\n */\n async editMessageWith(\n handler: (msg: Message) => MaybePromise<Parameters<CallbackQueryContext['editMessage']>[0]>,\n ): Promise<Message | undefined> {\n const msg = await this.getMessage()\n if (!msg) return\n\n const res = await handler(msg)\n if (!res) return\n\n return this.editMessage(res)\n }\n}\n\n/**\n * Context of an inline-originated callback query update.\n *\n * This is a subclass of {@link InlineCallbackQuery}, so all its fields are also available.\n */\nexport class InlineCallbackQueryContext extends InlineCallbackQuery implements UpdateContext<InlineCallbackQuery> {\n readonly _name = 'inline_callback_query'\n\n constructor(\n readonly client: TelegramClient,\n query: InlineCallbackQuery,\n ) {\n super(query.raw, query._peers)\n }\n\n /** Answer to this callback query */\n answer(params: Parameters<TelegramClient['answerCallbackQuery']>[1]): Promise<void> {\n return this.client.answerCallbackQuery(this.id, params)\n }\n\n /**\n * Edit the message that contained the callback button that was clicked.\n */\n async editMessage(params: Omit<Parameters<TelegramClient['editInlineMessage']>[0], 'messageId'>): Promise<void> {\n return this.client.editInlineMessage({\n messageId: this.raw.msgId,\n ...params,\n })\n }\n}\n\n/**\n * Context of an callback query update originated from a business connection message\n *\n * This is a subclass of {@link BusinessCallbackQuery}, so all its fields are also available.\n */\nexport class BusinessCallbackQueryContext\n extends BusinessCallbackQuery\n implements UpdateContext<BusinessCallbackQuery> {\n readonly _name = 'business_callback_query'\n\n constructor(\n readonly client: TelegramClient,\n query: BusinessCallbackQuery,\n ) {\n super(query.raw, query._peers)\n }\n\n /** Answer to this callback query */\n answer(params: Parameters<TelegramClient['answerCallbackQuery']>[1]): Promise<void> {\n return this.client.answerCallbackQuery(this.id, params)\n }\n\n /**\n * Edit the message that contained the callback button that was clicked.\n */\n async editMessage(params: Omit<Parameters<TelegramClient['editInlineMessage']>[0], 'messageId'>): Promise<Message> {\n return this.client.editMessage({\n message: this.message,\n businessConnectionId: this.connectionId,\n ...params,\n })\n }\n}\n"]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ChatJoinRequestUpdateContext = void 0;
|
|
4
|
-
const core_1 = require("@mtcute/core");
|
|
5
|
-
/**
|
|
6
|
-
* Context of a chat join request update (for bots).
|
|
7
|
-
*
|
|
8
|
-
* This is a subclass of {@link BotChatJoinRequestUpdate}, so all its fields are also available.
|
|
9
|
-
*/
|
|
10
|
-
class ChatJoinRequestUpdateContext extends core_1.BotChatJoinRequestUpdate {
|
|
11
|
-
client;
|
|
12
|
-
_name = 'bot_chat_join_request';
|
|
13
|
-
constructor(client, update) {
|
|
14
|
-
super(update.raw, update._peers);
|
|
15
|
-
this.client = client;
|
|
16
|
-
}
|
|
17
|
-
/** Approve the request */
|
|
18
|
-
approve() {
|
|
19
|
-
return this.client.hideJoinRequest({
|
|
20
|
-
action: 'approve',
|
|
21
|
-
user: this.user.inputPeer,
|
|
22
|
-
chatId: this.chat.inputPeer,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
/** Decline the request */
|
|
26
|
-
decline() {
|
|
27
|
-
return this.client.hideJoinRequest({
|
|
28
|
-
action: 'decline',
|
|
29
|
-
user: this.user.inputPeer,
|
|
30
|
-
chatId: this.chat.inputPeer,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.ChatJoinRequestUpdateContext = ChatJoinRequestUpdateContext;
|
|
35
|
-
//# sourceMappingURL=chat-join-request.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chat-join-request.js","sourceRoot":"","sources":["../../../src/context/chat-join-request.ts"],"names":[],"mappings":";;;AAAA,uCAAuD;AAKvD;;;;GAIG;AACH,MAAa,4BACT,SAAQ,+BAAwB;IAKnB;IAHJ,KAAK,GAAG,uBAAuB,CAAA;IAExC,YACa,MAAsB,EAC/B,MAAgC;QAEhC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;QAHvB,WAAM,GAAN,MAAM,CAAgB;IAInC,CAAC;IAED,0BAA0B;IAC1B,OAAO;QACH,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;YAC/B,MAAM,EAAE,SAAS;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS;SAC9B,CAAC,CAAA;IACN,CAAC;IAED,0BAA0B;IAC1B,OAAO;QACH,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;YAC/B,MAAM,EAAE,SAAS;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS;SAC9B,CAAC,CAAA;IACN,CAAC;CACJ;AA7BD,oEA6BC","sourcesContent":["import { BotChatJoinRequestUpdate } from '@mtcute/core'\nimport type { TelegramClient } from '@mtcute/core/client.js'\n\nimport type { UpdateContext } from './base.js'\n\n/**\n * Context of a chat join request update (for bots).\n *\n * This is a subclass of {@link BotChatJoinRequestUpdate}, so all its fields are also available.\n */\nexport class ChatJoinRequestUpdateContext\n extends BotChatJoinRequestUpdate\n implements UpdateContext<BotChatJoinRequestUpdate> {\n readonly _name = 'bot_chat_join_request'\n\n constructor(\n readonly client: TelegramClient,\n update: BotChatJoinRequestUpdate,\n ) {\n super(update.raw, update._peers)\n }\n\n /** Approve the request */\n approve(): Promise<void> {\n return this.client.hideJoinRequest({\n action: 'approve',\n user: this.user.inputPeer,\n chatId: this.chat.inputPeer,\n })\n }\n\n /** Decline the request */\n decline(): Promise<void> {\n return this.client.hideJoinRequest({\n action: 'decline',\n user: this.user.inputPeer,\n chatId: this.chat.inputPeer,\n })\n }\n}\n"]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ChosenInlineResult } from '@mtcute/core';
|
|
2
|
-
import type { TelegramClient } from '@mtcute/core/client.js';
|
|
3
|
-
import type { UpdateContext } from './base.js';
|
|
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
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ChosenInlineResultContext = void 0;
|
|
4
|
-
const core_1 = require("@mtcute/core");
|
|
5
|
-
/**
|
|
6
|
-
* Context of a chosen inline result update.
|
|
7
|
-
*
|
|
8
|
-
* This is a subclass of {@link ChosenInlineResult}, so all its fields are also available.
|
|
9
|
-
*
|
|
10
|
-
* > **Note**: To receive these updates, you must enable
|
|
11
|
-
* > Inline feedback in [@BotFather](//t.me/botfather)
|
|
12
|
-
*/
|
|
13
|
-
class ChosenInlineResultContext extends core_1.ChosenInlineResult {
|
|
14
|
-
client;
|
|
15
|
-
_name = 'chosen_inline_result';
|
|
16
|
-
constructor(client, result) {
|
|
17
|
-
super(result.raw, result._peers);
|
|
18
|
-
this.client = client;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Edit the message that was sent when this inline result that was chosen.
|
|
22
|
-
*
|
|
23
|
-
* > **Note**: This method can only be used if the message contained a reply markup
|
|
24
|
-
*/
|
|
25
|
-
async editMessage(params) {
|
|
26
|
-
if (!this.raw.msgId) {
|
|
27
|
-
throw new core_1.MtArgumentError('No message ID, make sure you have included reply markup!');
|
|
28
|
-
}
|
|
29
|
-
return this.client.editInlineMessage({
|
|
30
|
-
...params,
|
|
31
|
-
messageId: this.raw.msgId,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.ChosenInlineResultContext = ChosenInlineResultContext;
|
|
36
|
-
//# sourceMappingURL=chosen-inline-result.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chosen-inline-result.js","sourceRoot":"","sources":["../../../src/context/chosen-inline-result.ts"],"names":[],"mappings":";;;AAAA,uCAAkE;AAKlE;;;;;;;GAOG;AACH,MAAa,yBAA0B,SAAQ,yBAAkB;IAIhD;IAHJ,KAAK,GAAG,sBAAsB,CAAA;IAEvC,YACa,MAAsB,EAC/B,MAA0B;QAE1B,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;QAHvB,WAAM,GAAN,MAAM,CAAgB;IAInC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW,CAAC,MAA0D;QACxE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;YAClB,MAAM,IAAI,sBAAe,CAAC,0DAA0D,CAAC,CAAA;QACzF,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;YACjC,GAAG,MAAM;YACT,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK;SAC5B,CAAC,CAAA;IACN,CAAC;CACJ;AAzBD,8DAyBC","sourcesContent":["import { ChosenInlineResult, MtArgumentError } from '@mtcute/core'\nimport type { TelegramClient } from '@mtcute/core/client.js'\n\nimport type { UpdateContext } from './base.js'\n\n/**\n * Context of a chosen inline result update.\n *\n * This is a subclass of {@link ChosenInlineResult}, so all its fields are also available.\n *\n * > **Note**: To receive these updates, you must enable\n * > Inline feedback in [@BotFather](//t.me/botfather)\n */\nexport class ChosenInlineResultContext extends ChosenInlineResult implements UpdateContext<ChosenInlineResult> {\n readonly _name = 'chosen_inline_result'\n\n constructor(\n readonly client: TelegramClient,\n result: ChosenInlineResult,\n ) {\n super(result.raw, result._peers)\n }\n\n /**\n * Edit the message that was sent when this inline result that was chosen.\n *\n * > **Note**: This method can only be used if the message contained a reply markup\n */\n async editMessage(params: Parameters<TelegramClient['editInlineMessage']>[0]): Promise<void> {\n if (!this.raw.msgId) {\n throw new MtArgumentError('No message ID, make sure you have included reply markup!')\n }\n\n return this.client.editInlineMessage({\n ...params,\n messageId: this.raw.msgId,\n })\n }\n}\n"]}
|
package/cjs/context/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./base.js"), exports);
|
|
18
|
-
__exportStar(require("./business-message.js"), exports);
|
|
19
|
-
__exportStar(require("./callback-query.js"), exports);
|
|
20
|
-
__exportStar(require("./chat-join-request.js"), exports);
|
|
21
|
-
__exportStar(require("./chosen-inline-result.js"), exports);
|
|
22
|
-
__exportStar(require("./inline-query.js"), exports);
|
|
23
|
-
__exportStar(require("./message.js"), exports);
|
|
24
|
-
__exportStar(require("./pre-checkout-query.js"), exports);
|
|
25
|
-
//# sourceMappingURL=index.js.map
|
package/cjs/context/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/context/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,wDAAqC;AACrC,sDAAmC;AACnC,yDAAsC;AACtC,4DAAyC;AACzC,oDAAiC;AACjC,+CAA4B;AAE5B,0DAAuC","sourcesContent":["export * from './base.js'\nexport * from './business-message.js'\nexport * from './callback-query.js'\nexport * from './chat-join-request.js'\nexport * from './chosen-inline-result.js'\nexport * from './inline-query.js'\nexport * from './message.js'\nexport type { UpdateContextType } from './parse.js'\nexport * from './pre-checkout-query.js'\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ParametersSkip1 } from '@mtcute/core';
|
|
2
|
-
import { InlineQuery } from '@mtcute/core';
|
|
3
|
-
import type { TelegramClient } from '@mtcute/core/client.js';
|
|
4
|
-
import type { UpdateContext } from './base.js';
|
|
5
|
-
/**
|
|
6
|
-
* Context of an inline query update.
|
|
7
|
-
*
|
|
8
|
-
* This is a subclass of {@link InlineQuery}, so all its fields are also available.
|
|
9
|
-
*/
|
|
10
|
-
export declare class InlineQueryContext extends InlineQuery implements UpdateContext<InlineQuery> {
|
|
11
|
-
readonly client: TelegramClient;
|
|
12
|
-
readonly _name = "inline_query";
|
|
13
|
-
constructor(client: TelegramClient, query: InlineQuery);
|
|
14
|
-
/** Answer to this inline query */
|
|
15
|
-
answer(...params: ParametersSkip1<TelegramClient['answerInlineQuery']>): Promise<void>;
|
|
16
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InlineQueryContext = void 0;
|
|
4
|
-
const core_1 = require("@mtcute/core");
|
|
5
|
-
/**
|
|
6
|
-
* Context of an inline query update.
|
|
7
|
-
*
|
|
8
|
-
* This is a subclass of {@link InlineQuery}, so all its fields are also available.
|
|
9
|
-
*/
|
|
10
|
-
class InlineQueryContext extends core_1.InlineQuery {
|
|
11
|
-
client;
|
|
12
|
-
_name = 'inline_query';
|
|
13
|
-
constructor(client, query) {
|
|
14
|
-
super(query.raw, query._peers);
|
|
15
|
-
this.client = client;
|
|
16
|
-
}
|
|
17
|
-
/** Answer to this inline query */
|
|
18
|
-
answer(...params) {
|
|
19
|
-
return this.client.answerInlineQuery(this.id, ...params);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.InlineQueryContext = InlineQueryContext;
|
|
23
|
-
//# sourceMappingURL=inline-query.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inline-query.js","sourceRoot":"","sources":["../../../src/context/inline-query.ts"],"names":[],"mappings":";;;AACA,uCAA0C;AAK1C;;;;GAIG;AACH,MAAa,kBAAmB,SAAQ,kBAAW;IAIlC;IAHJ,KAAK,GAAG,cAAc,CAAA;IAE/B,YACa,MAAsB,EAC/B,KAAkB;QAElB,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;QAHrB,WAAM,GAAN,MAAM,CAAgB;IAInC,CAAC;IAED,kCAAkC;IAClC,MAAM,CAAC,GAAG,MAA4D;QAClE,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,CAAA;IAC5D,CAAC;CACJ;AAdD,gDAcC","sourcesContent":["import type { ParametersSkip1 } from '@mtcute/core'\nimport { InlineQuery } from '@mtcute/core'\nimport type { TelegramClient } from '@mtcute/core/client.js'\n\nimport type { UpdateContext } from './base.js'\n\n/**\n * Context of an inline query update.\n *\n * This is a subclass of {@link InlineQuery}, so all its fields are also available.\n */\nexport class InlineQueryContext extends InlineQuery implements UpdateContext<InlineQuery> {\n readonly _name = 'inline_query'\n\n constructor(\n readonly client: TelegramClient,\n query: InlineQuery,\n ) {\n super(query.raw, query._peers)\n }\n\n /** Answer to this inline query */\n answer(...params: ParametersSkip1<TelegramClient['answerInlineQuery']>): Promise<void> {\n return this.client.answerInlineQuery(this.id, ...params)\n }\n}\n"]}
|
package/cjs/context/message.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageContext = void 0;
|
|
4
|
-
const core_1 = require("@mtcute/core");
|
|
5
|
-
/**
|
|
6
|
-
* Context of a message-related update.
|
|
7
|
-
*
|
|
8
|
-
* This is a subclass of {@link Message}, so all fields
|
|
9
|
-
* of the message are available.
|
|
10
|
-
*
|
|
11
|
-
* For message groups, own fields are related to the last message
|
|
12
|
-
* in the group. To access all messages, use {@link MessageContext#messages}.
|
|
13
|
-
*/
|
|
14
|
-
class MessageContext extends core_1.Message {
|
|
15
|
-
client;
|
|
16
|
-
// this is primarily for proper types in filters, so don't bother much with actual value
|
|
17
|
-
_name = 'new_message';
|
|
18
|
-
/**
|
|
19
|
-
* List of messages in the message group.
|
|
20
|
-
*
|
|
21
|
-
* For other updates, this is a list with a single element (`this`).
|
|
22
|
-
*/
|
|
23
|
-
messages;
|
|
24
|
-
/** Whether this update is about a message group */
|
|
25
|
-
isMessageGroup;
|
|
26
|
-
constructor(client, message) {
|
|
27
|
-
const msg = Array.isArray(message) ? message[message.length - 1] : message;
|
|
28
|
-
super(msg.raw, msg._peers, msg.isScheduled);
|
|
29
|
-
this.client = client;
|
|
30
|
-
this.messages = Array.isArray(message) ? message.map(it => new MessageContext(client, it)) : [this];
|
|
31
|
-
this.isMessageGroup = Array.isArray(message);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Get complete information about {@link sender}
|
|
35
|
-
*
|
|
36
|
-
* Learn more: [Incomplete peers](https://mtcute.dev/guide/topics/peers.html#incomplete-peers)
|
|
37
|
-
*/
|
|
38
|
-
async getCompleteSender() {
|
|
39
|
-
if (!this.sender.isMin)
|
|
40
|
-
return this.sender;
|
|
41
|
-
let res;
|
|
42
|
-
if (this.sender.type === 'user') {
|
|
43
|
-
[res] = await this.client.getUsers(this.sender);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
res = await this.client.getChat(this.sender);
|
|
47
|
-
}
|
|
48
|
-
if (!res)
|
|
49
|
-
throw new core_1.MtPeerNotFoundError('Failed to fetch sender');
|
|
50
|
-
Object.defineProperty(this, 'sender', { value: res });
|
|
51
|
-
return res;
|
|
52
|
-
}
|
|
53
|
-
/** Get a message that this message is a reply to */
|
|
54
|
-
getReplyTo() {
|
|
55
|
-
return this.client.getReplyTo(this);
|
|
56
|
-
}
|
|
57
|
-
/** If this is a channel post, get its automatic forward in the discussion group */
|
|
58
|
-
getDiscussionMessage() {
|
|
59
|
-
return this.client.getDiscussionMessage({ chatId: this.chat.inputPeer, message: this.id });
|
|
60
|
-
}
|
|
61
|
-
/** Get all custom emojis contained in this message (message group), if any */
|
|
62
|
-
getCustomEmojis() {
|
|
63
|
-
return this.client.getCustomEmojisFromMessages(this.messages);
|
|
64
|
-
}
|
|
65
|
-
/** Send a text message to the same chat (and topic, if applicable) as a given message */
|
|
66
|
-
answerText(...params) {
|
|
67
|
-
return this.client.answerText(this, ...params);
|
|
68
|
-
}
|
|
69
|
-
/** Send a media to the same chat (and topic, if applicable) as a given message */
|
|
70
|
-
answerMedia(...params) {
|
|
71
|
-
return this.client.answerMedia(this, ...params);
|
|
72
|
-
}
|
|
73
|
-
/** Send a media group to the same chat (and topic, if applicable) as a given message */
|
|
74
|
-
answerMediaGroup(...params) {
|
|
75
|
-
return this.client.answerMediaGroup(this, ...params);
|
|
76
|
-
}
|
|
77
|
-
/** Send a text message in reply to this message */
|
|
78
|
-
replyText(...params) {
|
|
79
|
-
return this.client.replyText(this, ...params);
|
|
80
|
-
}
|
|
81
|
-
/** Send a media in reply to this message */
|
|
82
|
-
replyMedia(...params) {
|
|
83
|
-
return this.client.replyMedia(this, ...params);
|
|
84
|
-
}
|
|
85
|
-
/** Send a media group in reply to this message */
|
|
86
|
-
replyMediaGroup(...params) {
|
|
87
|
-
return this.client.replyMediaGroup(this, ...params);
|
|
88
|
-
}
|
|
89
|
-
/** Send a text message in reply to this message */
|
|
90
|
-
quoteWithText(params) {
|
|
91
|
-
return this.client.quoteWithText(this, params);
|
|
92
|
-
}
|
|
93
|
-
/** Send a media in reply to this message */
|
|
94
|
-
quoteWithMedia(params) {
|
|
95
|
-
return this.client.quoteWithMedia(this, params);
|
|
96
|
-
}
|
|
97
|
-
/** Send a media group in reply to this message */
|
|
98
|
-
quoteWithMediaGroup(params) {
|
|
99
|
-
return this.client.quoteWithMediaGroup(this, params);
|
|
100
|
-
}
|
|
101
|
-
/** Send a text as a comment to this message */
|
|
102
|
-
commentText(...params) {
|
|
103
|
-
return this.client.commentText(this, ...params);
|
|
104
|
-
}
|
|
105
|
-
/** Send a media as a comment to this message */
|
|
106
|
-
commentMedia(...params) {
|
|
107
|
-
return this.client.commentMedia(this, ...params);
|
|
108
|
-
}
|
|
109
|
-
/** Send a media group as a comment to this message */
|
|
110
|
-
commentMediaGroup(...params) {
|
|
111
|
-
return this.client.commentMediaGroup(this, ...params);
|
|
112
|
-
}
|
|
113
|
-
/** Delete this message (message group) */
|
|
114
|
-
delete(params) {
|
|
115
|
-
return this.client.deleteMessagesById(this.chat.inputPeer, this.messages.map(it => it.id), params);
|
|
116
|
-
}
|
|
117
|
-
/** Pin this message */
|
|
118
|
-
pin(params) {
|
|
119
|
-
return this.client.pinMessage({
|
|
120
|
-
chatId: this.chat.inputPeer,
|
|
121
|
-
message: this.id,
|
|
122
|
-
...params,
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
/** Unpin this message */
|
|
126
|
-
unpin() {
|
|
127
|
-
return this.client.unpinMessage({
|
|
128
|
-
chatId: this.chat.inputPeer,
|
|
129
|
-
message: this.id,
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
/** Edit this message */
|
|
133
|
-
edit(params) {
|
|
134
|
-
return this.client.editMessage({
|
|
135
|
-
chatId: this.chat.inputPeer,
|
|
136
|
-
message: this.id,
|
|
137
|
-
...params,
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
/** Forward this message (message group) */
|
|
141
|
-
forwardTo(params) {
|
|
142
|
-
return this.client.forwardMessagesById({
|
|
143
|
-
fromChatId: this.chat.inputPeer,
|
|
144
|
-
messages: this.messages.map(it => it.id),
|
|
145
|
-
...params,
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
/** Send a copy of this message (message group) */
|
|
149
|
-
copy(params) {
|
|
150
|
-
if (this.isMessageGroup) {
|
|
151
|
-
return this.client.sendCopyGroup({
|
|
152
|
-
messages: this.messages,
|
|
153
|
-
...params,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
return this.client.sendCopy({
|
|
157
|
-
message: this,
|
|
158
|
-
...params,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
/** React to this message */
|
|
162
|
-
react(params) {
|
|
163
|
-
return this.client.sendReaction({
|
|
164
|
-
chatId: this.chat.inputPeer,
|
|
165
|
-
message: this.id,
|
|
166
|
-
...params,
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
exports.MessageContext = MessageContext;
|
|
171
|
-
//# sourceMappingURL=message.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/context/message.ts"],"names":[],"mappings":";;;AACA,uCAA2D;AAW3D;;;;;;;;GAQG;AACH,MAAa,cAAe,SAAQ,cAAO;IAe1B;IAdb,wFAAwF;IAC/E,KAAK,GAAG,aAAa,CAAA;IAE9B;;;;OAIG;IACM,QAAQ,CAAkB;IAEnC,mDAAmD;IAC1C,cAAc,CAAS;IAEhC,YACa,MAAsB,EAC/B,O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C,YAAY,CAAC;YAC5B,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS;YAC3B,OAAO,EAAE,IAAI,CAAC,EAAE;YAChB,GAAG,MAAM;SACZ,CAAC,CAAA;IACN,CAAC;CACJ;AAhMD,wCAgMC","sourcesContent":["import type { OmitInputMessageId, ParametersSkip1, Peer, Sticker } from '@mtcute/core'\nimport { Message, MtPeerNotFoundError } from '@mtcute/core'\nimport type { TelegramClient } from '@mtcute/core/client.js'\nimport type {\n DeleteMessagesParams,\n ForwardMessageOptions,\n SendCopyGroupParams,\n SendCopyParams,\n} from '@mtcute/core/methods.js'\n\nimport type { UpdateContext } from './base.js'\n\n/**\n * Context of a message-related update.\n *\n * This is a subclass of {@link Message}, so all fields\n * of the message are available.\n *\n * For message groups, own fields are related to the last message\n * in the group. To access all messages, use {@link MessageContext#messages}.\n */\nexport class MessageContext extends Message implements UpdateContext<Message> {\n // this is primarily for proper types in filters, so don't bother much with actual value\n readonly _name = 'new_message'\n\n /**\n * List of messages in the message group.\n *\n * For other updates, this is a list with a single element (`this`).\n */\n readonly messages: MessageContext[]\n\n /** Whether this update is about a message group */\n readonly isMessageGroup: boolean\n\n constructor(\n readonly client: TelegramClient,\n message: Message | Message[],\n ) {\n const msg = Array.isArray(message) ? message[message.length - 1] : message\n super(msg.raw, msg._peers, msg.isScheduled)\n\n this.messages = Array.isArray(message) ? message.map(it => new MessageContext(client, it)) : [this]\n this.isMessageGroup = Array.isArray(message)\n }\n\n /**\n * Get complete information about {@link sender}\n *\n * Learn more: [Incomplete peers](https://mtcute.dev/guide/topics/peers.html#incomplete-peers)\n */\n async getCompleteSender(): Promise<Peer> {\n if (!this.sender.isMin) return this.sender\n\n let res\n\n if (this.sender.type === 'user') {\n [res] = await this.client.getUsers(this.sender)\n } else {\n res = await this.client.getChat(this.sender)\n }\n\n if (!res) throw new MtPeerNotFoundError('Failed to fetch sender')\n\n Object.defineProperty(this, 'sender', { value: res })\n\n return res\n }\n\n /** Get a message that this message is a reply to */\n getReplyTo(): Promise<Message | null> {\n return this.client.getReplyTo(this)\n }\n\n /** If this is a channel post, get its automatic forward in the discussion group */\n getDiscussionMessage(): Promise<Message | null> {\n return this.client.getDiscussionMessage({ chatId: this.chat.inputPeer, message: this.id })\n }\n\n /** Get all custom emojis contained in this message (message group), if any */\n getCustomEmojis(): Promise<Sticker[]> {\n return this.client.getCustomEmojisFromMessages(this.messages)\n }\n\n /** Send a text message to the same chat (and topic, if applicable) as a given message */\n answerText(...params: ParametersSkip1<TelegramClient['answerText']>): Promise<Message> {\n return this.client.answerText(this, ...params)\n }\n\n /** Send a media to the same chat (and topic, if applicable) as a given message */\n answerMedia(...params: ParametersSkip1<TelegramClient['answerMedia']>): Promise<Message> {\n return this.client.answerMedia(this, ...params)\n }\n\n /** Send a media group to the same chat (and topic, if applicable) as a given message */\n answerMediaGroup(...params: ParametersSkip1<TelegramClient['answerMediaGroup']>): Promise<Message[]> {\n return this.client.answerMediaGroup(this, ...params)\n }\n\n /** Send a text message in reply to this message */\n replyText(...params: ParametersSkip1<TelegramClient['replyText']>): Promise<Message> {\n return this.client.replyText(this, ...params)\n }\n\n /** Send a media in reply to this message */\n replyMedia(...params: ParametersSkip1<TelegramClient['replyMedia']>): Promise<Message> {\n return this.client.replyMedia(this, ...params)\n }\n\n /** Send a media group in reply to this message */\n replyMediaGroup(...params: ParametersSkip1<TelegramClient['replyMediaGroup']>): Promise<Message[]> {\n return this.client.replyMediaGroup(this, ...params)\n }\n\n /** Send a text message in reply to this message */\n quoteWithText(params: Parameters<TelegramClient['quoteWithText']>[1]): Promise<Message> {\n return this.client.quoteWithText(this, params)\n }\n\n /** Send a media in reply to this message */\n quoteWithMedia(params: Parameters<TelegramClient['quoteWithMedia']>[1]): Promise<Message> {\n return this.client.quoteWithMedia(this, params)\n }\n\n /** Send a media group in reply to this message */\n quoteWithMediaGroup(params: Parameters<TelegramClient['quoteWithMediaGroup']>[1]): Promise<Message[]> {\n return this.client.quoteWithMediaGroup(this, params)\n }\n\n /** Send a text as a comment to this message */\n commentText(...params: ParametersSkip1<TelegramClient['commentText']>): Promise<Message> {\n return this.client.commentText(this, ...params)\n }\n\n /** Send a media as a comment to this message */\n commentMedia(...params: ParametersSkip1<TelegramClient['commentMedia']>): Promise<Message> {\n return this.client.commentMedia(this, ...params)\n }\n\n /** Send a media group as a comment to this message */\n commentMediaGroup(...params: ParametersSkip1<TelegramClient['commentMediaGroup']>): Promise<Message[]> {\n return this.client.commentMediaGroup(this, ...params)\n }\n\n /** Delete this message (message group) */\n delete(params?: DeleteMessagesParams): Promise<void> {\n return this.client.deleteMessagesById(\n this.chat.inputPeer,\n this.messages.map(it => it.id),\n params,\n )\n }\n\n /** Pin this message */\n pin(params?: OmitInputMessageId<Parameters<TelegramClient['pinMessage']>[0]>): Promise<Message | null> {\n return this.client.pinMessage({\n chatId: this.chat.inputPeer,\n message: this.id,\n ...params,\n })\n }\n\n /** Unpin this message */\n unpin(): Promise<void> {\n return this.client.unpinMessage({\n chatId: this.chat.inputPeer,\n message: this.id,\n })\n }\n\n /** Edit this message */\n edit(params: OmitInputMessageId<Parameters<TelegramClient['editMessage']>[0]>): Promise<Message> {\n return this.client.editMessage({\n chatId: this.chat.inputPeer,\n message: this.id,\n ...params,\n })\n }\n\n /** Forward this message (message group) */\n forwardTo(params: ForwardMessageOptions): Promise<Message[]> {\n return this.client.forwardMessagesById({\n fromChatId: this.chat.inputPeer,\n messages: this.messages.map(it => it.id),\n ...params,\n })\n }\n\n /** Send a copy of this message (message group) */\n copy(params: SendCopyParams & SendCopyGroupParams): Promise<Message> | Promise<Message[]> {\n if (this.isMessageGroup) {\n return this.client.sendCopyGroup({\n messages: this.messages,\n ...params,\n })\n }\n\n return this.client.sendCopy({\n message: this,\n ...params,\n })\n }\n\n /** React to this message */\n react(\n params: OmitInputMessageId<Parameters<TelegramClient['sendReaction']>[0]>,\n ): Promise<Message | null> {\n return this.client.sendReaction({\n chatId: this.chat.inputPeer,\n message: this.id,\n ...params,\n })\n }\n}\n"]}
|
package/cjs/context/parse.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._parsedUpdateToContext = _parsedUpdateToContext;
|
|
4
|
-
const business_message_js_1 = require("./business-message.js");
|
|
5
|
-
const callback_query_js_1 = require("./callback-query.js");
|
|
6
|
-
const chat_join_request_js_1 = require("./chat-join-request.js");
|
|
7
|
-
const chosen_inline_result_js_1 = require("./chosen-inline-result.js");
|
|
8
|
-
const inline_query_js_1 = require("./inline-query.js");
|
|
9
|
-
const message_js_1 = require("./message.js");
|
|
10
|
-
const pre_checkout_query_js_1 = require("./pre-checkout-query.js");
|
|
11
|
-
/** @internal */
|
|
12
|
-
function _parsedUpdateToContext(client, update) {
|
|
13
|
-
switch (update.name) {
|
|
14
|
-
case 'new_message':
|
|
15
|
-
case 'edit_message':
|
|
16
|
-
case 'message_group':
|
|
17
|
-
return new message_js_1.MessageContext(client, update.data);
|
|
18
|
-
case 'inline_query':
|
|
19
|
-
return new inline_query_js_1.InlineQueryContext(client, update.data);
|
|
20
|
-
case 'chosen_inline_result':
|
|
21
|
-
return new chosen_inline_result_js_1.ChosenInlineResultContext(client, update.data);
|
|
22
|
-
case 'callback_query':
|
|
23
|
-
return new callback_query_js_1.CallbackQueryContext(client, update.data);
|
|
24
|
-
case 'inline_callback_query':
|
|
25
|
-
return new callback_query_js_1.InlineCallbackQueryContext(client, update.data);
|
|
26
|
-
case 'business_callback_query':
|
|
27
|
-
return new callback_query_js_1.BusinessCallbackQueryContext(client, update.data);
|
|
28
|
-
case 'bot_chat_join_request':
|
|
29
|
-
return new chat_join_request_js_1.ChatJoinRequestUpdateContext(client, update.data);
|
|
30
|
-
case 'pre_checkout_query':
|
|
31
|
-
return new pre_checkout_query_js_1.PreCheckoutQueryContext(client, update.data);
|
|
32
|
-
case 'new_business_message':
|
|
33
|
-
case 'edit_business_message':
|
|
34
|
-
case 'business_message_group':
|
|
35
|
-
return new business_message_js_1.BusinessMessageContext(client, update.data);
|
|
36
|
-
}
|
|
37
|
-
const _update = update.data;
|
|
38
|
-
_update.client = client;
|
|
39
|
-
_update._name = update.name;
|
|
40
|
-
return _update;
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=parse.js.map
|
package/cjs/context/parse.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/context/parse.ts"],"names":[],"mappings":";;AA0DA,wDA+BC;AApED,+DAA8D;AAC9D,2DAAoH;AACpH,iEAAqE;AACrE,uEAAqE;AACrE,uDAAsD;AACtD,6CAA6C;AAC7C,mEAAiE;AA8BjE,gBAAgB;AAChB,SAAgB,sBAAsB,CAAC,MAAsB,EAAE,MAAoB;IAC/E,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,aAAa,CAAC;QACnB,KAAK,cAAc,CAAC;QACpB,KAAK,eAAe;YAChB,OAAO,IAAI,2BAAc,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAClD,KAAK,cAAc;YACf,OAAO,IAAI,oCAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QACtD,KAAK,sBAAsB;YACvB,OAAO,IAAI,mDAAyB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC7D,KAAK,gBAAgB;YACjB,OAAO,IAAI,wCAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QACxD,KAAK,uBAAuB;YACxB,OAAO,IAAI,8CAA0B,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC9D,KAAK,yBAAyB;YAC1B,OAAO,IAAI,gDAA4B,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAChE,KAAK,uBAAuB;YACxB,OAAO,IAAI,mDAA4B,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAChE,KAAK,oBAAoB;YACrB,OAAO,IAAI,+CAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC3D,KAAK,sBAAsB,CAAC;QAC5B,KAAK,uBAAuB,CAAC;QAC7B,KAAK,wBAAwB;YACzB,OAAO,IAAI,4CAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;IAC9D,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,IAAoD,CAAA;IAC3E,OAAO,CAAC,MAAM,GAAG,MAAM,CAAA;IACvB,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAA;IAE3B,OAAO,OAAO,CAAA;AAClB,CAAC","sourcesContent":["import type {\n BotReactionCountUpdate,\n BotReactionUpdate,\n BotStoppedUpdate,\n BusinessConnection,\n ChatJoinRequestUpdate,\n ChatMemberUpdate,\n DeleteBusinessMessageUpdate,\n DeleteMessageUpdate,\n DeleteStoryUpdate,\n HistoryReadUpdate,\n ParsedUpdate,\n PollUpdate,\n PollVoteUpdate,\n StoryUpdate,\n UserStatusUpdate,\n UserTypingUpdate,\n} from '@mtcute/core'\nimport type { TelegramClient } from '@mtcute/core/client.js'\n\nimport type { UpdateContextDistributed } from './base.js'\nimport { BusinessMessageContext } from './business-message.js'\nimport { BusinessCallbackQueryContext, CallbackQueryContext, InlineCallbackQueryContext } from './callback-query.js'\nimport { ChatJoinRequestUpdateContext } from './chat-join-request.js'\nimport { ChosenInlineResultContext } from './chosen-inline-result.js'\nimport { InlineQueryContext } from './inline-query.js'\nimport { MessageContext } from './message.js'\nimport { PreCheckoutQueryContext } from './pre-checkout-query.js'\n\nexport type UpdateContextType =\n | MessageContext\n | InlineQueryContext\n | ChosenInlineResultContext\n | CallbackQueryContext\n | InlineCallbackQueryContext\n | BusinessCallbackQueryContext\n | ChatJoinRequestUpdateContext\n | PreCheckoutQueryContext\n | BusinessMessageContext\n | UpdateContextDistributed<\n | DeleteMessageUpdate\n | ChatMemberUpdate\n | PollUpdate\n | PollVoteUpdate\n | UserStatusUpdate\n | UserTypingUpdate\n | HistoryReadUpdate\n | BotStoppedUpdate\n | ChatJoinRequestUpdate\n | StoryUpdate\n | DeleteStoryUpdate\n | BotReactionUpdate\n | BotReactionCountUpdate\n | BusinessConnection\n | DeleteBusinessMessageUpdate\n >\n\n/** @internal */\nexport function _parsedUpdateToContext(client: TelegramClient, update: ParsedUpdate): UpdateContextType {\n switch (update.name) {\n case 'new_message':\n case 'edit_message':\n case 'message_group':\n return new MessageContext(client, update.data)\n case 'inline_query':\n return new InlineQueryContext(client, update.data)\n case 'chosen_inline_result':\n return new ChosenInlineResultContext(client, update.data)\n case 'callback_query':\n return new CallbackQueryContext(client, update.data)\n case 'inline_callback_query':\n return new InlineCallbackQueryContext(client, update.data)\n case 'business_callback_query':\n return new BusinessCallbackQueryContext(client, update.data)\n case 'bot_chat_join_request':\n return new ChatJoinRequestUpdateContext(client, update.data)\n case 'pre_checkout_query':\n return new PreCheckoutQueryContext(client, update.data)\n case 'new_business_message':\n case 'edit_business_message':\n case 'business_message_group':\n return new BusinessMessageContext(client, update.data)\n }\n\n const _update = update.data as UpdateContextDistributed<typeof update.data>\n _update.client = client\n _update._name = update.name\n\n return _update\n}\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { PreCheckoutQuery } from '@mtcute/core';
|
|
2
|
-
import type { TelegramClient } from '@mtcute/core/client.js';
|
|
3
|
-
import type { UpdateContext } from './base.js';
|
|
4
|
-
/**
|
|
5
|
-
* Context of a pre-checkout query update
|
|
6
|
-
*
|
|
7
|
-
* This is a subclass of {@link PreCheckoutQuery}, so all its fields are also available.
|
|
8
|
-
*/
|
|
9
|
-
export declare class PreCheckoutQueryContext extends PreCheckoutQuery implements UpdateContext<PreCheckoutQuery> {
|
|
10
|
-
readonly client: TelegramClient;
|
|
11
|
-
readonly _name = "pre_checkout_query";
|
|
12
|
-
constructor(client: TelegramClient, query: PreCheckoutQuery);
|
|
13
|
-
/** Approve the query */
|
|
14
|
-
approve(): Promise<void>;
|
|
15
|
-
/** Decline the query, optionally with an error */
|
|
16
|
-
decline(error?: string): Promise<void>;
|
|
17
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PreCheckoutQueryContext = void 0;
|
|
4
|
-
const core_1 = require("@mtcute/core");
|
|
5
|
-
/**
|
|
6
|
-
* Context of a pre-checkout query update
|
|
7
|
-
*
|
|
8
|
-
* This is a subclass of {@link PreCheckoutQuery}, so all its fields are also available.
|
|
9
|
-
*/
|
|
10
|
-
class PreCheckoutQueryContext extends core_1.PreCheckoutQuery {
|
|
11
|
-
client;
|
|
12
|
-
_name = 'pre_checkout_query';
|
|
13
|
-
constructor(client, query) {
|
|
14
|
-
super(query.raw, query._peers);
|
|
15
|
-
this.client = client;
|
|
16
|
-
}
|
|
17
|
-
/** Approve the query */
|
|
18
|
-
approve() {
|
|
19
|
-
return this.client.answerPreCheckoutQuery(this.raw.queryId);
|
|
20
|
-
}
|
|
21
|
-
/** Decline the query, optionally with an error */
|
|
22
|
-
decline(error = '') {
|
|
23
|
-
return this.client.answerPreCheckoutQuery(this.raw.queryId, { error });
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.PreCheckoutQueryContext = PreCheckoutQueryContext;
|
|
27
|
-
//# sourceMappingURL=pre-checkout-query.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pre-checkout-query.js","sourceRoot":"","sources":["../../../src/context/pre-checkout-query.ts"],"names":[],"mappings":";;;AAAA,uCAA+C;AAK/C;;;;GAIG;AACH,MAAa,uBAAwB,SAAQ,uBAAgB;IAI5C;IAHJ,KAAK,GAAG,oBAAoB,CAAA;IAErC,YACa,MAAsB,EAC/B,KAAuB;QAEvB,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;QAHrB,WAAM,GAAN,MAAM,CAAgB;IAInC,CAAC;IAED,wBAAwB;IACxB,OAAO;QACH,OAAO,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAC/D,CAAC;IAED,kDAAkD;IAClD,OAAO,CAAC,KAAK,GAAG,EAAE;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;IAC1E,CAAC;CACJ;AAnBD,0DAmBC","sourcesContent":["import { PreCheckoutQuery } from '@mtcute/core'\nimport type { TelegramClient } from '@mtcute/core/client.js'\n\nimport type { UpdateContext } from './base.js'\n\n/**\n * Context of a pre-checkout query update\n *\n * This is a subclass of {@link PreCheckoutQuery}, so all its fields are also available.\n */\nexport class PreCheckoutQueryContext extends PreCheckoutQuery implements UpdateContext<PreCheckoutQuery> {\n readonly _name = 'pre_checkout_query'\n\n constructor(\n readonly client: TelegramClient,\n query: PreCheckoutQuery,\n ) {\n super(query.raw, query._peers)\n }\n\n /** Approve the query */\n approve(): Promise<void> {\n return this.client.answerPreCheckoutQuery(this.raw.queryId)\n }\n\n /** Decline the query, optionally with an error */\n decline(error = ''): Promise<void> {\n return this.client.answerPreCheckoutQuery(this.raw.queryId, { error })\n }\n}\n"]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BusinessMessageContext } from './business-message.js';
|
|
2
|
-
import { CallbackQueryContext, InlineCallbackQueryContext } from './callback-query.js';
|
|
3
|
-
import { MessageContext } from './message.js';
|
|
4
|
-
import type { UpdateContextType } from './parse.js';
|
|
5
|
-
/** Update which is dispatched whenever scene is entered or exited */
|
|
6
|
-
export declare class SceneTransitionContext {
|
|
7
|
-
/** Name of the previous scene, if any */
|
|
8
|
-
readonly previousScene: string | null;
|
|
9
|
-
/** Update, handler for which triggered the transition */
|
|
10
|
-
readonly update: UpdateContextType;
|
|
11
|
-
constructor(
|
|
12
|
-
/** Name of the previous scene, if any */
|
|
13
|
-
previousScene: string | null,
|
|
14
|
-
/** Update, handler for which triggered the transition */
|
|
15
|
-
update: UpdateContextType);
|
|
16
|
-
/** Get {@link update}, asserting it is a message-related update */
|
|
17
|
-
get message(): MessageContext;
|
|
18
|
-
/** Get {@link update}, asserting it is a business message-related update */
|
|
19
|
-
get businessMessage(): BusinessMessageContext;
|
|
20
|
-
/** Get {@link update}, asserting it is a callback query update */
|
|
21
|
-
get callbackQuery(): CallbackQueryContext;
|
|
22
|
-
/** Get {@link update}, asserting it is an inline callback query update */
|
|
23
|
-
get inlineCallbackQuery(): InlineCallbackQueryContext;
|
|
24
|
-
}
|