@mtcute/dispatcher 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/cjs/context/business-message.d.ts +60 -0
  2. package/cjs/context/business-message.js +146 -0
  3. package/cjs/context/business-message.js.map +1 -0
  4. package/cjs/context/parse.d.ts +12 -0
  5. package/cjs/context/parse.js +5 -0
  6. package/cjs/context/parse.js.map +1 -1
  7. package/cjs/dispatcher.d.ts +121 -2
  8. package/cjs/dispatcher.js +43 -1
  9. package/cjs/dispatcher.js.map +1 -1
  10. package/cjs/filters/bots.d.ts +6 -5
  11. package/cjs/filters/bots.js.map +1 -1
  12. package/cjs/filters/chat.d.ts +2 -2
  13. package/cjs/filters/chat.js.map +1 -1
  14. package/cjs/filters/group.d.ts +4 -3
  15. package/cjs/filters/group.js.map +1 -1
  16. package/cjs/filters/message.d.ts +27 -18
  17. package/cjs/filters/message.js +10 -3
  18. package/cjs/filters/message.js.map +1 -1
  19. package/cjs/filters/user.js +3 -1
  20. package/cjs/filters/user.js.map +1 -1
  21. package/cjs/handler.d.ts +8 -2
  22. package/cjs/handler.js.map +1 -1
  23. package/cjs/index.js +6 -0
  24. package/cjs/state/key.d.ts +2 -1
  25. package/cjs/state/key.js +1 -1
  26. package/cjs/state/key.js.map +1 -1
  27. package/cjs/wizard.d.ts +5 -1
  28. package/cjs/wizard.js +3 -0
  29. package/cjs/wizard.js.map +1 -1
  30. package/esm/context/business-message.d.ts +60 -0
  31. package/esm/context/business-message.js +142 -0
  32. package/esm/context/business-message.js.map +1 -0
  33. package/esm/context/parse.d.ts +12 -0
  34. package/esm/context/parse.js +5 -0
  35. package/esm/context/parse.js.map +1 -1
  36. package/esm/dispatcher.d.ts +121 -2
  37. package/esm/dispatcher.js +43 -1
  38. package/esm/dispatcher.js.map +1 -1
  39. package/esm/filters/bots.d.ts +6 -5
  40. package/esm/filters/bots.js.map +1 -1
  41. package/esm/filters/chat.d.ts +2 -2
  42. package/esm/filters/chat.js.map +1 -1
  43. package/esm/filters/group.d.ts +4 -3
  44. package/esm/filters/group.js.map +1 -1
  45. package/esm/filters/message.d.ts +27 -18
  46. package/esm/filters/message.js +8 -2
  47. package/esm/filters/message.js.map +1 -1
  48. package/esm/filters/user.js +3 -1
  49. package/esm/filters/user.js.map +1 -1
  50. package/esm/handler.d.ts +8 -2
  51. package/esm/handler.js.map +1 -1
  52. package/esm/state/key.d.ts +2 -1
  53. package/esm/state/key.js +1 -1
  54. package/esm/state/key.js.map +1 -1
  55. package/esm/wizard.d.ts +5 -1
  56. package/esm/wizard.js +3 -0
  57. package/esm/wizard.js.map +1 -1
  58. package/index.d.ts +1 -0
  59. package/index.js +1 -0
  60. package/package.json +3 -3
