refactor(client)!: extracted inline callback query into a separate update
breaking: `CallbackQuery` -> `CallbackQuery` and `InlineCallbackQuery` also removed some redundant fields
This commit is contained in:
parent
e259701837
commit
2728166727
16 changed files with 190 additions and 145 deletions
|
@ -7,6 +7,7 @@ chat_member: ChatMemberUpdate = ChatMemberUpdate
|
|||
inline_query = InlineQuery in InlineQueryContext
|
||||
chosen_inline_result = ChosenInlineResult in ChosenInlineResultContext
|
||||
callback_query = CallbackQuery + State in CallbackQueryContext
|
||||
inline_callback_query = InlineCallbackQuery + State in InlineCallbackQueryContext
|
||||
poll: PollUpdate = PollUpdate
|
||||
poll_vote = PollVoteUpdate
|
||||
user_status: UserStatusUpdate = UserStatusUpdate
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { BaseTelegramClient, Long } from '@mtcute/core'
|
||||
|
||||
import { CallbackQuery } from '../../types/bots/callback-query.js'
|
||||
import { CallbackQuery } from '../../types/updates/callback-query.js'
|
||||
|
||||
/**
|
||||
* Send an answer to a callback query.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { BaseTelegramClient, Long, tl } from '@mtcute/core'
|
||||
|
||||
import { BotInline, InlineQuery, InputInlineResult } from '../../types/bots/index.js'
|
||||
import { BotInline, InputInlineResult } from '../../types/bots/index.js'
|
||||
import { InlineQuery } from '../../types/updates/inline-query.js'
|
||||
|
||||
/**
|
||||
* Answer an inline query.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { BaseTelegramClient, tl } from '@mtcute/core'
|
||||
import { assertTypeIsNot } from '@mtcute/core/utils.js'
|
||||
|
||||
import type { CallbackQuery } from '../../types/bots/callback-query.js'
|
||||
import { Message } from '../../types/messages/message.js'
|
||||
import { InputPeerLike, PeersIndex } from '../../types/peers/index.js'
|
||||
import type { CallbackQuery } from '../../types/updates/callback-query.js'
|
||||
import { isInputPeerChannel, toInputChannel } from '../../utils/peer-utils.js'
|
||||
import { resolvePeer } from '../users/resolve-peer.js'
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
export * from './callback-query.js'
|
||||
export * from './command-scope.js'
|
||||
export * from './game-high-score.js'
|
||||
export * from './inline-query.js'
|
||||
export * from './input/index.js'
|
||||
export * from './keyboard-builder.js'
|
||||
export * from './keyboards.js'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { BasicPeerType, getBasicPeerType, getMarkedPeerId, MtArgumentError, tl } from '@mtcute/core'
|
||||
import { MtArgumentError, tl } from '@mtcute/core'
|
||||
|
||||
import { makeInspectable, utf8Decode } from '../../utils/index.js'
|
||||
import { encodeInlineMessageId } from '../../utils/inline-utils.js'
|
||||
|
@ -7,11 +7,8 @@ import { Chat } from '../peers/chat.js'
|
|||
import { PeersIndex } from '../peers/peers-index.js'
|
||||
import { User } from '../peers/user.js'
|
||||
|
||||
/**
|
||||
* An incoming callback query, originated from a callback button
|
||||
* of an inline keyboard.
|
||||
*/
|
||||
export class CallbackQuery {
|
||||
/** Base class for callback queries */
|
||||
class BaseCallbackQuery {
|
||||
constructor(
|
||||
readonly raw: tl.RawUpdateBotCallbackQuery | tl.RawUpdateInlineBotCallbackQuery,
|
||||
readonly _peers: PeersIndex,
|
||||
|
@ -39,96 +36,6 @@ export class CallbackQuery {
|
|||
return this.raw.chatInstance
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this callback query originates from
|
||||
* a button that was attached to a message sent
|
||||
* *via* the bot (i.e. using inline mode).
|
||||
*
|
||||
* If `true`, `messageId` is available and `getMessage` can be used,
|
||||
* otherwise `inlineMessageId` and `inlineMessageIdStr` are available
|
||||
*/
|
||||
get isInline(): boolean {
|
||||
return this.raw._ === 'updateInlineBotCallbackQuery'
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier of the previously sent inline message,
|
||||
* that contained the button which was clicked.
|
||||
* This ID can be used in `TelegramClient.editInlineMessage`
|
||||
*
|
||||
* Is only available in case `isInline = true`
|
||||
*/
|
||||
get inlineMessageId(): tl.TypeInputBotInlineMessageID {
|
||||
if (this.raw._ !== 'updateInlineBotCallbackQuery') {
|
||||
throw new MtArgumentError('Cannot get inline message id for non-inline callback')
|
||||
}
|
||||
|
||||
return this.raw.msgId
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier of the previously sent inline message,
|
||||
* that contained the button which was clicked,
|
||||
* as a TDLib and Bot API compatible string.
|
||||
* Can be used instead of {@link inlineMessageId} in
|
||||
* case you want to store it in some storage.
|
||||
*
|
||||
* Is only available in case `isInline = true`
|
||||
*/
|
||||
get inlineMessageIdStr(): string {
|
||||
if (this.raw._ !== 'updateInlineBotCallbackQuery') {
|
||||
throw new MtArgumentError('Cannot get inline message id for non-inline callback')
|
||||
}
|
||||
|
||||
return encodeInlineMessageId(this.raw.msgId)
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier of the chat where this message was sent
|
||||
*/
|
||||
get chatId(): number {
|
||||
if (this.raw._ !== 'updateBotCallbackQuery') {
|
||||
throw new MtArgumentError('Cannot get message id for inline callback')
|
||||
}
|
||||
|
||||
return getMarkedPeerId(this.raw.peer)
|
||||
}
|
||||
|
||||
/**
|
||||
* Chat where this message was sent
|
||||
*
|
||||
* Only available in case `isInline = false`
|
||||
*/
|
||||
get chat(): Chat {
|
||||
if (this.raw._ !== 'updateBotCallbackQuery') {
|
||||
throw new MtArgumentError('Cannot get message id for inline callback')
|
||||
}
|
||||
|
||||
return new Chat(this._peers.get(this.raw.peer))
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic peer type of the chat where this message was sent,
|
||||
* derived based on {@link chatId}
|
||||
*/
|
||||
get chatType(): BasicPeerType {
|
||||
return getBasicPeerType(this.chatId)
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier of the message sent by the bot
|
||||
* that contained the button which was clicked.
|
||||
*
|
||||
* Is only available in case `isInline = false`
|
||||
*/
|
||||
get messageId(): number {
|
||||
if (this.raw._ !== 'updateBotCallbackQuery') {
|
||||
throw new MtArgumentError('Cannot get message id for inline callback')
|
||||
}
|
||||
|
||||
return this.raw.msgId
|
||||
}
|
||||
|
||||
/**
|
||||
* Data that was contained in the callback button, if any
|
||||
*
|
||||
|
@ -162,5 +69,70 @@ export class CallbackQuery {
|
|||
}
|
||||
}
|
||||
|
||||
memoizeGetters(CallbackQuery, ['user', 'chat', 'dataStr', 'inlineMessageIdStr'])
|
||||
/**
|
||||
* A callback query originating from a normal message sent by the bot.
|
||||
*/
|
||||
export class CallbackQuery extends BaseCallbackQuery {
|
||||
constructor(
|
||||
readonly raw: tl.RawUpdateBotCallbackQuery,
|
||||
_peers: PeersIndex,
|
||||
) {
|
||||
super(raw, _peers)
|
||||
}
|
||||
|
||||
/**
|
||||
* Chat where the originating message was sent
|
||||
*/
|
||||
get chat(): Chat {
|
||||
if (this.raw._ !== 'updateBotCallbackQuery') {
|
||||
throw new MtArgumentError('Cannot get message id for inline callback')
|
||||
}
|
||||
|
||||
return new Chat(this._peers.get(this.raw.peer))
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier of the message containing the button which was clicked.
|
||||
*/
|
||||
get messageId(): number {
|
||||
return this.raw.msgId
|
||||
}
|
||||
}
|
||||
|
||||
memoizeGetters(CallbackQuery, ['user', 'dataStr', 'chat'])
|
||||
makeInspectable(CallbackQuery)
|
||||
|
||||
/**
|
||||
* A callback query originating from an inline message sent by the bot.
|
||||
*/
|
||||
export class InlineCallbackQuery extends BaseCallbackQuery {
|
||||
constructor(
|
||||
readonly raw: tl.RawUpdateInlineBotCallbackQuery,
|
||||
_peers: PeersIndex,
|
||||
) {
|
||||
super(raw, _peers)
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier of the previously sent inline message,
|
||||
* that contained the button which was clicked.
|
||||
* This ID can be used in `TelegramClient.editInlineMessage`
|
||||
*/
|
||||
get inlineMessageId(): tl.TypeInputBotInlineMessageID {
|
||||
return this.raw.msgId
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier of the previously sent inline message,
|
||||
* that contained the button which was clicked,
|
||||
* as a TDLib and Bot API compatible string.
|
||||
* Can be used instead of {@link inlineMessageId} in
|
||||
* case you want to store it in some storage.
|
||||
*/
|
||||
get inlineMessageIdStr(): string {
|
||||
return encodeInlineMessageId(this.raw.msgId)
|
||||
}
|
||||
}
|
||||
|
||||
memoizeGetters(InlineCallbackQuery, ['user', 'dataStr', 'inlineMessageIdStr'])
|
||||
makeInspectable(InlineCallbackQuery)
|
|
@ -1,8 +1,10 @@
|
|||
import type { CallbackQuery, InlineQuery, Message } from '../../types/index.js'
|
||||
import type { Message } from '../../types/index.js'
|
||||
import { BotChatJoinRequestUpdate } from './bot-chat-join-request.js'
|
||||
import { BotStoppedUpdate } from './bot-stopped.js'
|
||||
import { CallbackQuery, InlineCallbackQuery } from './callback-query.js'
|
||||
import { ChatJoinRequestUpdate } from './chat-join-request.js'
|
||||
import { ChatMemberUpdate } from './chat-member-update.js'
|
||||
import { InlineQuery } from './inline-query.js'
|
||||
export type { ChatMemberUpdateType } from './chat-member-update.js'
|
||||
import { ChosenInlineResult } from './chosen-inline-result.js'
|
||||
import { DeleteMessageUpdate } from './delete-message-update.js'
|
||||
|
@ -18,12 +20,15 @@ import { UserTypingUpdate } from './user-typing-update.js'
|
|||
export {
|
||||
BotChatJoinRequestUpdate,
|
||||
BotStoppedUpdate,
|
||||
CallbackQuery,
|
||||
ChatJoinRequestUpdate,
|
||||
ChatMemberUpdate,
|
||||
ChosenInlineResult,
|
||||
DeleteMessageUpdate,
|
||||
DeleteStoryUpdate,
|
||||
HistoryReadUpdate,
|
||||
InlineCallbackQuery,
|
||||
InlineQuery,
|
||||
PollUpdate,
|
||||
PollVoteUpdate,
|
||||
PreCheckoutQuery,
|
||||
|
@ -42,6 +47,7 @@ export type ParsedUpdate =
|
|||
| { name: 'inline_query'; data: InlineQuery }
|
||||
| { name: 'chosen_inline_result'; data: ChosenInlineResult }
|
||||
| { name: 'callback_query'; data: CallbackQuery }
|
||||
| { name: 'inline_callback_query'; data: InlineCallbackQuery }
|
||||
| { name: 'poll'; data: PollUpdate }
|
||||
| { name: 'poll_vote'; data: PollVoteUpdate }
|
||||
| { name: 'user_status'; data: UserStatusUpdate }
|
||||
|
|
|
@ -11,6 +11,7 @@ import {
|
|||
DeleteMessageUpdate,
|
||||
DeleteStoryUpdate,
|
||||
HistoryReadUpdate,
|
||||
InlineCallbackQuery,
|
||||
InlineQuery,
|
||||
Message,
|
||||
ParsedUpdate,
|
||||
|
@ -44,8 +45,9 @@ export function _parseUpdate(update: tl.TypeUpdate, peers: PeersIndex): ParsedUp
|
|||
case 'updateBotInlineSend':
|
||||
return { name: 'chosen_inline_result', data: new ChosenInlineResult(update, peers) }
|
||||
case 'updateBotCallbackQuery':
|
||||
case 'updateInlineBotCallbackQuery':
|
||||
return { name: 'callback_query', data: new CallbackQuery(update, peers) }
|
||||
case 'updateInlineBotCallbackQuery':
|
||||
return { name: 'inline_callback_query', data: new InlineCallbackQuery(update, peers) }
|
||||
case 'updateMessagePoll':
|
||||
return { name: 'poll', data: new PollUpdate(update, peers) }
|
||||
case 'updateMessagePollVote':
|
||||
|
|
|
@ -1,12 +1,4 @@
|
|||
import {
|
||||
CallbackQuery,
|
||||
getMarkedPeerId,
|
||||
MaybeAsync,
|
||||
Message,
|
||||
MtArgumentError,
|
||||
MtMessageNotFoundError,
|
||||
TelegramClient,
|
||||
} from '@mtcute/client'
|
||||
import { CallbackQuery, InlineCallbackQuery, MaybeAsync, Message, TelegramClient } from '@mtcute/client'
|
||||
|
||||
import { UpdateContext } from './base.js'
|
||||
|
||||
|
@ -34,33 +26,16 @@ export class CallbackQueryContext extends CallbackQuery implements UpdateContext
|
|||
* Get the message containing the callback button being clicked.
|
||||
*
|
||||
* Note that the message may have been deleted, in which case
|
||||
* `MessageNotFoundError` is thrown.
|
||||
* `null` will be returned.
|
||||
*/
|
||||
async getMessage() {
|
||||
if (this.raw._ !== 'updateBotCallbackQuery') {
|
||||
throw new MtArgumentError('Cannot get message for inline callback query')
|
||||
}
|
||||
|
||||
const msg = await this.client.getCallbackQueryMessage(this)
|
||||
|
||||
if (!msg) {
|
||||
throw new MtMessageNotFoundError(getMarkedPeerId(this.raw.peer), this.raw.msgId, 'Message not found')
|
||||
}
|
||||
|
||||
return msg
|
||||
async getMessage(): Promise<Message | null> {
|
||||
return this.client.getCallbackQueryMessage(this)
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the message that contained the callback button that was clicked.
|
||||
*/
|
||||
async editMessage(params: Omit<Parameters<TelegramClient['editInlineMessage']>[0], 'messageId'>) {
|
||||
if (this.raw._ === 'updateInlineBotCallbackQuery') {
|
||||
return this.client.editInlineMessage({
|
||||
messageId: this.raw.msgId,
|
||||
...params,
|
||||
})
|
||||
}
|
||||
|
||||
return this.client.editMessage({
|
||||
chatId: this.raw.peer,
|
||||
message: this.raw.msgId,
|
||||
|
@ -81,3 +56,34 @@ export class CallbackQueryContext extends CallbackQuery implements UpdateContext
|
|||
return this.editMessage(res)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Context of an inline-originated callback query update.
|
||||
*
|
||||
* This is a subclass of {@link InlineCallbackQuery}, so all its fields are also available.
|
||||
*/
|
||||
export class InlineCallbackQueryContext extends InlineCallbackQuery implements UpdateContext<InlineCallbackQuery> {
|
||||
readonly _name = 'inline_callback_query'
|
||||
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
query: InlineCallbackQuery,
|
||||
) {
|
||||
super(query.raw, query._peers)
|
||||
}
|
||||
|
||||
/** Answer to this callback query */
|
||||
answer(params: Parameters<TelegramClient['answerCallbackQuery']>[1]) {
|
||||
return this.client.answerCallbackQuery(this.id, params)
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the message that contained the callback button that was clicked.
|
||||
*/
|
||||
async editMessage(params: Omit<Parameters<TelegramClient['editInlineMessage']>[0], 'messageId'>) {
|
||||
return this.client.editInlineMessage({
|
||||
messageId: this.raw.msgId,
|
||||
...params,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import {
|
|||
CallbackQueryContext,
|
||||
ChatJoinRequestUpdateContext,
|
||||
ChosenInlineResultContext,
|
||||
InlineCallbackQueryContext,
|
||||
InlineQueryContext,
|
||||
MessageContext,
|
||||
PreCheckoutQueryContext,
|
||||
|
@ -46,6 +47,7 @@ import {
|
|||
DeleteStoryHandler,
|
||||
EditMessageHandler,
|
||||
HistoryReadHandler,
|
||||
InlineCallbackQueryHandler,
|
||||
InlineQueryHandler,
|
||||
MessageGroupHandler,
|
||||
NewMessageHandler,
|
||||
|
@ -1359,6 +1361,57 @@ export class Dispatcher<State extends object = never> {
|
|||
this._addKnownHandler('callback_query', filter, handler, group)
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an inline callback query handler without any filters
|
||||
*
|
||||
* @param handler Inline callback query handler
|
||||
* @param group Handler group index
|
||||
*/
|
||||
onInlineCallbackQuery(
|
||||
handler: InlineCallbackQueryHandler<
|
||||
InlineCallbackQueryContext,
|
||||
State extends never ? never : UpdateState<State>
|
||||
>['callback'],
|
||||
group?: number,
|
||||
): void
|
||||
|
||||
/**
|
||||
* Register an inline callback query handler with a filter
|
||||
*
|
||||
* @param filter Update filter
|
||||
* @param handler Inline callback query handler
|
||||
* @param group Handler group index
|
||||
*/
|
||||
onInlineCallbackQuery<Mod>(
|
||||
filter: UpdateFilter<InlineCallbackQueryContext, Mod, State>,
|
||||
handler: InlineCallbackQueryHandler<
|
||||
filters.Modify<InlineCallbackQueryContext, Mod>,
|
||||
State extends never ? never : UpdateState<State>
|
||||
>['callback'],
|
||||
group?: number,
|
||||
): void
|
||||
|
||||
/**
|
||||
* Register an inline callback query handler with a filter
|
||||
*
|
||||
* @param filter Update filter
|
||||
* @param handler Inline callback query handler
|
||||
* @param group Handler group index
|
||||
*/
|
||||
onInlineCallbackQuery<Mod>(
|
||||
filter: UpdateFilter<InlineCallbackQueryContext, Mod>,
|
||||
handler: InlineCallbackQueryHandler<
|
||||
filters.Modify<InlineCallbackQueryContext, Mod>,
|
||||
State extends never ? never : UpdateState<State>
|
||||
>['callback'],
|
||||
group?: number,
|
||||
): void
|
||||
|
||||
/** @internal */
|
||||
onInlineCallbackQuery(filter: any, handler?: any, group?: number): void {
|
||||
this._addKnownHandler('inline_callback_query', filter, handler, group)
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a poll update handler without any filters
|
||||
*
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { CallbackQuery, ChosenInlineResult, InlineQuery, Message } from '@mtcute/client'
|
||||
import { CallbackQuery, ChosenInlineResult, InlineCallbackQuery, InlineQuery, Message } from '@mtcute/client'
|
||||
|
||||
import { UpdateContextDistributed } from '../context/base.js'
|
||||
import { UpdateFilter } from './types.js'
|
||||
|
||||
type UpdatesWithText = UpdateContextDistributed<Message | InlineQuery | ChosenInlineResult | CallbackQuery>
|
||||
type UpdatesWithText = UpdateContextDistributed<
|
||||
Message | InlineQuery | ChosenInlineResult | CallbackQuery | InlineCallbackQuery
|
||||
>
|
||||
|
||||
function extractText(obj: UpdatesWithText): string | null {
|
||||
switch (obj._name) {
|
||||
|
@ -14,6 +16,7 @@ function extractText(obj: UpdatesWithText): string | null {
|
|||
case 'chosen_inline_result':
|
||||
return obj.id
|
||||
case 'callback_query':
|
||||
case 'inline_callback_query':
|
||||
if (obj.raw.data) return obj.dataStr
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { CallbackQuery, ChatMemberUpdate, ChatMemberUpdateType, MaybeArray, UserStatus, UserStatusUpdate } from '@mtcute/client'
|
||||
import { ChatMemberUpdate, ChatMemberUpdateType, MaybeArray, UserStatus, UserStatusUpdate } from '@mtcute/client'
|
||||
|
||||
import { UpdateFilter } from './types.js'
|
||||
|
||||
|
@ -56,9 +56,3 @@ export const userStatus: {
|
|||
* regarding current user
|
||||
*/
|
||||
export const chatMemberSelf: UpdateFilter<ChatMemberUpdate, { isSelf: true }> = (upd) => upd.isSelf
|
||||
|
||||
/**
|
||||
* Create a filter for callback queries that
|
||||
* originated from an inline message
|
||||
*/
|
||||
export const callbackInline: UpdateFilter<CallbackQuery, { isInline: true }> = (q) => q.isInline
|
||||
|
|
|
@ -5,6 +5,7 @@ import {
|
|||
ChosenInlineResult,
|
||||
DeleteStoryUpdate,
|
||||
HistoryReadUpdate,
|
||||
InlineCallbackQuery,
|
||||
InlineQuery,
|
||||
MaybeArray,
|
||||
Message,
|
||||
|
@ -44,6 +45,7 @@ export const userId: {
|
|||
| ChatMemberUpdate
|
||||
| ChosenInlineResult
|
||||
| CallbackQuery
|
||||
| InlineCallbackQuery
|
||||
| PollVoteUpdate
|
||||
| BotChatJoinRequestUpdate
|
||||
>>
|
||||
|
@ -58,6 +60,7 @@ export const userId: {
|
|||
| ChatMemberUpdate
|
||||
| ChosenInlineResult
|
||||
| CallbackQuery
|
||||
| InlineCallbackQuery
|
||||
| PollVoteUpdate
|
||||
| BotChatJoinRequestUpdate
|
||||
>>
|
||||
|
|
|
@ -21,6 +21,7 @@ import {
|
|||
CallbackQueryContext,
|
||||
ChatJoinRequestUpdateContext,
|
||||
ChosenInlineResultContext,
|
||||
InlineCallbackQueryContext,
|
||||
InlineQueryContext,
|
||||
MessageContext,
|
||||
PreCheckoutQueryContext,
|
||||
|
@ -59,6 +60,11 @@ export type ChatMemberUpdateHandler<T = UpdateContext<ChatMemberUpdate>> = Parse
|
|||
export type InlineQueryHandler<T = InlineQueryContext> = ParsedUpdateHandler<'inline_query', T>
|
||||
export type ChosenInlineResultHandler<T = ChosenInlineResultContext> = ParsedUpdateHandler<'chosen_inline_result', T>
|
||||
export type CallbackQueryHandler<T = CallbackQueryContext, S = never> = ParsedUpdateHandler<'callback_query', T, S>
|
||||
export type InlineCallbackQueryHandler<T = InlineCallbackQueryContext, S = never> = ParsedUpdateHandler<
|
||||
'inline_callback_query',
|
||||
T,
|
||||
S
|
||||
>
|
||||
export type PollUpdateHandler<T = UpdateContext<PollUpdate>> = ParsedUpdateHandler<'poll', T>
|
||||
export type PollVoteHandler<T = UpdateContext<PollVoteUpdate>> = ParsedUpdateHandler<'poll_vote', T>
|
||||
export type UserStatusUpdateHandler<T = UpdateContext<UserStatusUpdate>> = ParsedUpdateHandler<'user_status', T>
|
||||
|
@ -87,6 +93,7 @@ export type UpdateHandler =
|
|||
| InlineQueryHandler
|
||||
| ChosenInlineResultHandler
|
||||
| CallbackQueryHandler
|
||||
| InlineCallbackQueryHandler
|
||||
| PollUpdateHandler
|
||||
| PollVoteHandler
|
||||
| UserStatusUpdateHandler
|
||||
|
|
|
@ -45,10 +45,9 @@ export const defaultStateKeyDelegate: StateKeyDelegate = (upd): string | null =>
|
|||
}
|
||||
|
||||
if (upd._name === 'callback_query') {
|
||||
if (upd.isInline) return null
|
||||
if (upd.chatType === 'user') return `${upd.user.id}`
|
||||
if (upd.chat.chatType === 'private') return `${upd.user.id}`
|
||||
|
||||
return `${upd.chatId}_${upd.user.id}`
|
||||
return `${upd.chat.id}_${upd.user.id}`
|
||||
}
|
||||
|
||||
return null
|
||||
|
|
Loading…
Reference in a new issue