mtcute/packages/dispatcher/src/context/chosen-inline-result.ts
Alina Tumanova f5976a2d74
ESM + end-to-end tests (#11)
* feat: moved tl-runtime to esm and native ArrayBuffers

* feat: migration to esm

* fix(core): web-related fixes

* test: finally, some good fucking e2e

* chore: fixed linters etc

* ci: added e2e to ci

* build(tl): fixed gen-code on node 20

* fix: codegen Uint8Array, not Buffer

never `git reset --hard` kids

* build: only do type-aware linting for `packages/*`

* build: ignore no-unresolved in ci for e2e

* fix: node 16 doesn't have subtle crypto apparently?

* fix(tests): use Uint8Array

for gods sake please can i just merge this already

* ci: don't parallel tasks in ci

because machines are utter garbage and it may just randomly break

* ci: pass secrets to e2e tests

* ci: separate cli command for ci

apparently im retarded

* fix: run codegen in e2e

im actually retarded

* ci: more fixes for e2e

* ci: debugging stuff

* ci: still debugging

* ci: hopefully fix ci???
2023-10-16 19:23:53 +03:00

38 lines
1.2 KiB
TypeScript

import { ChosenInlineResult, MtArgumentError, TelegramClient } from '@mtcute/client'
import { UpdateContext } from './base.js'
/**
* Context of a chosen inline result update.
*
* This is a subclass of {@link ChosenInlineResult}, so all its fields are also available.
*
* > **Note**: To receive these updates, you must enable
* > Inline feedback in [@BotFather](//t.me/botfather)
*/
export class ChosenInlineResultContext extends ChosenInlineResult implements UpdateContext<ChosenInlineResult> {
readonly _name = 'chosen_inline_result'
constructor(
readonly client: TelegramClient,
result: ChosenInlineResult,
) {
super(result.raw, result._peers)
}
/**
* Edit the message that was sent when this inline result that was chosen.
*
* > **Note**: This method can only be used if the message contained a reply markup
*/
async editMessage(params: Parameters<TelegramClient['editInlineMessage']>[0]): Promise<void> {
if (!this.raw.msgId) {
throw new MtArgumentError('No message ID, make sure you have included reply markup!')
}
return this.client.editInlineMessage({
...params,
messageId: this.raw.msgId,
})
}
}