@mtcute/dispatcher 0.13.4 → 0.14.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 (43) hide show
  1. package/cjs/context/callback-query.d.ts +17 -1
  2. package/cjs/context/callback-query.js +29 -1
  3. package/cjs/context/callback-query.js.map +1 -1
  4. package/cjs/context/index.d.ts +1 -0
  5. package/cjs/context/index.js +1 -0
  6. package/cjs/context/index.js.map +1 -1
  7. package/cjs/context/parse.d.ts +2 -2
  8. package/cjs/context/parse.js +2 -0
  9. package/cjs/context/parse.js.map +1 -1
  10. package/cjs/dispatcher.d.ts +28 -5
  11. package/cjs/dispatcher.js +5 -0
  12. package/cjs/dispatcher.js.map +1 -1
  13. package/cjs/filters/chat.d.ts +3 -3
  14. package/cjs/filters/chat.js.map +1 -1
  15. package/cjs/filters/text.d.ts +7 -7
  16. package/cjs/filters/text.js +7 -5
  17. package/cjs/filters/text.js.map +1 -1
  18. package/cjs/filters/user.d.ts +3 -3
  19. package/cjs/filters/user.js.map +1 -1
  20. package/cjs/handler.d.ts +3 -3
  21. package/cjs/handler.js.map +1 -1
  22. package/esm/context/callback-query.d.ts +17 -1
  23. package/esm/context/callback-query.js +28 -1
  24. package/esm/context/callback-query.js.map +1 -1
  25. package/esm/context/index.d.ts +1 -0
  26. package/esm/context/index.js +1 -0
  27. package/esm/context/index.js.map +1 -1
  28. package/esm/context/parse.d.ts +2 -2
  29. package/esm/context/parse.js +3 -1
  30. package/esm/context/parse.js.map +1 -1
  31. package/esm/dispatcher.d.ts +28 -5
  32. package/esm/dispatcher.js +5 -0
  33. package/esm/dispatcher.js.map +1 -1
  34. package/esm/filters/chat.d.ts +3 -3
  35. package/esm/filters/chat.js.map +1 -1
  36. package/esm/filters/text.d.ts +7 -7
  37. package/esm/filters/text.js +7 -5
  38. package/esm/filters/text.js.map +1 -1
  39. package/esm/filters/user.d.ts +3 -3
  40. package/esm/filters/user.js.map +1 -1
  41. package/esm/handler.d.ts +3 -3
  42. package/esm/handler.js.map +1 -1
  43. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import { CallbackQuery, InlineCallbackQuery, MaybePromise, Message } from '@mtcute/core';
1
+ import { BusinessCallbackQuery, CallbackQuery, InlineCallbackQuery, MaybePromise, Message } from '@mtcute/core';
2
2
  import { TelegramClient } from '@mtcute/core/client.js';
3
3
  import { UpdateContext } from './base.js';
4
4
  /**
@@ -44,3 +44,19 @@ export declare class InlineCallbackQueryContext extends InlineCallbackQuery impl
44
44
  */
45
45
  editMessage(params: Omit<Parameters<TelegramClient['editInlineMessage']>[0], 'messageId'>): Promise<void>;
46
46
  }
