@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,103 +0,0 @@
|
|
|
1
|
-
import { BusinessCallbackQuery, CallbackQuery, InlineCallbackQuery } from '@mtcute/core';
|
|
2
|
-
/**
|
|
3
|
-
* Context of a callback query update.
|
|
4
|
-
*
|
|
5
|
-
* This is a subclass of {@link CallbackQuery}, so all its fields are also available.
|
|
6
|
-
*/
|
|
7
|
-
export class CallbackQueryContext extends CallbackQuery {
|
|
8
|
-
client;
|
|
9
|
-
_name = 'callback_query';
|
|
10
|
-
constructor(client, query) {
|
|
11
|
-
super(query.raw, query._peers);
|
|
12
|
-
this.client = client;
|
|
13
|
-
}
|
|
14
|
-
/** Answer to this callback query */
|
|
15
|
-
answer(params) {
|
|
16
|
-
return this.client.answerCallbackQuery(this.id, params);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Get the message containing the callback button being clicked.
|
|
20
|
-
*
|
|
21
|
-
* Note that the message may have been deleted, in which case
|
|
22
|
-
* `null` will be returned.
|
|
23
|
-
*/
|
|
24
|
-
async getMessage() {
|
|
25
|
-
return this.client.getCallbackQueryMessage(this);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Edit the message that contained the callback button that was clicked.
|
|
29
|
-
*/
|
|
30
|
-
async editMessage(params) {
|
|
31
|
-
return this.client.editMessage({
|
|
32
|
-
chatId: this.raw.peer,
|
|
33
|
-
message: this.raw.msgId,
|
|
34
|
-
...params,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Shortcut for getting the message and editing it.
|
|
39
|
-
*/
|
|
40
|
-
async editMessageWith(handler) {
|
|
41
|
-
const msg = await this.getMessage();
|
|
42
|
-
if (!msg)
|
|
43
|
-
return;
|
|
44
|
-
const res = await handler(msg);
|
|
45
|
-
if (!res)
|
|
46
|
-
return;
|
|
47
|
-
return this.editMessage(res);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Context of an inline-originated callback query update.
|
|
52
|
-
*
|
|
53
|
-
* This is a subclass of {@link InlineCallbackQuery}, so all its fields are also available.
|
|
54
|
-
*/
|
|
55
|
-
export class InlineCallbackQueryContext extends InlineCallbackQuery {
|
|
56
|
-
client;
|
|
57
|
-
_name = 'inline_callback_query';
|
|
58
|
-
constructor(client, query) {
|
|
59
|
-
super(query.raw, query._peers);
|
|
60
|
-
this.client = client;
|
|
61
|
-
}
|
|
62
|
-
/** Answer to this callback query */
|
|
63
|
-
answer(params) {
|
|
64
|
-
return this.client.answerCallbackQuery(this.id, params);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Edit the message that contained the callback button that was clicked.
|
|
68
|
-
*/
|
|
69
|
-
async editMessage(params) {
|
|
70
|
-
return this.client.editInlineMessage({
|
|
71
|
-
messageId: this.raw.msgId,
|
|
72
|
-
...params,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Context of an callback query update originated from a business connection message
|
|
78
|
-
*
|
|
79
|
-
* This is a subclass of {@link BusinessCallbackQuery}, so all its fields are also available.
|
|
80
|
-
*/
|
|
81
|
-
export class BusinessCallbackQueryContext extends BusinessCallbackQuery {
|
|
82
|
-
client;
|
|
83
|
-
_name = 'business_callback_query';
|
|
84
|
-
constructor(client, query) {
|
|
85
|
-
super(query.raw, query._peers);
|
|
86
|
-
this.client = client;
|
|
87
|
-
}
|
|
88
|
-
/** Answer to this callback query */
|
|
89
|
-
answer(params) {
|
|
90
|
-
return this.client.answerCallbackQuery(this.id, params);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Edit the message that contained the callback button that was clicked.
|
|
94
|
-
*/
|
|
95
|
-
async editMessage(params) {
|
|
96
|
-
return this.client.editMessage({
|
|
97
|
-
message: this.message,
|
|
98
|
-
businessConnectionId: this.connectionId,
|
|
99
|
-
...params,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
//# 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,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAKxF;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,aAAa;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,GAAG,MAAM;SACZ,CAAC,CAAA;IACN,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,eAAe,CACjB,OAA2F;QAE3F,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAA;QACnC,IAAI,CAAC,GAAG;YAAE,OAAM;QA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,CAAC,WAAW,CAAC;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,oBAAoB,EAAE,IAAI,CAAC,YAAY;YACvC,GAAG,MAAM;SACZ,CAAC,CAAA;IACN,CAAC;CACJ","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,17 +0,0 @@
|
|
|
1
|
-
import { BotChatJoinRequestUpdate } from '@mtcute/core';
|
|
2
|
-
import type { TelegramClient } from '@mtcute/core/client.js';
|
|
3
|
-
import type { UpdateContext } from './base.js';
|
|
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,31 +0,0 @@
|
|
|
1
|
-
import { BotChatJoinRequestUpdate } from '@mtcute/core';
|
|
2
|
-
/**
|
|
3
|
-
* Context of a chat join request update (for bots).
|
|
4
|
-
*
|
|
5
|
-
* This is a subclass of {@link BotChatJoinRequestUpdate}, so all its fields are also available.
|
|
6
|
-
*/
|
|
7
|
-
export class ChatJoinRequestUpdateContext extends BotChatJoinRequestUpdate {
|
|
8
|
-
client;
|
|
9
|
-
_name = 'bot_chat_join_request';
|
|
10
|
-
constructor(client, update) {
|
|
11
|
-
super(update.raw, update._peers);
|
|
12
|
-
this.client = client;
|
|
13
|
-
}
|
|
14
|
-
/** Approve the request */
|
|
15
|
-
approve() {
|
|
16
|
-
return this.client.hideJoinRequest({
|
|
17
|
-
action: 'approve',
|
|
18
|
-
user: this.user.inputPeer,
|
|
19
|
-
chatId: this.chat.inputPeer,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
/** Decline the request */
|
|
23
|
-
decline() {
|
|
24
|
-
return this.client.hideJoinRequest({
|
|
25
|
-
action: 'decline',
|
|
26
|
-
user: this.user.inputPeer,
|
|
27
|
-
chatId: this.chat.inputPeer,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
//# 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,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAKvD;;;;GAIG;AACH,MAAM,OAAO,4BACT,SAAQ,wBAAwB;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","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,32 +0,0 @@
|
|
|
1
|
-
import { ChosenInlineResult, MtArgumentError } from '@mtcute/core';
|
|
2
|
-
/**
|
|
3
|
-
* Context of a chosen inline result update.
|
|
4
|
-
*
|
|
5
|
-
* This is a subclass of {@link ChosenInlineResult}, so all its fields are also available.
|
|
6
|
-
*
|
|
7
|
-
* > **Note**: To receive these updates, you must enable
|
|
8
|
-
* > Inline feedback in [@BotFather](//t.me/botfather)
|
|
9
|
-
*/
|
|
10
|
-
export class ChosenInlineResultContext extends ChosenInlineResult {
|
|
11
|
-
client;
|
|
12
|
-
_name = 'chosen_inline_result';
|
|
13
|
-
constructor(client, result) {
|
|
14
|
-
super(result.raw, result._peers);
|
|
15
|
-
this.client = client;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Edit the message that was sent when this inline result that was chosen.
|
|
19
|
-
*
|
|
20
|
-
* > **Note**: This method can only be used if the message contained a reply markup
|
|
21
|
-
*/
|
|
22
|
-
async editMessage(params) {
|
|
23
|
-
if (!this.raw.msgId) {
|
|
24
|
-
throw new MtArgumentError('No message ID, make sure you have included reply markup!');
|
|
25
|
-
}
|
|
26
|
-
return this.client.editInlineMessage({
|
|
27
|
-
...params,
|
|
28
|
-
messageId: this.raw.msgId,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
//# 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,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAKlE;;;;;;;GAOG;AACH,MAAM,OAAO,yBAA0B,SAAQ,kBAAkB;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,eAAe,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","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/esm/context/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
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';
|
package/esm/context/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
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 * from './pre-checkout-query.js';
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
package/esm/context/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAE5B,cAAc,yBAAyB,CAAA","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,19 +0,0 @@
|
|
|
1
|
-
import { InlineQuery } from '@mtcute/core';
|
|
2
|
-
/**
|
|
3
|
-
* Context of an inline query update.
|
|
4
|
-
*
|
|
5
|
-
* This is a subclass of {@link InlineQuery}, so all its fields are also available.
|
|
6
|
-
*/
|
|
7
|
-
export class InlineQueryContext extends InlineQuery {
|
|
8
|
-
client;
|
|
9
|
-
_name = 'inline_query';
|
|
10
|
-
constructor(client, query) {
|
|
11
|
-
super(query.raw, query._peers);
|
|
12
|
-
this.client = client;
|
|
13
|
-
}
|
|
14
|
-
/** Answer to this inline query */
|
|
15
|
-
answer(...params) {
|
|
16
|
-
return this.client.answerInlineQuery(this.id, ...params);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
//# 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,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAK1C;;;;GAIG;AACH,MAAM,OAAO,kBAAmB,SAAQ,WAAW;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","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/esm/context/message.d.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { OmitInputMessageId, ParametersSkip1, Peer, Sticker } from '@mtcute/core';
|
|
2
|
-
import { Message } from '@mtcute/core';
|
|
3
|
-
import type { TelegramClient } from '@mtcute/core/client.js';
|
|
4
|
-
import type { DeleteMessagesParams, ForwardMessageOptions, SendCopyGroupParams, SendCopyParams } from '@mtcute/core/methods.js';
|
|
5
|
-
import type { UpdateContext } from './base.js';
|
|
6
|
-
/**
|
|
7
|
-
* Context of a message-related update.
|
|
8
|
-
*
|
|
9
|
-
* This is a subclass of {@link Message}, so all fields
|
|
10
|
-
* of the message are available.
|
|
11
|
-
*
|
|
12
|
-
* For message groups, own fields are related to the last message
|
|
13
|
-
* in the group. To access all messages, use {@link MessageContext#messages}.
|
|
14
|
-
*/
|
|
15
|
-
export declare class MessageContext extends Message implements UpdateContext<Message> {
|
|
16
|
-
readonly client: TelegramClient;
|
|
17
|
-
readonly _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
|
-
readonly messages: MessageContext[];
|
|
24
|
-
/** Whether this update is about a message group */
|
|
25
|
-
readonly isMessageGroup: boolean;
|
|
26
|
-
constructor(client: TelegramClient, message: Message | Message[]);
|
|
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
|
-
getCompleteSender(): Promise<Peer>;
|
|
33
|
-
/** Get a message that this message is a reply to */
|
|
34
|
-
getReplyTo(): Promise<Message | null>;
|
|
35
|
-
/** If this is a channel post, get its automatic forward in the discussion group */
|
|
36
|
-
getDiscussionMessage(): Promise<Message | null>;
|
|
37
|
-
/** Get all custom emojis contained in this message (message group), if any */
|
|
38
|
-
getCustomEmojis(): Promise<Sticker[]>;
|
|
39
|
-
/** Send a text message to the same chat (and topic, if applicable) as a given message */
|
|
40
|
-
answerText(...params: ParametersSkip1<TelegramClient['answerText']>): Promise<Message>;
|
|
41
|
-
/** Send a media to the same chat (and topic, if applicable) as a given message */
|
|
42
|
-
answerMedia(...params: ParametersSkip1<TelegramClient['answerMedia']>): Promise<Message>;
|
|
43
|
-
/** Send a media group to the same chat (and topic, if applicable) as a given message */
|
|
44
|
-
answerMediaGroup(...params: ParametersSkip1<TelegramClient['answerMediaGroup']>): Promise<Message[]>;
|
|
45
|
-
/** Send a text message in reply to this message */
|
|
46
|
-
replyText(...params: ParametersSkip1<TelegramClient['replyText']>): Promise<Message>;
|
|
47
|
-
/** Send a media in reply to this message */
|
|
48
|
-
replyMedia(...params: ParametersSkip1<TelegramClient['replyMedia']>): Promise<Message>;
|
|
49
|
-
/** Send a media group in reply to this message */
|
|
50
|
-
replyMediaGroup(...params: ParametersSkip1<TelegramClient['replyMediaGroup']>): Promise<Message[]>;
|
|
51
|
-
/** Send a text message in reply to this message */
|
|
52
|
-
quoteWithText(params: Parameters<TelegramClient['quoteWithText']>[1]): Promise<Message>;
|
|
53
|
-
/** Send a media in reply to this message */
|
|
54
|
-
quoteWithMedia(params: Parameters<TelegramClient['quoteWithMedia']>[1]): Promise<Message>;
|
|
55
|
-
/** Send a media group in reply to this message */
|
|
56
|
-
quoteWithMediaGroup(params: Parameters<TelegramClient['quoteWithMediaGroup']>[1]): Promise<Message[]>;
|
|
57
|
-
/** Send a text as a comment to this message */
|
|
58
|
-
commentText(...params: ParametersSkip1<TelegramClient['commentText']>): Promise<Message>;
|
|
59
|
-
/** Send a media as a comment to this message */
|
|
60
|
-
commentMedia(...params: ParametersSkip1<TelegramClient['commentMedia']>): Promise<Message>;
|
|
61
|
-
/** Send a media group as a comment to this message */
|
|
62
|
-
commentMediaGroup(...params: ParametersSkip1<TelegramClient['commentMediaGroup']>): Promise<Message[]>;
|
|
63
|
-
/** Delete this message (message group) */
|
|
64
|
-
delete(params?: DeleteMessagesParams): Promise<void>;
|
|
65
|
-
/** Pin this message */
|
|
66
|
-
pin(params?: OmitInputMessageId<Parameters<TelegramClient['pinMessage']>[0]>): Promise<Message | null>;
|
|
67
|
-
/** Unpin this message */
|
|
68
|
-
unpin(): Promise<void>;
|
|
69
|
-
/** Edit this message */
|
|
70
|
-
edit(params: OmitInputMessageId<Parameters<TelegramClient['editMessage']>[0]>): Promise<Message>;
|
|
71
|
-
/** Forward this message (message group) */
|
|
72
|
-
forwardTo(params: ForwardMessageOptions): Promise<Message[]>;
|
|
73
|
-
/** Send a copy of this message (message group) */
|
|
74
|
-
copy(params: SendCopyParams & SendCopyGroupParams): Promise<Message> | Promise<Message[]>;
|
|
75
|
-
/** React to this message */
|
|
76
|
-
react(params: OmitInputMessageId<Parameters<TelegramClient['sendReaction']>[0]>): Promise<Message | null>;
|
|
77
|
-
}
|
package/esm/context/message.js
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { Message, MtPeerNotFoundError } from '@mtcute/core';
|
|
2
|
-
/**
|
|
3
|
-
* Context of a message-related update.
|
|
4
|
-
*
|
|
5
|
-
* This is a subclass of {@link Message}, so all fields
|
|
6
|
-
* of the message are available.
|
|
7
|
-
*
|
|
8
|
-
* For message groups, own fields are related to the last message
|
|
9
|
-
* in the group. To access all messages, use {@link MessageContext#messages}.
|
|
10
|
-
*/
|
|
11
|
-
export class MessageContext extends Message {
|
|
12
|
-
client;
|
|
13
|
-
// this is primarily for proper types in filters, so don't bother much with actual value
|
|
14
|
-
_name = 'new_message';
|
|
15
|
-
/**
|
|
16
|
-
* List of messages in the message group.
|
|
17
|
-
*
|
|
18
|
-
* For other updates, this is a list with a single element (`this`).
|
|
19
|
-
*/
|
|
20
|
-
messages;
|
|
21
|
-
/** Whether this update is about a message group */
|
|
22
|
-
isMessageGroup;
|
|
23
|
-
constructor(client, message) {
|
|
24
|
-
const msg = Array.isArray(message) ? message[message.length - 1] : message;
|
|
25
|
-
super(msg.raw, msg._peers, msg.isScheduled);
|
|
26
|
-
this.client = client;
|
|
27
|
-
this.messages = Array.isArray(message) ? message.map(it => new MessageContext(client, it)) : [this];
|
|
28
|
-
this.isMessageGroup = Array.isArray(message);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Get complete information about {@link sender}
|
|
32
|
-
*
|
|
33
|
-
* Learn more: [Incomplete peers](https://mtcute.dev/guide/topics/peers.html#incomplete-peers)
|
|
34
|
-
*/
|
|
35
|
-
async getCompleteSender() {
|
|
36
|
-
if (!this.sender.isMin)
|
|
37
|
-
return this.sender;
|
|
38
|
-
let res;
|
|
39
|
-
if (this.sender.type === 'user') {
|
|
40
|
-
[res] = await this.client.getUsers(this.sender);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
res = await this.client.getChat(this.sender);
|
|
44
|
-
}
|
|
45
|
-
if (!res)
|
|
46
|
-
throw new MtPeerNotFoundError('Failed to fetch sender');
|
|
47
|
-
Object.defineProperty(this, 'sender', { value: res });
|
|
48
|
-
return res;
|
|
49
|
-
}
|
|
50
|
-
/** Get a message that this message is a reply to */
|
|
51
|
-
getReplyTo() {
|
|
52
|
-
return this.client.getReplyTo(this);
|
|
53
|
-
}
|
|
54
|
-
/** If this is a channel post, get its automatic forward in the discussion group */
|
|
55
|
-
getDiscussionMessage() {
|
|
56
|
-
return this.client.getDiscussionMessage({ chatId: this.chat.inputPeer, message: this.id });
|
|
57
|
-
}
|
|
58
|
-
/** Get all custom emojis contained in this message (message group), if any */
|
|
59
|
-
getCustomEmojis() {
|
|
60
|
-
return this.client.getCustomEmojisFromMessages(this.messages);
|
|
61
|
-
}
|
|
62
|
-
/** Send a text message to the same chat (and topic, if applicable) as a given message */
|
|
63
|
-
answerText(...params) {
|
|
64
|
-
return this.client.answerText(this, ...params);
|
|
65
|
-
}
|
|
66
|
-
/** Send a media to the same chat (and topic, if applicable) as a given message */
|
|
67
|
-
answerMedia(...params) {
|
|
68
|
-
return this.client.answerMedia(this, ...params);
|
|
69
|
-
}
|
|
70
|
-
/** Send a media group to the same chat (and topic, if applicable) as a given message */
|
|
71
|
-
answerMediaGroup(...params) {
|
|
72
|
-
return this.client.answerMediaGroup(this, ...params);
|
|
73
|
-
}
|
|
74
|
-
/** Send a text message in reply to this message */
|
|
75
|
-
replyText(...params) {
|
|
76
|
-
return this.client.replyText(this, ...params);
|
|
77
|
-
}
|
|
78
|
-
/** Send a media in reply to this message */
|
|
79
|
-
replyMedia(...params) {
|
|
80
|
-
return this.client.replyMedia(this, ...params);
|
|
81
|
-
}
|
|
82
|
-
/** Send a media group in reply to this message */
|
|
83
|
-
replyMediaGroup(...params) {
|
|
84
|
-
return this.client.replyMediaGroup(this, ...params);
|
|
85
|
-
}
|
|
86
|
-
/** Send a text message in reply to this message */
|
|
87
|
-
quoteWithText(params) {
|
|
88
|
-
return this.client.quoteWithText(this, params);
|
|
89
|
-
}
|
|
90
|
-
/** Send a media in reply to this message */
|
|
91
|
-
quoteWithMedia(params) {
|
|
92
|
-
return this.client.quoteWithMedia(this, params);
|
|
93
|
-
}
|
|
94
|
-
/** Send a media group in reply to this message */
|
|
95
|
-
quoteWithMediaGroup(params) {
|
|
96
|
-
return this.client.quoteWithMediaGroup(this, params);
|
|
97
|
-
}
|
|
98
|
-
/** Send a text as a comment to this message */
|
|
99
|
-
commentText(...params) {
|
|
100
|
-
return this.client.commentText(this, ...params);
|
|
101
|
-
}
|
|
102
|
-
/** Send a media as a comment to this message */
|
|
103
|
-
commentMedia(...params) {
|
|
104
|
-
return this.client.commentMedia(this, ...params);
|
|
105
|
-
}
|
|
106
|
-
/** Send a media group as a comment to this message */
|
|
107
|
-
commentMediaGroup(...params) {
|
|
108
|
-
return this.client.commentMediaGroup(this, ...params);
|
|
109
|
-
}
|
|
110
|
-
/** Delete this message (message group) */
|
|
111
|
-
delete(params) {
|
|
112
|
-
return this.client.deleteMessagesById(this.chat.inputPeer, this.messages.map(it => it.id), params);
|
|
113
|
-
}
|
|
114
|
-
/** Pin this message */
|
|
115
|
-
pin(params) {
|
|
116
|
-
return this.client.pinMessage({
|
|
117
|
-
chatId: this.chat.inputPeer,
|
|
118
|
-
message: this.id,
|
|
119
|
-
...params,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
/** Unpin this message */
|
|
123
|
-
unpin() {
|
|
124
|
-
return this.client.unpinMessage({
|
|
125
|
-
chatId: this.chat.inputPeer,
|
|
126
|
-
message: this.id,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
/** Edit this message */
|
|
130
|
-
edit(params) {
|
|
131
|
-
return this.client.editMessage({
|
|
132
|
-
chatId: this.chat.inputPeer,
|
|
133
|
-
message: this.id,
|
|
134
|
-
...params,
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
/** Forward this message (message group) */
|
|
138
|
-
forwardTo(params) {
|
|
139
|
-
return this.client.forwardMessagesById({
|
|
140
|
-
fromChatId: this.chat.inputPeer,
|
|
141
|
-
messages: this.messages.map(it => it.id),
|
|
142
|
-
...params,
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
/** Send a copy of this message (message group) */
|
|
146
|
-
copy(params) {
|
|
147
|
-
if (this.isMessageGroup) {
|
|
148
|
-
return this.client.sendCopyGroup({
|
|
149
|
-
messages: this.messages,
|
|
150
|
-
...params,
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
return this.client.sendCopy({
|
|
154
|
-
message: this,
|
|
155
|
-
...params,
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
/** React to this message */
|
|
159
|
-
react(params) {
|
|
160
|
-
return this.client.sendReaction({
|
|
161
|
-
chatId: this.chat.inputPeer,
|
|
162
|
-
message: this.id,
|
|
163
|
-
...params,
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
//# sourceMappingURL=message.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/context/message.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAW3D;;;;;;;;GAQG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ED,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;YACxB,OAAO,EAAE,IAAI;YACb,GAAG,MAAM;SACZ,CAAC,CAAA;IACN,CAAC;IAED,4BAA4B;IAC5B,KAAK,CACD,MAAyE;QAEzE,OAAO,IAAI,CAAC,MAAM,CAAC,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","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/esm/context/parse.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessConnection, ChatJoinRequestUpdate, ChatMemberUpdate, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, HistoryReadUpdate, ParsedUpdate, PollUpdate, PollVoteUpdate, StoryUpdate, UserStatusUpdate, UserTypingUpdate } from '@mtcute/core';
|
|
2
|
-
import type { TelegramClient } from '@mtcute/core/client.js';
|
|
3
|
-
import type { UpdateContextDistributed } from './base.js';
|
|
4
|
-
import { BusinessMessageContext } from './business-message.js';
|
|
5
|
-
import { BusinessCallbackQueryContext, CallbackQueryContext, InlineCallbackQueryContext } from './callback-query.js';
|
|
6
|
-
import { ChatJoinRequestUpdateContext } from './chat-join-request.js';
|
|
7
|
-
import { ChosenInlineResultContext } from './chosen-inline-result.js';
|
|
8
|
-
import { InlineQueryContext } from './inline-query.js';
|
|
9
|
-
import { MessageContext } from './message.js';
|
|
10
|
-
import { PreCheckoutQueryContext } from './pre-checkout-query.js';
|
|
11
|
-
export type UpdateContextType = MessageContext | InlineQueryContext | ChosenInlineResultContext | CallbackQueryContext | InlineCallbackQueryContext | BusinessCallbackQueryContext | ChatJoinRequestUpdateContext | PreCheckoutQueryContext | BusinessMessageContext | UpdateContextDistributed<DeleteMessageUpdate | ChatMemberUpdate | PollUpdate | PollVoteUpdate | UserStatusUpdate | UserTypingUpdate | HistoryReadUpdate | BotStoppedUpdate | ChatJoinRequestUpdate | StoryUpdate | DeleteStoryUpdate | BotReactionUpdate | BotReactionCountUpdate | BusinessConnection | DeleteBusinessMessageUpdate>;
|
|
12
|
-
/** @internal */
|
|
13
|
-
export declare function _parsedUpdateToContext(client: TelegramClient, update: ParsedUpdate): UpdateContextType;
|
package/esm/context/parse.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { BusinessMessageContext } from './business-message.js';
|
|
2
|
-
import { BusinessCallbackQueryContext, CallbackQueryContext, InlineCallbackQueryContext } from './callback-query.js';
|
|
3
|
-
import { ChatJoinRequestUpdateContext } from './chat-join-request.js';
|
|
4
|
-
import { ChosenInlineResultContext } from './chosen-inline-result.js';
|
|
5
|
-
import { InlineQueryContext } from './inline-query.js';
|
|
6
|
-
import { MessageContext } from './message.js';
|
|
7
|
-
import { PreCheckoutQueryContext } from './pre-checkout-query.js';
|
|
8
|
-
/** @internal */
|
|
9
|
-
export function _parsedUpdateToContext(client, update) {
|
|
10
|
-
switch (update.name) {
|
|
11
|
-
case 'new_message':
|
|
12
|
-
case 'edit_message':
|
|
13
|
-
case 'message_group':
|
|
14
|
-
return new MessageContext(client, update.data);
|
|
15
|
-
case 'inline_query':
|
|
16
|
-
return new InlineQueryContext(client, update.data);
|
|
17
|
-
case 'chosen_inline_result':
|
|
18
|
-
return new ChosenInlineResultContext(client, update.data);
|
|
19
|
-
case 'callback_query':
|
|
20
|
-
return new CallbackQueryContext(client, update.data);
|
|
21
|
-
case 'inline_callback_query':
|
|
22
|
-
return new InlineCallbackQueryContext(client, update.data);
|
|
23
|
-
case 'business_callback_query':
|
|
24
|
-
return new BusinessCallbackQueryContext(client, update.data);
|
|
25
|
-
case 'bot_chat_join_request':
|
|
26
|
-
return new ChatJoinRequestUpdateContext(client, update.data);
|
|
27
|
-
case 'pre_checkout_query':
|
|
28
|
-
return new PreCheckoutQueryContext(client, update.data);
|
|
29
|
-
case 'new_business_message':
|
|
30
|
-
case 'edit_business_message':
|
|
31
|
-
case 'business_message_group':
|
|
32
|
-
return new BusinessMessageContext(client, update.data);
|
|
33
|
-
}
|
|
34
|
-
const _update = update.data;
|
|
35
|
-
_update.client = client;
|
|
36
|
-
_update._name = update.name;
|
|
37
|
-
return _update;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=parse.js.map
|
package/esm/context/parse.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/context/parse.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAA;AACpH,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAA;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AA8BjE,gBAAgB;AAChB,MAAM,UAAU,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,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAClD,KAAK,cAAc;YACf,OAAO,IAAI,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QACtD,KAAK,sBAAsB;YACvB,OAAO,IAAI,yBAAyB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC7D,KAAK,gBAAgB;YACjB,OAAO,IAAI,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QACxD,KAAK,uBAAuB;YACxB,OAAO,IAAI,0BAA0B,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC9D,KAAK,yBAAyB;YAC1B,OAAO,IAAI,4BAA4B,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAChE,KAAK,uBAAuB;YACxB,OAAO,IAAI,4BAA4B,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAChE,KAAK,oBAAoB;YACrB,OAAO,IAAI,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC3D,KAAK,sBAAsB,CAAC;QAC5B,KAAK,uBAAuB,CAAC;QAC7B,KAAK,wBAAwB;YACzB,OAAO,IAAI,sBAAsB,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,23 +0,0 @@
|
|
|
1
|
-
import { PreCheckoutQuery } from '@mtcute/core';
|
|
2
|
-
/**
|
|
3
|
-
* Context of a pre-checkout query update
|
|
4
|
-
*
|
|
5
|
-
* This is a subclass of {@link PreCheckoutQuery}, so all its fields are also available.
|
|
6
|
-
*/
|
|
7
|
-
export class PreCheckoutQueryContext extends PreCheckoutQuery {
|
|
8
|
-
client;
|
|
9
|
-
_name = 'pre_checkout_query';
|
|
10
|
-
constructor(client, query) {
|
|
11
|
-
super(query.raw, query._peers);
|
|
12
|
-
this.client = client;
|
|
13
|
-
}
|
|
14
|
-
/** Approve the query */
|
|
15
|
-
approve() {
|
|
16
|
-
return this.client.answerPreCheckoutQuery(this.raw.queryId);
|
|
17
|
-
}
|
|
18
|
-
/** Decline the query, optionally with an error */
|
|
19
|
-
decline(error = '') {
|
|
20
|
-
return this.client.answerPreCheckoutQuery(this.raw.queryId, { error });
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
//# 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,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAK/C;;;;GAIG;AACH,MAAM,OAAO,uBAAwB,SAAQ,gBAAgB;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","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"]}
|