@@ -0,0 +1,142 @@
1
+ import { BusinessMessage } from '@mtcute/core';
2
+ /**
3
+ * Context of a business message related update.
4
+ *
5
+ * This is a subclass of {@link BusinessMessage}, 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 BusinessMessageContext#messages}.
10
+ */
11
+ export class BusinessMessageContext extends BusinessMessage {
12
+ client;
13
+ // this is primarily for proper types in filters, so don't bother much with actual value
14
+ _name = 'new_business_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.update, msg._peers);
26
+ this.client = client;
27
+ this.messages = Array.isArray(message) ? message.map((it) => new BusinessMessageContext(client, it)) : [this];
28
+ this.isMessageGroup = Array.isArray(message);
29
+ }
30
+ /** Get all custom emojis contained in this message (message group), if any */
31
+ getCustomEmojis() {
32
+ return this.client.getCustomEmojisFromMessages(this.messages);
33
+ }
34
+ /** Send a text message to the same chat (and topic, if applicable) as a given message */
35
+ answerText(...params) {
36
+ const [send, params_ = {}] = params;
37
+ params_.businessConnectionId = this.update.connectionId;
38
+ return this.client.answerText(this, send, params_);
39
+ }
40
+ /** Send a media to the same chat (and topic, if applicable) as a given message */
41
+ answerMedia(...params) {
42
+ const [send, params_ = {}] = params;
43
+ params_.businessConnectionId = this.update.connectionId;
44
+ return this.client.answerMedia(this, send, params_);
45
+ }
46
+ /** Send a media group to the same chat (and topic, if applicable) as a given message */
47
+ answerMediaGroup(...params) {
48
+ const [send, params_ = {}] = params;
49
+ params_.businessConnectionId = this.update.connectionId;
50
+ return this.client.answerMediaGroup(this, send, params_);
51
+ }
52
+ /** Send a text message in reply to this message */
53
+ replyText(...params) {
54
+ const [send, params_ = {}] = params;
55
+ params_.businessConnectionId = this.update.connectionId;
56
+ return this.client.replyText(this, send, params_);
57
+ }
58
+ /** Send a media in reply to this message */
59
+ replyMedia(...params) {
60
+ const [send, params_ = {}] = params;
61
+ params_.businessConnectionId = this.update.connectionId;
62
+ return this.client.replyMedia(this, send, params_);
63
+ }
64
+ /** Send a media group in reply to this message */
65
+ replyMediaGroup(...params) {
66
+ const [send, params_ = {}] = params;
67
+ params_.businessConnectionId = this.update.connectionId;
68
+ return this.client.replyMediaGroup(this, send, params_);
69
+ }
70
+ /** Send a text message in reply to this message */
71
+ quoteWithText(params) {
72
+ params.businessConnectionId = this.update.connectionId;
73
+ return this.client.quoteWithText(this, params);
74
+ }
75
+ /** Send a media in reply to this message */
76
+ quoteWithMedia(params) {
77
+ params.businessConnectionId = this.update.connectionId;
78
+ return this.client.quoteWithMedia(this, params);
79
+ }
80
+ /** Send a media group in reply to this message */
81
+ quoteWithMediaGroup(params) {
82
+ params.businessConnectionId = this.update.connectionId;
83
+ return this.client.quoteWithMediaGroup(this, params);
84
+ }
85
+ /** Delete this message (message group) */
86
+ delete(params) {
87
+ return this.client.deleteMessagesById(this.chat.inputPeer, this.messages.map((it) => it.id), params);
88
+ }
89
+ /** Pin this message */
90
+ pin(params) {
91
+ return this.client.pinMessage({
92
+ chatId: this.chat.inputPeer,
93
+ message: this.id,
94
+ ...params,
95
+ });
96
+ }
97
+ /** Unpin this message */
98
+ unpin() {
99
+ return this.client.unpinMessage({
100
+ chatId: this.chat.inputPeer,
101
+ message: this.id,
102
+ });
103
+ }
104
+ /** Edit this message */
105
+ edit(params) {
106
+ return this.client.editMessage({
107
+ chatId: this.chat.inputPeer,
108
+ message: this.id,
109
+ ...params,
110
+ });
111
+ }
112
+ /** Forward this message (message group) */
113
+ forwardTo(params) {
114
+ return this.client.forwardMessagesById({
115
+ fromChatId: this.chat.inputPeer,
116
+ messages: this.messages.map((it) => it.id),
117
+ ...params,
118
+ });
119
+ }
120
+ /** Send a copy of this message (message group) */
121
+ copy(params) {
122
+ if (this.isMessageGroup) {
123
+ return this.client.sendCopyGroup({
124
+ messages: this.messages,
125
+ ...params,
126
+ });
127
+ }
128
+ return this.client.sendCopy({
129
+ message: this,
130
+ ...params,
131
+ });
132
+ }
133
+ /** React to this message */
134
+ react(params) {
135
+ return this.client.sendReaction({
136
+ chatId: this.chat.inputPeer,
137
+ message: this.id,
138
+ ...params,
139
+ });
140
+ }
141
+ }
142
+ //# sourceMappingURL=business-message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"business-message.js","sourceRoot":"","sources":["../../../src/context/business-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAuC,MAAM,cAAc,CAAA;AAWnF;;;;;;;;GAQG;AACH,MAAM,OAAO,sBAAuB,SAAQ,eAAe;IAe1C;IAdb,wFAAwF;IAC/E,KAAK,GAAG,sBAAsB,CAAA;IAEvC;;;;OAIG;IACM,QAAQ,CAA0B;IAE3C,mDAAmD;IAC1C,cAAc,CAAS;IAEhC,YACa,MAAsB,EAC/B,OAA4C;QAE5C,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,C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C,SAAS;YAC3B,OAAO,EAAE,IAAI,CAAC,EAAE;YAChB,GAAG,MAAM;SACZ,CAAC,CAAA;IACN,CAAC;IAED,2CAA2C;IAC3C,SAAS,CAAC,MAA6B;QACnC,OAAO,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC;YACnC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS;YAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;YAC1C,GAAG,MAAM;SACZ,CAAC,CAAA;IACN,CAAC;IAED,kDAAkD;IAClD,IAAI,CAAC,MAA4C;QAC7C,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;gBAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,GAAG,MAAM;aACZ,CAAC,CAAA;QACN,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;YACxB,OAAO,EAAE,IAAI;YACb,GAAG,MAAM;SACZ,CAAC,CAAA;IACN,CAAC;IAED,4BAA4B;IAC5B,KAAK,CAAC,MAAyE;QAC3E,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 { BusinessMessage, OmitInputMessageId, ParametersSkip1 } from '@mtcute/core'\nimport { TelegramClient } from '@mtcute/core/client.js'\nimport {\n DeleteMessagesParams,\n ForwardMessageOptions,\n SendCopyGroupParams,\n SendCopyParams,\n} from '@mtcute/core/methods.js'\n\nimport { UpdateContext } from './base.js'\n\n/**\n * Context of a business message related update.\n *\n * This is a subclass of {@link BusinessMessage}, 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 BusinessMessageContext#messages}.\n */\nexport class BusinessMessageContext extends BusinessMessage implements UpdateContext<BusinessMessage> {\n // this is primarily for proper types in filters, so don't bother much with actual value\n readonly _name = 'new_business_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: BusinessMessageContext[]\n\n /** Whether this update is about a message group */\n readonly isMessageGroup: boolean\n\n constructor(\n readonly client: TelegramClient,\n message: BusinessMessage | BusinessMessage[],\n ) {\n const msg = Array.isArray(message) ? message[message.length - 1] : message\n super(msg.update, msg._peers)\n\n this.messages = Array.isArray(message) ? message.map((it) => new BusinessMessageContext(client, it)) : [this]\n this.isMessageGroup = Array.isArray(message)\n }\n\n /** Get all custom emojis contained in this message (message group), if any */\n getCustomEmojis() {\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']>) {\n const [send, params_ = {}] = params\n params_.businessConnectionId = this.update.connectionId\n\n return this.client.answerText(this, send, 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']>) {\n const [send, params_ = {}] = params\n params_.businessConnectionId = this.update.connectionId\n\n return this.client.answerMedia(this, send, 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']>) {\n const [send, params_ = {}] = params\n params_.businessConnectionId = this.update.connectionId\n\n return this.client.answerMediaGroup(this, send, params_)\n }\n\n /** Send a text message in reply to this message */\n replyText(...params: ParametersSkip1<TelegramClient['replyText']>) {\n const [send, params_ = {}] = params\n params_.businessConnectionId = this.update.connectionId\n\n return this.client.replyText(this, send, params_)\n }\n\n /** Send a media in reply to this message */\n replyMedia(...params: ParametersSkip1<TelegramClient['replyMedia']>) {\n const [send, params_ = {}] = params\n params_.businessConnectionId = this.update.connectionId\n\n return this.client.replyMedia(this, send, params_)\n }\n\n /** Send a media group in reply to this message */\n replyMediaGroup(...params: ParametersSkip1<TelegramClient['replyMediaGroup']>) {\n const [send, params_ = {}] = params\n params_.businessConnectionId = this.update.connectionId\n\n return this.client.replyMediaGroup(this, send, params_)\n }\n\n /** Send a text message in reply to this message */\n quoteWithText(params: Parameters<TelegramClient['quoteWithText']>[1]) {\n params.businessConnectionId = this.update.connectionId\n\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]) {\n params.businessConnectionId = this.update.connectionId\n\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]) {\n params.businessConnectionId = this.update.connectionId\n\n return this.client.quoteWithMediaGroup(this, params)\n }\n\n /** Delete this message (message group) */\n delete(params?: DeleteMessagesParams) {\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]>) {\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() {\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]>) {\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) {\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) {\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(params: OmitInputMessageId<Parameters<TelegramClient['sendReaction']>[0]>) {\n return this.client.sendReaction({\n chatId: this.chat.inputPeer,\n message: this.id,\n ...params,\n })\n }\n}\n"]}
@@ -1 +1,13 @@
1
+ import { ParsedUpdate } from '@mtcute/core';
2
+ import { TelegramClient } from '@mtcute/core/client.js';
3
+ import { UpdateContextDistributed } from './base.js';
4
+ import { BusinessMessageContext } from './business-message.js';
5
+ import { CallbackQueryContext } 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
+ /** @internal */
12
+ export declare function _parsedUpdateToContext(client: TelegramClient, update: ParsedUpdate): BusinessMessageContext | CallbackQueryContext | ChatJoinRequestUpdateContext | ChosenInlineResultContext | InlineQueryContext | MessageContext | PreCheckoutQueryContext | UpdateContextDistributed<import("@mtcute/core").DeleteMessageUpdate | import("@mtcute/core").ChatMemberUpdate | import("@mtcute/core").InlineCallbackQuery | import("@mtcute/core").PollUpdate | import("@mtcute/core").PollVoteUpdate | import("@mtcute/core").UserStatusUpdate | import("@mtcute/core").UserTypingUpdate | import("@mtcute/core").HistoryReadUpdate | import("@mtcute/core").BotStoppedUpdate | import("@mtcute/core").ChatJoinRequestUpdate | import("@mtcute/core").StoryUpdate | import("@mtcute/core").DeleteStoryUpdate | import("@mtcute/core").BotReactionUpdate | import("@mtcute/core").BotReactionCountUpdate | import("@mtcute/core").BusinessConnection | import("@mtcute/core").DeleteBusinessMessageUpdate>;
1
13
  export type UpdateContextType = ReturnType<typeof _parsedUpdateToContext>;