47
+ /**
48
+ * Context of an callback query update originated from a business connection message
49
+ *
50
+ * This is a subclass of {@link BusinessCallbackQuery}, so all its fields are also available.
51
+ */
52
+ export declare class BusinessCallbackQueryContext extends BusinessCallbackQuery implements UpdateContext<BusinessCallbackQuery> {
53
+ readonly client: TelegramClient;
54
+ readonly _name = "business_callback_query";
55
+ constructor(client: TelegramClient, query: BusinessCallbackQuery);
56
+ /** Answer to this callback query */
57
+ answer(params: Parameters<TelegramClient['answerCallbackQuery']>[1]): Promise<void>;
58
+ /**
59
+ * Edit the message that contained the callback button that was clicked.
60
+ */
61
+ editMessage(params: Omit<Parameters<TelegramClient['editInlineMessage']>[0], 'messageId'>): Promise<Message>;
62
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InlineCallbackQueryContext = exports.CallbackQueryContext = void 0;
3
+ exports.BusinessCallbackQueryContext = exports.InlineCallbackQueryContext = exports.CallbackQueryContext = void 0;
4
4
  const core_1 = require("@mtcute/core");
5
5
  /**
6
6
  * Context of a callback query update.
@@ -78,4 +78,32 @@ class InlineCallbackQueryContext extends core_1.InlineCallbackQuery {
78
78
  }
79
79
  }
80
80
  exports.InlineCallbackQueryContext = InlineCallbackQueryContext;
81
+ /**
82
+ * Context of an callback query update originated from a business connection message
83
+ *
84
+ * This is a subclass of {@link BusinessCallbackQuery}, so all its fields are also available.
85
+ */
86
+ class BusinessCallbackQueryContext extends core_1.BusinessCallbackQuery {
87
+ client;
88
+ _name = 'business_callback_query';
89
+ constructor(client, query) {
90
+ super(query.raw, query._peers);
91
+ this.client = client;
92
+ }
93
+ /** Answer to this callback query */
94
+ answer(params) {
95
+ return this.client.answerCallbackQuery(this.id, params);
96
+ }
97
+ /**
98
+ * Edit the message that contained the callback button that was clicked.
99
+ */
100
+ async editMessage(params) {
101
+ return this.client.editMessage({
102
+ message: this.message,
103
+ businessConnectionId: this.connectionId,
104
+ ...params,
105
+ });
106
+ }
107
+ }
108
+ exports.BusinessCallbackQueryContext = BusinessCallbackQueryContext;
81
109
  //# sourceMappingURL=callback-query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"callback-query.js","sourceRoot":"","sources":["../../../src/context/callback-query.ts"],"names":[],"mappings":";;;AAAA,uCAAwF;AAKxF;;;;GAIG;AACH,MAAa,oBAAqB,SAAQ,oBAAa;IAItC;IAHJ,KAAK,GAAG,gBAAgB,CAAA;IAEjC,YACa,MAAsB,EAC/B,KAAoB;QAEpB,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;QAHrB,WAAM,GAAN,MAAM,CAAgB;IAInC,CAAC;IAED,oCAAoC;IACpC,MAAM,CAAC,MAA4D;QAC/D,OAAO,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;IAC3D,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,UAAU;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAA;IACpD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,MAA6E;QAC3F,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;YAC3B,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI;YACrB,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK;YACvB,GAAG,MAAM;SACZ,CAAC,CAAA;IACN,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,eAAe,CAAC,OAA2F;QAC7G,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAA;QACnC,IAAI,CAAC,GAAG;YAAE,OAAM;QAEhB,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;QAC9B,IAAI,CAAC,GAAG;YAAE,OAAM;QAEhB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IAChC,CAAC;CACJ;AAhDD,oDAgDC;AAED;;;;GAIG;AACH,MAAa,0BAA2B,SAAQ,0BAAmB;IAIlD;IAHJ,KAAK,GAAG,uBAAuB,CAAA;IAExC,YACa,MAAsB,EAC/B,KAA0B;QAE1B,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;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,MAA6E;QAC3F,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;YACjC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK;YACzB,GAAG,MAAM;SACZ,CAAC,CAAA;IACN,CAAC;CACJ;AAxBD,gEAwBC","sourcesContent":["import { CallbackQuery, InlineCallbackQuery, MaybePromise, Message } from '@mtcute/core'\nimport { TelegramClient } from '@mtcute/core/client.js'\n\nimport { 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]) {\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'>) {\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(handler: (msg: Message) => MaybePromise<Parameters<CallbackQueryContext['editMessage']>[0]>) {\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]) {\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'>) {\n return this.client.editInlineMessage({\n messageId: this.raw.msgId,\n ...params,\n })\n }\n}\n"]}
1
+ {"version":3,"file":"callback-query.js","sourceRoot":"","sources":["../../../src/context/callback-query.ts"],"names":[],"mappings":";;;AAAA,uCAA+G;AAK/G;;;;GAIG;AACH,MAAa,oBAAqB,SAAQ,oBAAa;IAItC;IAHJ,KAAK,GAAG,gBAAgB,CAAA;IAEjC,YACa,MAAsB,EAC/B,KAAoB;QAEpB,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;QAHrB,WAAM,GAAN,MAAM,CAAgB;IAInC,CAAC;IAED,oCAAoC;IACpC,MAAM,CAAC,MAA4D;QAC/D,OAAO,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;IAC3D,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,UAAU;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAA;IACpD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,MAA6E;QAC3F,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;YAC3B,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI;YACrB,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK;YACvB,GAAG,MAAM;SACZ,CAAC,CAAA;IACN,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,eAAe,CAAC,OAA2F;QAC7G,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAA;QACnC,IAAI,CAAC,GAAG;YAAE,OAAM;QAEhB,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;QAC9B,IAAI,CAAC,GAAG;YAAE,OAAM;QAEhB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IAChC,CAAC;CACJ;AAhDD,oDAgDC;AAED;;;;GAIG;AACH,MAAa,0BAA2B,SAAQ,0BAAmB;IAIlD;IAHJ,KAAK,GAAG,uBAAuB,CAAA;IAExC,YACa,MAAsB,EAC/B,KAA0B;QAE1B,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;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,MAA6E;QAC3F,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;YACjC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK;YACzB,GAAG,MAAM;SACZ,CAAC,CAAA;IACN,CAAC;CACJ;AAxBD,gEAwBC;AAED;;;;GAIG;AACH,MAAa,4BACT,SAAQ,4BAAqB;IAKhB;IAHJ,KAAK,GAAG,yBAAyB,CAAA;IAE1C,YACa,MAAsB,EAC/B,KAA4B;QAE5B,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;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,MAA6E;QAC3F,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,oBAAoB,EAAE,IAAI,CAAC,YAAY;YACvC,GAAG,MAAM;SACZ,CAAC,CAAA;IACN,CAAC;CACJ;AA3BD,oEA2BC","sourcesContent":["import { BusinessCallbackQuery, CallbackQuery, InlineCallbackQuery, MaybePromise, Message } from '@mtcute/core'\nimport { TelegramClient } from '@mtcute/core/client.js'\n\nimport { 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]) {\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'>) {\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(handler: (msg: Message) => MaybePromise<Parameters<CallbackQueryContext['editMessage']>[0]>) {\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]) {\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'>) {\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]) {\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'>) {\n return this.client.editMessage({\n message: this.message,\n businessConnectionId: this.connectionId,\n ...params,\n })\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  export * from './base.js';
2
+ export * from './business-message.js';
2
3
  export * from './callback-query.js';
3
4
  export * from './chat-join-request.js';
4
5
  export * from './chosen-inline-result.js';
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./base.js"), exports);
18
+ __exportStar(require("./business-message.js"), exports);
18
19
  __exportStar(require("./callback-query.js"), exports);
19
20
  __exportStar(require("./chat-join-request.js"), exports);
20
21
  __exportStar(require("./chosen-inline-result.js"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/context/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,sDAAmC;AACnC,yDAAsC;AACtC,4DAAyC;AACzC,oDAAiC;AACjC,+CAA4B;AAE5B,0DAAuC","sourcesContent":["export * from './base.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
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/context/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,wDAAqC;AACrC,sDAAmC;AACnC,yDAAsC;AACtC,4DAAyC;AACzC,oDAAiC;AACjC,+CAA4B;AAE5B,0DAAuC","sourcesContent":["export * from './base.js'\nexport * from './business-message.js'\nexport * from './callback-query.js'\nexport * from './chat-join-request.js'\nexport * from './chosen-inline-result.js'\nexport * from './inline-query.js'\nexport * from './message.js'\nexport type { UpdateContextType } from './parse.js'\nexport * from './pre-checkout-query.js'\n"]}
@@ -2,12 +2,12 @@ import { ParsedUpdate } from '@mtcute/core';
2
2
  import { TelegramClient } from '@mtcute/core/client.js';
3
3
  import { UpdateContextDistributed } from './base.js';
4
4
  import { BusinessMessageContext } from './business-message.js';
5
- import { CallbackQueryContext, InlineCallbackQueryContext } from './callback-query.js';
5
+ import { BusinessCallbackQueryContext, CallbackQueryContext, InlineCallbackQueryContext } from './callback-query.js';
6
6
  import { ChatJoinRequestUpdateContext } from './chat-join-request.js';
7
7
  import { ChosenInlineResultContext } from './chosen-inline-result.js';
8
8
  import { InlineQueryContext } from './inline-query.js';
9
9
  import { MessageContext } from './message.js';
10
10
  import { PreCheckoutQueryContext } from './pre-checkout-query.js';
11
11
  /** @internal */
12
- export declare function _parsedUpdateToContext(client: TelegramClient, update: ParsedUpdate): BusinessMessageContext | CallbackQueryContext | InlineCallbackQueryContext | ChatJoinRequestUpdateContext | ChosenInlineResultContext | InlineQueryContext | MessageContext | PreCheckoutQueryContext | UpdateContextDistributed<import("@mtcute/core").DeleteMessageUpdate | import("@mtcute/core").ChatMemberUpdate | 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>;
12
+ export declare function _parsedUpdateToContext(client: TelegramClient, update: ParsedUpdate): BusinessMessageContext | CallbackQueryContext | InlineCallbackQueryContext | BusinessCallbackQueryContext | ChatJoinRequestUpdateContext | ChosenInlineResultContext | InlineQueryContext | MessageContext | PreCheckoutQueryContext | UpdateContextDistributed<import("@mtcute/core").DeleteMessageUpdate | import("@mtcute/core").ChatMemberUpdate | 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>;
13
13
  export type UpdateContextType = ReturnType<typeof _parsedUpdateToContext>;
@@ -23,6 +23,8 @@ function _parsedUpdateToContext(client, update) {
23
23
  return new callback_query_js_1.CallbackQueryContext(client, update.data);
24
24
  case 'inline_callback_query':
25
25
  return new callback_query_js_1.InlineCallbackQueryContext(client, update.data);
26
+ case 'business_callback_query':
27
+ return new callback_query_js_1.BusinessCallbackQueryContext(client, update.data);
26
28
  case 'bot_chat_join_request':
27
29
  return new chat_join_request_js_1.ChatJoinRequestUpdateContext(client, update.data);
28
30
  case 'pre_checkout_query':
@@ -1 +1 @@
1
- {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/context/parse.ts"],"names":[],"mappings":";;;AAIA,+DAA8D;AAC9D,2DAAsF;AACtF,iEAAqE;AACrE,uEAAqE;AACrE,uDAAsD;AACtD,6CAA6C;AAC7C,mEAAiE;AAEjE,gBAAgB;AAChB,SAAgB,sBAAsB,CAAC,MAAsB,EAAE,MAAoB;IAC/E,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,aAAa,CAAC;QACnB,KAAK,cAAc,CAAC;QACpB,KAAK,eAAe;YAChB,OAAO,IAAI,2BAAc,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAClD,KAAK,cAAc;YACf,OAAO,IAAI,oCAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QACtD,KAAK,sBAAsB;YACvB,OAAO,IAAI,mDAAyB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC7D,KAAK,gBAAgB;YACjB,OAAO,IAAI,wCAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QACxD,KAAK,uBAAuB;YACxB,OAAO,IAAI,8CAA0B,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC9D,KAAK,uBAAuB;YACxB,OAAO,IAAI,mDAA4B,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAChE,KAAK,oBAAoB;YACrB,OAAO,IAAI,+CAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC3D,KAAK,sBAAsB,CAAC;QAC5B,KAAK,uBAAuB,CAAC;QAC7B,KAAK,wBAAwB;YACzB,OAAO,IAAI,4CAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;IAC9D,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,IAAoD,CAAA;IAC3E,OAAO,CAAC,MAAM,GAAG,MAAM,CAAA;IACvB,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAA;IAE3B,OAAO,OAAO,CAAA;AAClB,CAAC;AA7BD,wDA6BC","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, 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\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 'inline_callback_query':\n return new InlineCallbackQueryContext(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
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/context/parse.ts"],"names":[],"mappings":";;;AAIA,+DAA8D;AAC9D,2DAAoH;AACpH,iEAAqE;AACrE,uEAAqE;AACrE,uDAAsD;AACtD,6CAA6C;AAC7C,mEAAiE;AAEjE,gBAAgB;AAChB,SAAgB,sBAAsB,CAAC,MAAsB,EAAE,MAAoB;IAC/E,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,aAAa,CAAC;QACnB,KAAK,cAAc,CAAC;QACpB,KAAK,eAAe;YAChB,OAAO,IAAI,2BAAc,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAClD,KAAK,cAAc;YACf,OAAO,IAAI,oCAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QACtD,KAAK,sBAAsB;YACvB,OAAO,IAAI,mDAAyB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC7D,KAAK,gBAAgB;YACjB,OAAO,IAAI,wCAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QACxD,KAAK,uBAAuB;YACxB,OAAO,IAAI,8CAA0B,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC9D,KAAK,yBAAyB;YAC1B,OAAO,IAAI,gDAA4B,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAChE,KAAK,uBAAuB;YACxB,OAAO,IAAI,mDAA4B,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAChE,KAAK,oBAAoB;YACrB,OAAO,IAAI,+CAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC3D,KAAK,sBAAsB,CAAC;QAC5B,KAAK,uBAAuB,CAAC;QAC7B,KAAK,wBAAwB;YACzB,OAAO,IAAI,4CAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;IAC9D,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,IAAoD,CAAA;IAC3E,OAAO,CAAC,MAAM,GAAG,MAAM,CAAA;IACvB,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAA;IAE3B,OAAO,OAAO,CAAA;AAClB,CAAC;AA/BD,wDA+BC","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 { 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\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 '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\nexport type UpdateContextType = ReturnType<typeof _parsedUpdateToContext>\n"]}
@@ -2,10 +2,10 @@ import { BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCo
2
2
  import { TelegramClient } from '@mtcute/core/client.js';
3
3
  import { UpdateContext } from './context/base.js';
4
4
  import { BusinessMessageContext } from './context/business-message.js';
5
- import { CallbackQueryContext, ChatJoinRequestUpdateContext, ChosenInlineResultContext, InlineCallbackQueryContext, InlineQueryContext, MessageContext, PreCheckoutQueryContext } from './context/index.js';
5
+ import { BusinessCallbackQueryContext, CallbackQueryContext, ChatJoinRequestUpdateContext, ChosenInlineResultContext, InlineCallbackQueryContext, InlineQueryContext, MessageContext, PreCheckoutQueryContext } from './context/index.js';
6
6
  import { SceneTransitionContext } from './context/scene-transition.js';
7
7
  import { filters, UpdateFilter } from './filters/index.js';
8
- 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';
8
+ import { BotChatJoinRequestHandler, BotReactionCountUpdateHandler, BotReactionUpdateHandler, BotStoppedHandler, BusinessCallbackQueryHandler, 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';
9
9
  import { PropagationAction } from './propagation.js';
10
10
  import { IStateStorageProvider, StateKeyDelegate, UpdateState } from './state/index.js';
11
11
  export interface DispatcherParams {
@@ -368,7 +368,7 @@ export declare class Dispatcher<State extends object = never> {
368
368
  * @param handler Callback query handler
369
369
  * @param group Handler group index
370
370
  */
371
- onAnyCallbackQuery(handler: CallbackQueryHandler<CallbackQueryContext | InlineCallbackQueryContext, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
371
+ onAnyCallbackQuery(handler: CallbackQueryHandler<CallbackQueryContext | InlineCallbackQueryContext | BusinessCallbackQueryContext, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
372
372
  /**
373
373
  * Register a callback query (both inline and non-inline) handler with a filter
374
374
  *
@@ -376,7 +376,7 @@ export declare class Dispatcher<State extends object = never> {
376
376
  * @param handler Callback query handler
377
377
  * @param group Handler group index
378
378
  */
379
- onAnyCallbackQuery<Mod>(filter: UpdateFilter<CallbackQueryContext | InlineCallbackQueryContext, Mod, State>, handler: CallbackQueryHandler<filters.Modify<CallbackQueryContext | InlineCallbackQueryContext, Mod>, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
379
+ onAnyCallbackQuery<Mod>(filter: UpdateFilter<CallbackQueryContext | InlineCallbackQueryContext | BusinessCallbackQueryContext, Mod, State>, handler: CallbackQueryHandler<filters.Modify<CallbackQueryContext | InlineCallbackQueryContext | BusinessCallbackQueryContext, Mod>, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
380
380
  /**
381
381
  * Register a callback query (both inline and non-inline) handler with a filter
382
382
  *
@@ -384,7 +384,7 @@ export declare class Dispatcher<State extends object = never> {
384
384
  * @param handler Callback query handler
385
385
  * @param group Handler group index
386
386
  */
387
- onAnyCallbackQuery<Mod>(filter: UpdateFilter<CallbackQueryContext | InlineCallbackQueryContext, Mod>, handler: CallbackQueryHandler<filters.Modify<CallbackQueryContext | InlineCallbackQueryContext, Mod>, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
387
+ onAnyCallbackQuery<Mod>(filter: UpdateFilter<CallbackQueryContext | InlineCallbackQueryContext | BusinessCallbackQueryContext, Mod>, handler: CallbackQueryHandler<filters.Modify<CallbackQueryContext | InlineCallbackQueryContext | BusinessCallbackQueryContext, Mod>, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
388
388
  /**
389
389
  * Register a new message handler without any filters
390
390
  *
@@ -560,6 +560,29 @@ export declare class Dispatcher<State extends object = never> {
560
560
  * @param group Handler group index
561
561
  */
562
562
  onInlineCallbackQuery<Mod>(filter: UpdateFilter<InlineCallbackQueryContext, Mod>, handler: InlineCallbackQueryHandler<filters.Modify<InlineCallbackQueryContext, Mod>, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
563
+ /**
564
+ * Register a business callback query handler without any filters
565
+ *
566
+ * @param handler Business callback query handler
567
+ * @param group Handler group index
568
+ */
569
+ onBusinessCallbackQuery(handler: BusinessCallbackQueryHandler<BusinessCallbackQueryContext, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
570
+ /**
571
+ * Register a business callback query handler with a filter
572
+ *
573
+ * @param filter Update filter
574
+ * @param handler Business callback query handler
575
+ * @param group Handler group index
576
+ */
577
+ onBusinessCallbackQuery<Mod>(filter: UpdateFilter<BusinessCallbackQueryContext, Mod, State>, handler: BusinessCallbackQueryHandler<filters.Modify<BusinessCallbackQueryContext, Mod>, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
578
+ /**
579
+ * Register a business callback query handler with a filter
580
+ *
581
+ * @param filter Update filter
582
+ * @param handler Business callback query handler
583
+ * @param group Handler group index
584
+ */
585
+ onBusinessCallbackQuery<Mod>(filter: UpdateFilter<BusinessCallbackQueryContext, Mod>, handler: BusinessCallbackQueryHandler<filters.Modify<BusinessCallbackQueryContext, Mod>, State extends never ? never : UpdateState<State>>['callback'], group?: number): void;
563
586
  /**
564
587
  * Register a poll update handler without any filters
565
588
  *
package/cjs/dispatcher.js CHANGED
@@ -786,6 +786,7 @@ class Dispatcher {
786
786
  onAnyCallbackQuery(filter, handler, group) {
787
787
  this._addKnownHandler('callback_query', filter, handler, group);
788
788
  this._addKnownHandler('inline_callback_query', filter, handler, group);
789
+ this._addKnownHandler('business_callback_query', filter, handler, group);
789
790
  }
790
791
  /** @internal */
791
792
  onNewMessage(filter, handler, group) {
@@ -824,6 +825,10 @@ class Dispatcher {
824
825
  this._addKnownHandler('inline_callback_query', filter, handler, group);
825
826
  }
826
827
  /** @internal */
828
+ onBusinessCallbackQuery(filter, handler, group) {
829
+ this._addKnownHandler('business_callback_query', filter, handler, group);
830
+ }
831
+ /** @internal */
827
832
  onPollUpdate(filter, handler, group) {
828
833
  this._addKnownHandler('poll', filter, handler, group);
829
834
  }