@mtcute/dispatcher 0.16.0 → 0.16.7
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/README.md +2 -2
- package/cjs/callback-data-builder.d.ts +2 -2
- package/cjs/callback-data-builder.js +8 -6
- package/cjs/callback-data-builder.js.map +1 -1
- package/cjs/context/base.d.ts +2 -2
- package/cjs/context/base.js.map +1 -1
- package/cjs/context/business-message.d.ts +20 -19
- package/cjs/context/business-message.js +3 -3
- package/cjs/context/business-message.js.map +1 -1
- package/cjs/context/callback-query.d.ts +4 -3
- package/cjs/context/callback-query.js.map +1 -1
- package/cjs/context/chat-join-request.d.ts +2 -2
- package/cjs/context/chat-join-request.js.map +1 -1
- package/cjs/context/chosen-inline-result.d.ts +2 -2
- package/cjs/context/chosen-inline-result.js.map +1 -1
- package/cjs/context/inline-query.d.ts +4 -3
- package/cjs/context/inline-query.js.map +1 -1
- package/cjs/context/message.d.ts +6 -5
- package/cjs/context/message.js +3 -3
- package/cjs/context/message.js.map +1 -1
- package/cjs/context/parse.d.ts +5 -5
- package/cjs/context/parse.js +1 -2
- package/cjs/context/parse.js.map +1 -1
- package/cjs/context/pre-checkout-query.d.ts +2 -2
- package/cjs/context/pre-checkout-query.js.map +1 -1
- package/cjs/context/scene-transition.d.ts +1 -1
- package/cjs/context/scene-transition.js.map +1 -1
- package/cjs/dispatcher.d.ts +10 -9
- package/cjs/dispatcher.js +34 -31
- package/cjs/dispatcher.js.map +1 -1
- package/cjs/filters/bots.d.ts +15 -25
- package/cjs/filters/bots.js +36 -34
- package/cjs/filters/bots.js.map +1 -1
- package/cjs/filters/chat.d.ts +5 -5
- package/cjs/filters/chat.js +10 -9
- package/cjs/filters/chat.js.map +1 -1
- package/cjs/filters/group.d.ts +4 -4
- package/cjs/filters/group.js +3 -6
- package/cjs/filters/group.js.map +1 -1
- package/cjs/filters/index.js.map +1 -1
- package/cjs/filters/logic.d.ts +1 -1
- package/cjs/filters/logic.js +5 -7
- package/cjs/filters/logic.js.map +1 -1
- package/cjs/filters/message.d.ts +29 -146
- package/cjs/filters/message.js +84 -72
- package/cjs/filters/message.js.map +1 -1
- package/cjs/filters/state.d.ts +3 -3
- package/cjs/filters/state.js +5 -4
- package/cjs/filters/state.js.map +1 -1
- package/cjs/filters/text.d.ts +8 -8
- package/cjs/filters/text.js +27 -26
- package/cjs/filters/text.js.map +1 -1
- package/cjs/filters/types.d.ts +2 -2
- package/cjs/filters/types.js +0 -3
- package/cjs/filters/types.js.map +1 -1
- package/cjs/filters/updates.d.ts +2 -2
- package/cjs/filters/updates.js +7 -7
- package/cjs/filters/updates.js.map +1 -1
- package/cjs/filters/user.d.ts +4 -3
- package/cjs/filters/user.js +15 -16
- package/cjs/filters/user.js.map +1 -1
- package/cjs/handler.d.ts +5 -5
- package/cjs/handler.js.map +1 -1
- package/cjs/state/key.d.ts +3 -3
- package/cjs/state/key.js.map +1 -1
- package/cjs/state/provider.d.ts +2 -2
- package/cjs/state/provider.js.map +1 -1
- package/cjs/state/providers/memory.d.ts +4 -3
- package/cjs/state/providers/memory.js.map +1 -1
- package/cjs/state/providers/sqlite.d.ts +3 -3
- package/cjs/state/providers/sqlite.js.map +1 -1
- package/cjs/state/repository.d.ts +7 -7
- package/cjs/state/repository.js.map +1 -1
- package/cjs/state/service.d.ts +4 -3
- package/cjs/state/service.js.map +1 -1
- package/cjs/state/update-state.d.ts +1 -1
- package/cjs/state/update-state.js +3 -4
- package/cjs/state/update-state.js.map +1 -1
- package/cjs/wizard.d.ts +8 -7
- package/cjs/wizard.js +3 -1
- package/cjs/wizard.js.map +1 -1
- package/esm/callback-data-builder.d.ts +2 -2
- package/esm/callback-data-builder.js +8 -6
- package/esm/callback-data-builder.js.map +1 -1
- package/esm/context/base.d.ts +2 -2
- package/esm/context/base.js.map +1 -1
- package/esm/context/business-message.d.ts +20 -19
- package/esm/context/business-message.js +3 -3
- package/esm/context/business-message.js.map +1 -1
- package/esm/context/callback-query.d.ts +4 -3
- package/esm/context/callback-query.js.map +1 -1
- package/esm/context/chat-join-request.d.ts +2 -2
- package/esm/context/chat-join-request.js.map +1 -1
- package/esm/context/chosen-inline-result.d.ts +2 -2
- package/esm/context/chosen-inline-result.js.map +1 -1
- package/esm/context/inline-query.d.ts +4 -3
- package/esm/context/inline-query.js.map +1 -1
- package/esm/context/message.d.ts +6 -5
- package/esm/context/message.js +3 -3
- package/esm/context/message.js.map +1 -1
- package/esm/context/parse.d.ts +5 -5
- package/esm/context/parse.js.map +1 -1
- package/esm/context/pre-checkout-query.d.ts +2 -2
- package/esm/context/pre-checkout-query.js.map +1 -1
- package/esm/context/scene-transition.d.ts +1 -1
- package/esm/context/scene-transition.js.map +1 -1
- package/esm/dispatcher.d.ts +10 -9
- package/esm/dispatcher.js +35 -32
- package/esm/dispatcher.js.map +1 -1
- package/esm/filters/bots.d.ts +15 -25
- package/esm/filters/bots.js +32 -30
- package/esm/filters/bots.js.map +1 -1
- package/esm/filters/chat.d.ts +5 -5
- package/esm/filters/chat.js +8 -7
- package/esm/filters/chat.js.map +1 -1
- package/esm/filters/group.d.ts +4 -4
- package/esm/filters/group.js +1 -3
- package/esm/filters/group.js.map +1 -1
- package/esm/filters/index.js.map +1 -1
- package/esm/filters/logic.d.ts +1 -1
- package/esm/filters/logic.js +1 -3
- package/esm/filters/logic.js.map +1 -1
- package/esm/filters/message.d.ts +29 -146
- package/esm/filters/message.js +60 -48
- package/esm/filters/message.js.map +1 -1
- package/esm/filters/state.d.ts +3 -3
- package/esm/filters/state.js +3 -2
- package/esm/filters/state.js.map +1 -1
- package/esm/filters/text.d.ts +8 -8
- package/esm/filters/text.js +22 -20
- package/esm/filters/text.js.map +1 -1
- package/esm/filters/types.d.ts +2 -2
- package/esm/filters/types.js +0 -3
- package/esm/filters/types.js.map +1 -1
- package/esm/filters/updates.d.ts +2 -2
- package/esm/filters/updates.js +7 -7
- package/esm/filters/updates.js.map +1 -1
- package/esm/filters/user.d.ts +4 -3
- package/esm/filters/user.js +15 -16
- package/esm/filters/user.js.map +1 -1
- package/esm/handler.d.ts +5 -5
- package/esm/handler.js.map +1 -1
- package/esm/state/key.d.ts +3 -3
- package/esm/state/key.js.map +1 -1
- package/esm/state/provider.d.ts +2 -2
- package/esm/state/provider.js.map +1 -1
- package/esm/state/providers/memory.d.ts +4 -3
- package/esm/state/providers/memory.js.map +1 -1
- package/esm/state/providers/sqlite.d.ts +3 -3
- package/esm/state/providers/sqlite.js.map +1 -1
- package/esm/state/repository.d.ts +7 -7
- package/esm/state/repository.js.map +1 -1
- package/esm/state/service.d.ts +4 -3
- package/esm/state/service.js +1 -1
- package/esm/state/service.js.map +1 -1
- package/esm/state/update-state.d.ts +1 -1
- package/esm/state/update-state.js +3 -4
- package/esm/state/update-state.js.map +1 -1
- package/esm/wizard.d.ts +8 -7
- package/esm/wizard.js +3 -1
- package/esm/wizard.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +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,CAAC,OAAO,CAAA;QAC1E,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;QAJpB,WAAM,GAAN,MAAM,CAAgB;QAM/B,IAAI,CAAC,QAAQ,GAAG,K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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
|
+
{"version":3,"file":"business-message.js","sourceRoot":"","sources":["../../../src/context/business-message.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAW9C;;;;;;;;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,CAAC,OAAO,CAAA;QAC1E,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;QAJpB,WAAM,GAAN,MAAM,CAAgB;QAM/B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,sBAAsB,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QAC3G,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAChD,CAAC;IAED,8EAA8E;IAC9E,eAAe;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,2BAA2B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACjE,CAAC;IAED,yFAAyF;IACzF,UAAU,CAAC,GAAG,MAAqD;QAC/D,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,EAAE,CAAC,GAAG,MAAM,CAAA;QACnC,OAAO,CAAC,oBAAoB,GAAG,IA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C;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 type { Message, OmitInputMessageId, ParametersSkip1, Sticker } from '@mtcute/core'\nimport { BusinessMessage } 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 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(): 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 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']>): Promise<Message> {\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']>): Promise<Message[]> {\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']>): Promise<Message> {\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']>): Promise<Message> {\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']>): Promise<Message[]> {\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]): Promise<Message> {\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]): Promise<Message> {\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]): Promise<Message[]> {\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): 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 | 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(params: OmitInputMessageId<Parameters<TelegramClient['sendReaction']>[0]>): Promise<Message | null> {\n return this.client.sendReaction({\n chatId: this.chat.inputPeer,\n message: this.id,\n ...params,\n })\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { MaybePromise, Message } from '@mtcute/core';
|
|
2
|
+
import { BusinessCallbackQuery, CallbackQuery, InlineCallbackQuery } from '@mtcute/core';
|
|
3
|
+
import type { TelegramClient } from '@mtcute/core/client.js';
|
|
4
|
+
import type { UpdateContext } from './base.js';
|
|
4
5
|
/**
|
|
5
6
|
* Context of a callback query update.
|
|
6
7
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callback-query.js","sourceRoot":"","sources":["../../../src/context/callback-query.ts"],"names":[],"mappings":"
|
|
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;QAEhB,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;QAC9B,IAAI,CAAC,GAAG;YAAE,OAAM;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ACvC,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,6 +1,6 @@
|
|
|
1
1
|
import { BotChatJoinRequestUpdate } from '@mtcute/core';
|
|
2
|
-
import { TelegramClient } from '@mtcute/core/client.js';
|
|
3
|
-
import { UpdateContext } from './base.js';
|
|
2
|
+
import type { TelegramClient } from '@mtcute/core/client.js';
|
|
3
|
+
import type { UpdateContext } from './base.js';
|
|
4
4
|
/**
|
|
5
5
|
* Context of a chat join request update (for bots).
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
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 { TelegramClient } from '@mtcute/core/client.js'\n\nimport { 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
|
+
{"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,6 +1,6 @@
|
|
|
1
1
|
import { ChosenInlineResult } from '@mtcute/core';
|
|
2
|
-
import { TelegramClient } from '@mtcute/core/client.js';
|
|
3
|
-
import { UpdateContext } from './base.js';
|
|
2
|
+
import type { TelegramClient } from '@mtcute/core/client.js';
|
|
3
|
+
import type { UpdateContext } from './base.js';
|
|
4
4
|
/**
|
|
5
5
|
* Context of a chosen inline result update.
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
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 { TelegramClient } from '@mtcute/core/client.js'\n\nimport { 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"]}
|
|
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"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { ParametersSkip1 } from '@mtcute/core';
|
|
2
|
+
import { InlineQuery } from '@mtcute/core';
|
|
3
|
+
import type { TelegramClient } from '@mtcute/core/client.js';
|
|
4
|
+
import type { UpdateContext } from './base.js';
|
|
4
5
|
/**
|
|
5
6
|
* Context of an inline query update.
|
|
6
7
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-query.js","sourceRoot":"","sources":["../../../src/context/inline-query.ts"],"names":[],"mappings":"
|
|
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
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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';
|
|
5
6
|
/**
|
|
6
7
|
* Context of a message-related update.
|
|
7
8
|
*
|
|
@@ -34,7 +35,7 @@ export declare class MessageContext extends Message implements UpdateContext<Mes
|
|
|
34
35
|
/** If this is a channel post, get its automatic forward in the discussion group */
|
|
35
36
|
getDiscussionMessage(): Promise<Message | null>;
|
|
36
37
|
/** Get all custom emojis contained in this message (message group), if any */
|
|
37
|
-
getCustomEmojis(): Promise<
|
|
38
|
+
getCustomEmojis(): Promise<Sticker[]>;
|
|
38
39
|
/** Send a text message to the same chat (and topic, if applicable) as a given message */
|
|
39
40
|
answerText(...params: ParametersSkip1<TelegramClient['answerText']>): Promise<Message>;
|
|
40
41
|
/** Send a media to the same chat (and topic, if applicable) as a given message */
|
package/esm/context/message.js
CHANGED
|
@@ -24,7 +24,7 @@ export class MessageContext extends Message {
|
|
|
24
24
|
const msg = Array.isArray(message) ? message[message.length - 1] : message;
|
|
25
25
|
super(msg.raw, msg._peers, msg.isScheduled);
|
|
26
26
|
this.client = client;
|
|
27
|
-
this.messages = Array.isArray(message) ? message.map(
|
|
27
|
+
this.messages = Array.isArray(message) ? message.map(it => new MessageContext(client, it)) : [this];
|
|
28
28
|
this.isMessageGroup = Array.isArray(message);
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
@@ -109,7 +109,7 @@ export class MessageContext extends Message {
|
|
|
109
109
|
}
|
|
110
110
|
/** Delete this message (message group) */
|
|
111
111
|
delete(params) {
|
|
112
|
-
return this.client.deleteMessagesById(this.chat.inputPeer, this.messages.map(
|
|
112
|
+
return this.client.deleteMessagesById(this.chat.inputPeer, this.messages.map(it => it.id), params);
|
|
113
113
|
}
|
|
114
114
|
/** Pin this message */
|
|
115
115
|
pin(params) {
|
|
@@ -138,7 +138,7 @@ export class MessageContext extends Message {
|
|
|
138
138
|
forwardTo(params) {
|
|
139
139
|
return this.client.forwardMessagesById({
|
|
140
140
|
fromChatId: this.chat.inputPeer,
|
|
141
|
-
messages: this.messages.map(
|
|
141
|
+
messages: this.messages.map(it => it.id),
|
|
142
142
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;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 { Message, MtPeerNotFoundError, OmitInputMessageId, ParametersSkip1, Peer } from '@mtcute/core'\nimport { TelegramClient } from '@mtcute/core/client.js'\nimport { DeleteMessagesParams, ForwardMessageOptions, SendCopyGroupParams, SendCopyParams } from '@mtcute/core/methods.js'\n\nimport { 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() {\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() {\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() {\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 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']>) {\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']>) {\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']>) {\n return this.client.replyText(this, ...params)\n }\n\n /** Send a media in reply to this message */\n replyMedia(...params: ParametersSkip1<TelegramClient['replyMedia']>) {\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']>) {\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]) {\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 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 return this.client.quoteWithMediaGroup(this, params)\n }\n\n /** Send a text as a comment to this message */\n commentText(...params: ParametersSkip1<TelegramClient['commentText']>) {\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']>) {\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']>) {\n return this.client.commentMediaGroup(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
|
+
{"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;AACH,MAAM,OAAO,cAAe,SAAQ,OAAO;IAe1B;IAdb,wFAAwF;IAC/E,KAAK,GAAG,aAAa,CAAA;IAE9B;;;;OAIG;IACM,QAAQ,CAAkB;IAEnC,mDAAmD;IAC1C,cAAc,CAAS;IAEhC,YACa,MAAsB,EAC/B,OAA4B;QAE5B,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;QAC1E,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC,CAAA;QAJlC,WAAM,GAAN,MAAM,CAAgB;QAM/B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,cAAc,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QACnG,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAChD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,iBAAiB;QACnB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC,MAAM,CAAA;QAE1C,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AAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;YACxC,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,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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ParsedUpdate } from '@mtcute/core';
|
|
2
|
-
import { TelegramClient } from '@mtcute/core/client.js';
|
|
3
|
-
import { UpdateContextDistributed } from './base.js';
|
|
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
4
|
import { BusinessMessageContext } from './business-message.js';
|
|
5
5
|
import { BusinessCallbackQueryContext, CallbackQueryContext, InlineCallbackQueryContext } from './callback-query.js';
|
|
6
6
|
import { ChatJoinRequestUpdateContext } from './chat-join-request.js';
|
|
@@ -8,6 +8,6 @@ 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
|
+
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>;
|
|
11
12
|
/** @internal */
|
|
12
|
-
export declare function _parsedUpdateToContext(client: TelegramClient, update: ParsedUpdate):
|
|
13
|
-
export type UpdateContextType = ReturnType<typeof _parsedUpdateToContext>;
|
|
13
|
+
export declare function _parsedUpdateToContext(client: TelegramClient, update: ParsedUpdate): UpdateContextType;
|
package/esm/context/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/context/parse.ts"],"names":[],"mappings":"
|
|
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;A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B,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,6 +1,6 @@
|
|
|
1
1
|
import { PreCheckoutQuery } from '@mtcute/core';
|
|
2
|
-
import { TelegramClient } from '@mtcute/core/client.js';
|
|
3
|
-
import { UpdateContext } from './base.js';
|
|
2
|
+
import type { TelegramClient } from '@mtcute/core/client.js';
|
|
3
|
+
import type { UpdateContext } from './base.js';
|
|
4
4
|
/**
|
|
5
5
|
* Context of a pre-checkout query update
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
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 { TelegramClient } from '@mtcute/core/client.js'\n\nimport { UpdateContext } from './base.js'\n\n/**\n * Context of a pre-checkout query update\n *\n * This is a subclass of {@link PreCheckoutQuery}, so all its fields are also available.\n */\nexport class PreCheckoutQueryContext extends PreCheckoutQuery implements UpdateContext<PreCheckoutQuery> {\n readonly _name = 'pre_checkout_query'\n\n constructor(\n readonly client: TelegramClient,\n query: PreCheckoutQuery,\n ) {\n super(query.raw, query._peers)\n }\n\n /** Approve the query */\n approve(): Promise<void> {\n return this.client.answerPreCheckoutQuery(this.raw.queryId)\n }\n\n /** Decline the query, optionally with an error */\n decline(error = ''): Promise<void> {\n return this.client.answerPreCheckoutQuery(this.raw.queryId, { error })\n }\n}\n"]}
|
|
1
|
+
{"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"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BusinessMessageContext } from './business-message.js';
|
|
2
2
|
import { CallbackQueryContext, InlineCallbackQueryContext } from './callback-query.js';
|
|
3
3
|
import { MessageContext } from './message.js';
|
|
4
|
-
import { UpdateContextType } from './parse.js';
|
|
4
|
+
import type { UpdateContextType } from './parse.js';
|
|
5
5
|
/** Update which is dispatched whenever scene is entered or exited */
|
|
6
6
|
export declare class SceneTransitionContext {
|
|
7
7
|
/** Name of the previous scene, if any */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scene-transition.js","sourceRoot":"","sources":["../../../src/context/scene-transition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAA;AACtF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,CAAC;CACJ;AAED,eAAe,CAAC,sBAAsB,CAAC,CAAA","sourcesContent":["import { MtTypeAssertionError } from '@mtcute/core'\nimport { makeInspectable } from '@mtcute/core/utils.js'\n\nimport { BusinessMessageContext } from './business-message.js'\nimport { CallbackQueryContext, InlineCallbackQueryContext } from './callback-query.js'\nimport { MessageContext } from './message.js'\nimport { UpdateContextType } from './parse.js'\n\n/** Update which is dispatched whenever scene is entered or exited */\nexport class SceneTransitionContext {\n constructor(\n /** Name of the previous scene, if any */\n readonly previousScene: string | null,\n /** Update, handler for which triggered the transition */\n readonly update: UpdateContextType,\n ) {}\n\n /** Get {@link update}, asserting it is a message-related update */\n get message(): MessageContext {\n if (this.update instanceof MessageContext) {\n return this.update\n }\n\n throw new MtTypeAssertionError('SceneTransitionContext.message', 'message', this.update._name)\n }\n\n /** Get {@link update}, asserting it is a business message-related update */\n get businessMessage(): BusinessMessageContext {\n if (this.update instanceof BusinessMessageContext) {\n return this.update\n }\n\n throw new MtTypeAssertionError('SceneTransitionContext.businessMessage', 'business message', this.update._name)\n }\n\n /** Get {@link update}, asserting it is a callback query update */\n get callbackQuery(): CallbackQueryContext {\n if (this.update instanceof CallbackQueryContext) {\n return this.update\n }\n\n throw new MtTypeAssertionError('SceneTransitionContext.callbackQuery', 'callback query', this.update._name)\n }\n\n /** Get {@link update}, asserting it is an inline callback query update */\n get inlineCallbackQuery(): InlineCallbackQueryContext {\n if (this.update instanceof InlineCallbackQueryContext) {\n return this.update\n }\n\n throw new MtTypeAssertionError(\n 'SceneTransitionContext.inlineCallbackQuery',\n 'inline callback query',\n this.update._name,\n )\n }\n}\n\nmakeInspectable(SceneTransitionContext)\n"]}
|
|
1
|
+
{"version":3,"file":"scene-transition.js","sourceRoot":"","sources":["../../../src/context/scene-transition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO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,CAAC;QAED,MAAM,IAAI,oBAAoB,CAC1B,4CAA4C,EAC5C,uBAAuB,EACvB,IAAI,CAAC,MAAM,CAAC,KAAK,CACpB,CAAA;IACL,CAAC;CACJ;AAED,eAAe,CAAC,sBAAsB,CAAC,CAAA","sourcesContent":["import { MtTypeAssertionError } from '@mtcute/core'\nimport { makeInspectable } from '@mtcute/core/utils.js'\n\nimport { BusinessMessageContext } from './business-message.js'\nimport { CallbackQueryContext, InlineCallbackQueryContext } from './callback-query.js'\nimport { MessageContext } from './message.js'\nimport type { UpdateContextType } from './parse.js'\n\n/** Update which is dispatched whenever scene is entered or exited */\nexport class SceneTransitionContext {\n constructor(\n /** Name of the previous scene, if any */\n readonly previousScene: string | null,\n /** Update, handler for which triggered the transition */\n readonly update: UpdateContextType,\n ) {}\n\n /** Get {@link update}, asserting it is a message-related update */\n get message(): MessageContext {\n if (this.update instanceof MessageContext) {\n return this.update\n }\n\n throw new MtTypeAssertionError('SceneTransitionContext.message', 'message', this.update._name)\n }\n\n /** Get {@link update}, asserting it is a business message-related update */\n get businessMessage(): BusinessMessageContext {\n if (this.update instanceof BusinessMessageContext) {\n return this.update\n }\n\n throw new MtTypeAssertionError('SceneTransitionContext.businessMessage', 'business message', this.update._name)\n }\n\n /** Get {@link update}, asserting it is a callback query update */\n get callbackQuery(): CallbackQueryContext {\n if (this.update instanceof CallbackQueryContext) {\n return this.update\n }\n\n throw new MtTypeAssertionError('SceneTransitionContext.callbackQuery', 'callback query', this.update._name)\n }\n\n /** Get {@link update}, asserting it is an inline callback query update */\n get inlineCallbackQuery(): InlineCallbackQueryContext {\n if (this.update instanceof InlineCallbackQueryContext) {\n return this.update\n }\n\n throw new MtTypeAssertionError(\n 'SceneTransitionContext.inlineCallbackQuery',\n 'inline callback query',\n this.update._name,\n )\n }\n}\n\nmakeInspectable(SceneTransitionContext)\n"]}
|
package/esm/dispatcher.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessConnection, ChatJoinRequestUpdate, ChatMemberUpdate, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, HistoryReadUpdate, MaybePromise, ParsedUpdate, PeersIndex, PollUpdate, PollVoteUpdate, StoryUpdate,
|
|
2
|
-
import { TelegramClient } from '@mtcute/core/client.js';
|
|
3
|
-
import { UpdateContext } from './context/base.js';
|
|
4
|
-
import { BusinessMessageContext } from './context/business-message.js';
|
|
5
|
-
import { BusinessCallbackQueryContext, CallbackQueryContext, ChatJoinRequestUpdateContext, ChosenInlineResultContext, InlineCallbackQueryContext, InlineQueryContext, MessageContext, PreCheckoutQueryContext } from './context/index.js';
|
|
1
|
+
import type { BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessConnection, ChatJoinRequestUpdate, ChatMemberUpdate, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, HistoryReadUpdate, MaybePromise, ParsedUpdate, PeersIndex, PollUpdate, PollVoteUpdate, StoryUpdate, UserStatusUpdate, UserTypingUpdate, tl } from '@mtcute/core';
|
|
2
|
+
import type { TelegramClient } from '@mtcute/core/client.js';
|
|
3
|
+
import type { UpdateContext } from './context/base.js';
|
|
4
|
+
import type { BusinessMessageContext } from './context/business-message.js';
|
|
5
|
+
import type { BusinessCallbackQueryContext, CallbackQueryContext, ChatJoinRequestUpdateContext, ChosenInlineResultContext, InlineCallbackQueryContext, InlineQueryContext, MessageContext, PreCheckoutQueryContext } from './context/index.js';
|
|
6
6
|
import { SceneTransitionContext } from './context/scene-transition.js';
|
|
7
|
-
import {
|
|
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
|
-
import { PropagationAction } from './propagation.js';
|
|
10
|
-
import { IStateStorageProvider, StateKeyDelegate
|
|
7
|
+
import type { UpdateFilter, filters } from './filters/index.js';
|
|
8
|
+
import type { 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
|
+
import type { PropagationAction } from './propagation.js';
|
|
10
|
+
import type { IStateStorageProvider, StateKeyDelegate } from './state/index.js';
|
|
11
|
+
import { UpdateState } from './state/index.js';
|
|
11
12
|
export interface DispatcherParams {
|
|
12
13
|
/**
|
|
13
14
|
* If this dispatcher can be used as a scene, its unique name.
|
package/esm/dispatcher.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/* eslint-disable
|
|
2
|
-
/* eslint-disable
|
|
3
|
-
/* eslint-disable
|
|
1
|
+
/* eslint-disable ts/no-unsafe-assignment */
|
|
2
|
+
/* eslint-disable ts/no-unsafe-argument */
|
|
3
|
+
/* eslint-disable ts/no-empty-object-type */
|
|
4
4
|
// ^^ will be looked into in MTQ-29
|
|
5
5
|
import { MtArgumentError, } from '@mtcute/core';
|
|
6
6
|
import { _parsedUpdateToContext } from './context/parse.js';
|
|
7
7
|
import { SceneTransitionContext } from './context/scene-transition.js';
|
|
8
|
-
import {
|
|
8
|
+
import { UpdateState, defaultStateKeyDelegate } from './state/index.js';
|
|
9
9
|
import { StateService } from './state/service.js';
|
|
10
10
|
/**
|
|
11
11
|
* Updates dispatcher
|
|
@@ -152,7 +152,7 @@ export class Dispatcher {
|
|
|
152
152
|
return;
|
|
153
153
|
// order does not matter in the dispatcher,
|
|
154
154
|
// so we can handle each update in its own task
|
|
155
|
-
this.dispatchRawUpdateNow(update, peers).catch(
|
|
155
|
+
this.dispatchRawUpdateNow(update, peers).catch(err => this._client.emitError(err));
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
158
|
* Process a raw update right now in the current stack.
|
|
@@ -180,8 +180,9 @@ export class Dispatcher {
|
|
|
180
180
|
result = await h.callback(this._client, update, peers);
|
|
181
181
|
handled = true;
|
|
182
182
|
}
|
|
183
|
-
else
|
|
183
|
+
else {
|
|
184
184
|
continue;
|
|
185
|
+
}
|
|
185
186
|
switch (result) {
|
|
186
187
|
case 'continue':
|
|
187
188
|
continue;
|
|
@@ -214,7 +215,7 @@ export class Dispatcher {
|
|
|
214
215
|
return;
|
|
215
216
|
// order does not matter in the dispatcher,
|
|
216
217
|
// so we can handle each update in its own task
|
|
217
|
-
this.dispatchUpdateNow(update).catch(
|
|
218
|
+
this.dispatchUpdateNow(update).catch(err => this._client.emitError(err));
|
|
218
219
|
}
|
|
219
220
|
/**
|
|
220
221
|
* Process an update right now in the current stack.
|
|
@@ -236,15 +237,15 @@ export class Dispatcher {
|
|
|
236
237
|
if (!this._client)
|
|
237
238
|
return false;
|
|
238
239
|
if (parsedScene === undefined) {
|
|
239
|
-
if (this._storage
|
|
240
|
-
this._scenes
|
|
241
|
-
(update.name === 'new_message'
|
|
242
|
-
update.name === 'edit_message'
|
|
243
|
-
update.name === 'callback_query'
|
|
244
|
-
update.name === 'message_group'
|
|
245
|
-
update.name === 'new_business_message'
|
|
246
|
-
update.name === 'edit_business_message'
|
|
247
|
-
update.name === 'business_message_group')) {
|
|
240
|
+
if (this._storage
|
|
241
|
+
&& this._scenes
|
|
242
|
+
&& (update.name === 'new_message'
|
|
243
|
+
|| update.name === 'edit_message'
|
|
244
|
+
|| update.name === 'callback_query'
|
|
245
|
+
|| update.name === 'message_group'
|
|
246
|
+
|| update.name === 'new_business_message'
|
|
247
|
+
|| update.name === 'edit_business_message'
|
|
248
|
+
|| update.name === 'business_message_group')) {
|
|
248
249
|
// no need to fetch scene if there are no registered scenes
|
|
249
250
|
if (!parsedContext)
|
|
250
251
|
parsedContext = _parsedUpdateToContext(this._client, update);
|
|
@@ -276,21 +277,21 @@ export class Dispatcher {
|
|
|
276
277
|
}
|
|
277
278
|
}
|
|
278
279
|
if (parsedState === undefined) {
|
|
279
|
-
if (this._storage
|
|
280
|
-
(update.name === 'new_message'
|
|
281
|
-
update.name === 'edit_message'
|
|
282
|
-
update.name === 'callback_query'
|
|
283
|
-
update.name === 'message_group'
|
|
284
|
-
update.name === 'new_business_message'
|
|
285
|
-
update.name === 'edit_business_message'
|
|
286
|
-
update.name === 'business_message_group')) {
|
|
280
|
+
if (this._storage
|
|
281
|
+
&& (update.name === 'new_message'
|
|
282
|
+
|| update.name === 'edit_message'
|
|
283
|
+
|| update.name === 'callback_query'
|
|
284
|
+
|| update.name === 'message_group'
|
|
285
|
+
|| update.name === 'new_business_message'
|
|
286
|
+
|| update.name === 'edit_business_message'
|
|
287
|
+
|| update.name === 'business_message_group')) {
|
|
287
288
|
if (!parsedContext)
|
|
288
289
|
parsedContext = _parsedUpdateToContext(this._client, update);
|
|
289
290
|
const key = await this._stateKeyDelegate(parsedContext);
|
|
290
291
|
if (key) {
|
|
291
292
|
let customKey;
|
|
292
|
-
if (!this._customStateKeyDelegate
|
|
293
|
-
(customKey = await this._customStateKeyDelegate(parsedContext))) {
|
|
293
|
+
if (!this._customStateKeyDelegate
|
|
294
|
+
|| (customKey = await this._customStateKeyDelegate(parsedContext))) {
|
|
294
295
|
parsedState = new UpdateState(this._storage, key, this._scene ?? null, this._sceneScoped, this._customStorage, customKey);
|
|
295
296
|
}
|
|
296
297
|
}
|
|
@@ -327,8 +328,9 @@ export class Dispatcher {
|
|
|
327
328
|
result = await h.callback(parsedContext, parsedState);
|
|
328
329
|
handled = true;
|
|
329
330
|
}
|
|
330
|
-
else
|
|
331
|
+
else {
|
|
331
332
|
continue;
|
|
333
|
+
}
|
|
332
334
|
if (parsedState && this._scenes) {
|
|
333
335
|
// check if scene transition was made
|
|
334
336
|
const newScene = parsedState.scene;
|
|
@@ -348,6 +350,7 @@ export class Dispatcher {
|
|
|
348
350
|
case 'scene': {
|
|
349
351
|
const scene = parsedState.scene;
|
|
350
352
|
const dp = scene ? nextDp._scenes.get(scene) : nextDp._parent;
|
|
353
|
+
// eslint-disable-next-line ts/return-await
|
|
351
354
|
return dp._dispatchUpdateNowImpl(update, undefined, scene, true);
|
|
352
355
|
}
|
|
353
356
|
}
|
|
@@ -368,6 +371,7 @@ export class Dispatcher {
|
|
|
368
371
|
}
|
|
369
372
|
const scene = parsedState.scene;
|
|
370
373
|
const dp = scene ? this._scenes.get(scene) : this._parent;
|
|
374
|
+
// eslint-disable-next-line ts/return-await
|
|
371
375
|
return dp._dispatchUpdateNowImpl(update, undefined, scene, true);
|
|
372
376
|
}
|
|
373
377
|
}
|
|
@@ -529,10 +533,9 @@ export class Dispatcher {
|
|
|
529
533
|
}
|
|
530
534
|
_prepareChild(child) {
|
|
531
535
|
if (child._client) {
|
|
532
|
-
throw new MtArgumentError(
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
'already bound to a client. Use unbind() before calling addChild()'));
|
|
536
|
+
throw new MtArgumentError(`Provided dispatcher is ${child._parent
|
|
537
|
+
? 'already a child. Use parent.removeChild() before calling addChild()'
|
|
538
|
+
: 'already bound to a client. Use unbind() before calling addChild()'}`);
|
|
536
539
|
}
|
|
537
540
|
child._parent = this;
|
|
538
541
|
child._client = this._client;
|
|
@@ -740,7 +743,7 @@ export class Dispatcher {
|
|
|
740
743
|
_addKnownHandler(name, filter, handler, group) {
|
|
741
744
|
if (typeof handler === 'number' || typeof handler === 'undefined') {
|
|
742
745
|
this.addUpdateHandler({
|
|
743
|
-
name
|
|
746
|
+
name,
|
|
744
747
|
callback: filter,
|
|
745
748
|
}, handler);
|
|
746
749
|
}
|