@mtcute/dispatcher 0.2.0 → 0.2.1
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CallbackQuery, Message, TelegramClient } from '@mtcute/client';
|
|
1
|
+
import { CallbackQuery, MaybeAsync, Message, TelegramClient } from '@mtcute/client';
|
|
2
2
|
import { UpdateContext } from './base.js';
|
|
3
3
|
/**
|
|
4
4
|
* Context of a callback query update.
|
|
@@ -27,5 +27,5 @@ export declare class CallbackQueryContext extends CallbackQuery implements Updat
|
|
|
27
27
|
/**
|
|
28
28
|
* Shortcut for getting the message and editing it.
|
|
29
29
|
*/
|
|
30
|
-
editMessageWith(handler: (msg: Message) =>
|
|
30
|
+
editMessageWith(handler: (msg: Message) => MaybeAsync<Parameters<CallbackQueryContext['editMessage']>[0]>): Promise<void | Message>;
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callback-query.js","sourceRoot":"","sources":["../../../src/context/callback-query.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"callback-query.js","sourceRoot":"","sources":["../../../src/context/callback-query.ts"],"names":[],"mappings":";;;AAAA,2CAQuB;AAIvB;;;;GAIG;AACH,MAAa,oBAAqB,SAAQ,sBAAa;IAGnD,YACa,MAAsB,EAC/B,KAAoB;QAEpB,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;QAHrB,WAAM,GAAN,MAAM,CAAgB;QAH1B,UAAK,GAAG,gBAAgB,CAAA;IAOjC,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;;;;;;;OAOG;IACH,KAAK,CAAC,UAAU;QACZ,IAAI,IAAI,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AAC;CACJ;AAnED,oDAmEC","sourcesContent":["import {\n CallbackQuery,\n getMarkedPeerId,\n MaybeAsync,\n Message,\n MtArgumentError,\n MtMessageNotFoundError,\n TelegramClient,\n} from '@mtcute/client'\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 * * Message that contained the callback button that was clicked.\n *\n * Note that the message may have been deleted, in which case\n * `MessageNotFoundError` is thrown.\n *\n * Can only be used if `isInline = false`\n */\n async getMessage() {\n if (this.raw._ !== 'updateBotCallbackQuery') {\n throw new MtArgumentError('Cannot get message for inline callback query')\n }\n\n const [msg] = await this.client.getMessages(this.raw.peer, this.raw.msgId)\n\n if (!msg) {\n throw new MtMessageNotFoundError(getMarkedPeerId(this.raw.peer), this.raw.msgId, 'Message not found')\n }\n\n return msg\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 if (this.raw._ === 'updateInlineBotCallbackQuery') {\n return this.client.editInlineMessage({\n messageId: this.raw.msgId,\n ...params,\n })\n }\n\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) => MaybeAsync<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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CallbackQuery, Message, TelegramClient } from '@mtcute/client';
|
|
1
|
+
import { CallbackQuery, MaybeAsync, Message, TelegramClient } from '@mtcute/client';
|
|
2
2
|
import { UpdateContext } from './base.js';
|
|
3
3
|
/**
|
|
4
4
|
* Context of a callback query update.
|
|
@@ -27,5 +27,5 @@ export declare class CallbackQueryContext extends CallbackQuery implements Updat
|
|
|
27
27
|
/**
|
|
28
28
|
* Shortcut for getting the message and editing it.
|
|
29
29
|
*/
|
|
30
|
-
editMessageWith(handler: (msg: Message) =>
|
|
30
|
+
editMessageWith(handler: (msg: Message) => MaybeAsync<Parameters<CallbackQueryContext['editMessage']>[0]>): Promise<void | Message>;
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callback-query.js","sourceRoot":"","sources":["../../../src/context/callback-query.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EACb,eAAe,
|
|
1
|
+
{"version":3,"file":"callback-query.js","sourceRoot":"","sources":["../../../src/context/callback-query.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EACb,eAAe,EAGf,eAAe,EACf,sBAAsB,GAEzB,MAAM,gBAAgB,CAAA;AAIvB;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,aAAa;IAGnD,YACa,MAAsB,EAC/B,KAAoB;QAEpB,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;QAHrB,WAAM,GAAN,MAAM,CAAgB;QAH1B,UAAK,GAAG,gBAAgB,CAAA;IAOjC,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;;;;;;;OAOG;IACH,KAAK,CAAC,UAAU;QACZ,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,wBAAwB,EAAE;Y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ybeAsync,\n Message,\n MtArgumentError,\n MtMessageNotFoundError,\n TelegramClient,\n} from '@mtcute/client'\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 * * Message that contained the callback button that was clicked.\n *\n * Note that the message may have been deleted, in which case\n * `MessageNotFoundError` is thrown.\n *\n * Can only be used if `isInline = false`\n */\n async getMessage() {\n if (this.raw._ !== 'updateBotCallbackQuery') {\n throw new MtArgumentError('Cannot get message for inline callback query')\n }\n\n const [msg] = await this.client.getMessages(this.raw.peer, this.raw.msgId)\n\n if (!msg) {\n throw new MtMessageNotFoundError(getMarkedPeerId(this.raw.peer), this.raw.msgId, 'Message not found')\n }\n\n return msg\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 if (this.raw._ === 'updateInlineBotCallbackQuery') {\n return this.client.editInlineMessage({\n messageId: this.raw.msgId,\n ...params,\n })\n }\n\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) => MaybeAsync<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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mtcute/dispatcher",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Updates dispatcher and bot framework for @mtcute/client",
|
|
5
5
|
"author": "Alina Sireneva <alina@tei.su>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"type": "module",
|
|
9
9
|
"scripts": {},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@mtcute/client": "^0.2.
|
|
11
|
+
"@mtcute/client": "^0.2.1",
|
|
12
12
|
"@mtcute/test": "^0.2.0",
|
|
13
13
|
"events": "3.2.0"
|
|
14
14
|
},
|