@@ -1,3 +1,4 @@
1
+ import { BusinessMessageContext } from './business-message.js';
1
2
  import { CallbackQueryContext } from './callback-query.js';
2
3
  import { ChatJoinRequestUpdateContext } from './chat-join-request.js';
3
4
  import { ChosenInlineResultContext } from './chosen-inline-result.js';
@@ -21,6 +22,10 @@ export function _parsedUpdateToContext(client, update) {
21
22
  return new ChatJoinRequestUpdateContext(client, update.data);
22
23
  case 'pre_checkout_query':
23
24
  return new PreCheckoutQueryContext(client, update.data);
25
+ case 'new_business_message':
26
+ case 'edit_business_message':
27
+ case 'business_message_group':
28
+ return new BusinessMessageContext(client, update.data);
24
29
  }
25
30
  const _update = update.data;
26
31
  _update.client = client;
@@ -1 +1 @@
1
- {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/context/parse.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,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;AAEjE,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,4BAA4B,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAChE,KAAK,oBAAoB;YACrB,OAAO,IAAI,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;IAC/D,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 { ParsedUpdate } from '@mtcute/core'\nimport { TelegramClient } from '@mtcute/core/client.js'\n\nimport { UpdateContextDistributed } from './base.js'\nimport { CallbackQueryContext } 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\n/** @internal */\nexport function _parsedUpdateToContext(client: TelegramClient, update: ParsedUpdate) {\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 'bot_chat_join_request':\n return new ChatJoinRequestUpdateContext(client, update.data)\n case 'pre_checkout_query':\n return new PreCheckoutQueryContext(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\nexport type UpdateContextType = ReturnType<typeof _parsedUpdateToContext>\n"]}
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/context/parse.ts"],"names":[],"mappings":"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,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 { ParsedUpdate } from '@mtcute/core'\nimport { TelegramClient } from '@mtcute/core/client.js'\n\nimport { UpdateContextDistributed } from './base.js'\nimport { BusinessMessageContext } from './business-message.js'\nimport { CallbackQueryContext } 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\n/** @internal */\nexport function _parsedUpdateToContext(client: TelegramClient, update: ParsedUpdate) {\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 '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\nexport type UpdateContextType = ReturnType<typeof _parsedUpdateToContext>\n"]}
@@ -1,9 +1,10 @@
1
- import { BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, ChatJoinRequestUpdate, ChatMemberUpdate, DeleteMessageUpdate, DeleteStoryUpdate, HistoryReadUpdate, MaybePromise, ParsedUpdate, PeersIndex, PollUpdate, PollVoteUpdate, StoryUpdate, tl, UserStatusUpdate, UserTypingUpdate } from '@mtcute/core';
1
+ import { BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessConnection, ChatJoinRequestUpdate, ChatMemberUpdate, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, HistoryReadUpdate, MaybePromise, ParsedUpdate, PeersIndex, PollUpdate, PollVoteUpdate, StoryUpdate, tl, UserStatusUpdate, UserTypingUpdate } from '@mtcute/core';
2
2
  import { TelegramClient } from '@mtcute/core/client.js';
3
3
  import { UpdateContext } from './context/base.js';
4
+ import { BusinessMessageContext } from './context/business-message.js';
4
5
  import { CallbackQueryContext, ChatJoinRequestUpdateContext, ChosenInlineResultContext, InlineCallbackQueryContext, InlineQueryContext, MessageContext, PreCheckoutQueryContext } from './context/index.js';
5
6
  import { filters, UpdateFilter } from './filters/index.js';
6
- import { BotChatJoinRequestHandler, BotReactionCountUpdateHandler, BotReactionUpdateHandler, BotStoppedHandler, CallbackQueryHandler, ChatJoinRequestHandler, ChatMemberUpdateHandler, ChosenInlineResultHandler, DeleteMessageHandler, DeleteStoryHandler, EditMessageHandler, HistoryReadHandler, InlineCallbackQueryHandler, InlineQueryHandler, MessageGroupHandler, NewMessageHandler, PollUpdateHandler, PollVoteHandler, PreCheckoutQueryHandler, RawUpdateHandler, StoryUpdateHandler, UpdateHandler, UserStatusUpdateHandler, UserTypingHandler } from './handler.js';
7
+ import { BotChatJoinRequestHandler, BotReactionCountUpdateHandler, BotReactionUpdateHandler, BotStoppedHandler, BusinessConnectionUpdateHandler, BusinessMessageGroupHandler, CallbackQueryHandler, ChatJoinRequestHandler, ChatMemberUpdateHandler, ChosenInlineResultHandler, DeleteBusinessMessageHandler, DeleteMessageHandler, DeleteStoryHandler, EditBusinessMessageHandler, EditMessageHandler, HistoryReadHandler, InlineCallbackQueryHandler, InlineQueryHandler, MessageGroupHandler, NewBusinessMessageHandler, NewMessageHandler, PollUpdateHandler, PollVoteHandler, PreCheckoutQueryHandler, RawUpdateHandler, StoryUpdateHandler, UpdateHandler, UserStatusUpdateHandler, UserTypingHandler } from './handler.js';
7
8
  import { PropagationAction } from './propagation.js';
8
9
  import { IStateStorageProvider, StateKeyDelegate, UpdateState } from './state/index.js';
9
10
  export interface DispatcherParams {
@@ -24,6 +25,8 @@ export interface DispatcherParams {
24
25
  */
25
26
  key?: StateKeyDelegate;
26
27
  }
28
+ export interface DispatcherDependencies {
29
+ }
27
30
  /**
28
31
  * Updates dispatcher
29
32
  */
@@ -40,6 +43,7 @@ export declare class Dispatcher<State extends object = never> {
40
43
  private _stateKeyDelegate?;
41
44
  private _customStateKeyDelegate?;
42
45
  private _customStorage?;
46
+ private _deps;
43
47
  private _errorHandler?;
44
48
  private _preUpdateHandler?;
45
49
  private _postUpdateHandler?;
@@ -58,6 +62,22 @@ export declare class Dispatcher<State extends object = never> {
58
62
  static scene<State extends object = Record<never, never>>(name: string, params?: Omit<DispatcherParams, 'sceneName'>): Dispatcher<State>;
59
63
  /** For scene dispatchers, name of the scene */
60
64
  get sceneName(): string | undefined;
65
+ /**
66
+ * Inject a dependency to be available in this dispatcher and all its children.
67
+ *
68
+ * **Note**: This is only available for the root dispatcher.
69
+ */
70
+ inject<Name extends keyof DispatcherDependencies>(name: Name, value: DispatcherDependencies[Name]): void;
71
+ /**
72
+ * Inject dependencies to be available in this dispatcher and all its children.
73
+ *
74
+ * **Note**: This is only available for the root dispatcher.
75
+ */
76
+ inject(deps: Partial<DispatcherDependencies>): void;
77
+ /**
78
+ * Get the dependencies injected into this dispatcher.
79
+ */
80
+ get deps(): DispatcherDependencies;
61
81
  /**
62
82
  * Bind the dispatcher to the client.
63
83
  * Called by the constructor automatically if
@@ -690,4 +710,103 @@ export declare class Dispatcher<State extends object = never> {
690
710
  * @param group Handler group index
691
711
  */
692
712
  onBotReactionCountUpdate<Mod>(filter: UpdateFilter<UpdateContext<BotReactionCountUpdate>, Mod>, handler: BotReactionCountUpdateHandler<filters.Modify<UpdateContext<BotReactionCountUpdate>, Mod>>['callback'], group?: number): void;
713
+ /**
714
+ * Register a business connection update handler without any filters
715
+ *
716
+ * @param handler Business connection update handler
717
+ * @param group Handler group index
718
+ */
719
+ onBusinessConnectionUpdate(handler: BusinessConnectionUpdateHandler['callback'], group?: number): void;
720
+ /**
721
+ * Register a business connection update handler with a filter
722
+ *
723
+ * @param filter Update filter
724
+ * @param handler Business connection update handler
725
+ * @param group Handler group index
726
+ */
727
+ onBusinessConnectionUpdate<Mod>(filter: UpdateFilter<UpdateContext<BusinessConnection>, Mod>, handler: BusinessConnectionUpdateHandler<filters.Modify<UpdateContext<BusinessConnection>, Mod>>['callback'], group?: number): void;
728
+ /**
729
+ * Register a new business message handler without any filters
730
+ *
731
+ * @param handler New business message handler
732
+ * @param group Handler group index
733
+ */
734
+ onNewBusinessMessage(handler: NewBusinessMessageHandler<BusinessMessageContext, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
735
+ /**
736
+ * Register a new business message handler with a filter
737
+ *
738
+ * @param filter Update filter
739
+ * @param handler New business message handler
740
+ * @param group Handler group index
741
+ */
742
+ onNewBusinessMessage<Mod>(filter: UpdateFilter<BusinessMessageContext, Mod, State>, handler: NewBusinessMessageHandler<filters.Modify<BusinessMessageContext, Mod>, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
743
+ /**
744
+ * Register a new business message handler with a filter
745
+ *
746
+ * @param filter Update filter
747
+ * @param handler New business message handler
748
+ * @param group Handler group index
749
+ */
750
+ onNewBusinessMessage<Mod>(filter: UpdateFilter<BusinessMessageContext, Mod>, handler: NewBusinessMessageHandler<filters.Modify<BusinessMessageContext, Mod>, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
751
+ /**
752
+ * Register an edit business message handler without any filters
753
+ *
754
+ * @param handler Edit business message handler
755
+ * @param group Handler group index
756
+ */
757
+ onEditBusinessMessage(handler: EditBusinessMessageHandler<BusinessMessageContext, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
758
+ /**
759
+ * Register an edit business message handler with a filter
760
+ *
761
+ * @param filter Update filter
762
+ * @param handler Edit business message handler
763
+ * @param group Handler group index
764
+ */
765
+ onEditBusinessMessage<Mod>(filter: UpdateFilter<BusinessMessageContext, Mod, State>, handler: EditBusinessMessageHandler<filters.Modify<BusinessMessageContext, Mod>, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
766
+ /**
767
+ * Register an edit business message handler with a filter
768
+ *
769
+ * @param filter Update filter
770
+ * @param handler Edit business message handler
771
+ * @param group Handler group index
772
+ */
773
+ onEditBusinessMessage<Mod>(filter: UpdateFilter<BusinessMessageContext, Mod>, handler: EditBusinessMessageHandler<filters.Modify<BusinessMessageContext, Mod>, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
774
+ /**
775
+ * Register a business message group handler without any filters
776
+ *
777
+ * @param handler Business message group handler
778
+ * @param group Handler group index
779
+ */
780
+ onBusinessMessageGroup(handler: BusinessMessageGroupHandler<BusinessMessageContext, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
781
+ /**
782
+ * Register a business message group handler with a filter
783
+ *
784
+ * @param filter Update filter
785
+ * @param handler Business message group handler
786
+ * @param group Handler group index
787
+ */
788
+ onBusinessMessageGroup<Mod>(filter: UpdateFilter<BusinessMessageContext, Mod, State>, handler: BusinessMessageGroupHandler<filters.Modify<BusinessMessageContext, Mod>, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
789
+ /**
790
+ * Register a business message group handler with a filter
791
+ *
792
+ * @param filter Update filter
793
+ * @param handler Business message group handler
794
+ * @param group Handler group index
795
+ */
796
+ onBusinessMessageGroup<Mod>(filter: UpdateFilter<BusinessMessageContext, Mod>, handler: BusinessMessageGroupHandler<filters.Modify<BusinessMessageContext, Mod>, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
797
+ /**
798
+ * Register a delete business message handler without any filters
799
+ *
800
+ * @param handler Delete business message handler
801
+ * @param group Handler group index
802
+ */
803
+ onDeleteBusinessMessage(handler: DeleteBusinessMessageHandler['callback'], group?: number): void;
804
+ /**
805
+ * Register a delete business message handler with a filter
806
+ *
807
+ * @param filter Update filter
808
+ * @param handler Delete business message handler
809
+ * @param group Handler group index
810
+ */
811
+ onDeleteBusinessMessage<Mod>(filter: UpdateFilter<UpdateContext<DeleteBusinessMessageUpdate>, Mod>, handler: DeleteBusinessMessageHandler<filters.Modify<UpdateContext<DeleteBusinessMessageUpdate>, Mod>>['callback'], group?: number): void;
693
812
  }
package/esm/dispatcher.js CHANGED
@@ -22,6 +22,7 @@ export class Dispatcher {
22
22
  _stateKeyDelegate;
23
23
  _customStateKeyDelegate;
24
24
  _customStorage;
25
+ _deps = {};
25
26
  _errorHandler;
26
27
  _preUpdateHandler;
27
28
  _postUpdateHandler;
@@ -75,6 +76,25 @@ export class Dispatcher {
75
76
  get sceneName() {
76
77
  return this._scene;
77
78
  }
79
+ inject(name, value) {
80
+ if (this._parent) {
81
+ throw new MtArgumentError('Cannot inject dependencies to child dispatchers');
82
+ }
83
+ if (typeof name === 'object') {
84
+ for (const [k, v] of Object.entries(name)) {
85
+ this._deps[k] = v;
86
+ }
87
+ }
88
+ else {
89
+ this._deps[name] = value;
90
+ }
91
+ }
92
+ /**
93
+ * Get the dependencies injected into this dispatcher.
94
+ */
95
+ get deps() {
96
+ return this._deps;
97
+ }
78
98
  /**
79
99
  * Bind the dispatcher to the client.
80
100
  * Called by the constructor automatically if
@@ -489,6 +509,7 @@ export class Dispatcher {
489
509
  child._parent = this;
490
510
  child._client = this._client;
491
511
  child._storage = this._storage;
512
+ child._deps = this._deps;
492
513
  child._stateKeyDelegate = this._stateKeyDelegate;
493
514
  child._customStorage ??= this._customStorage;
494
515
  child._customStateKeyDelegate ??= this._customStateKeyDelegate;
@@ -547,6 +568,7 @@ export class Dispatcher {
547
568
  }
548
569
  _unparent() {
549
570
  this._parent = this._client = undefined;
571
+ this._deps = {}; // to avoid dangling references
550
572
  this._stateKeyDelegate = undefined;
551
573
  this._storage = undefined;
552
574
  }
@@ -689,7 +711,7 @@ export class Dispatcher {
689
711
  _addKnownHandler(name, filter, handler, group) {
690
712
  if (typeof handler === 'number' || typeof handler === 'undefined') {
691
713
  this.addUpdateHandler({
692
- name,
714
+ name: name,
693
715
  callback: filter,
694
716
  }, handler);
695
717
  }
@@ -793,5 +815,25 @@ export class Dispatcher {
793
815
  onBotReactionCountUpdate(filter, handler, group) {
794
816
  this._addKnownHandler('bot_reaction_count', filter, handler, group);
795
817
  }
818
+ /** @internal */
819
+ onBusinessConnectionUpdate(filter, handler, group) {
820
+ this._addKnownHandler('business_connection', filter, handler, group);
821
+ }
822
+ /** @internal */
823
+ onNewBusinessMessage(filter, handler, group) {
824
+ this._addKnownHandler('new_business_message', filter, handler, group);
825
+ }
826
+ /** @internal */
827
+ onEditBusinessMessage(filter, handler, group) {
828
+ this._addKnownHandler('edit_business_message', filter, handler, group);
829
+ }
830
+ /** @internal */
831
+ onBusinessMessageGroup(filter, handler, group) {
832
+ this._addKnownHandler('business_message_group', filter, handler, group);
833
+ }
834
+ /** @internal */
835
+ onDeleteBusinessMessage(filter, handler, group) {
836
+ this._addKnownHandler('delete_business_message', filter, handler, group);
837
+ }
796
838
  }
797
839
  //# sourceMappingURL=dispatcher.js.map