mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 15:44:02 +00:00
- Wrap answerCallbackQuery and editMessageText in try-catch to handle expired queries - Answer callback queries as early as possible - Add setup_tracking to allowed pending action types for better type safety - Ignore 'query is too old' and 'message is not modified' errors gracefully
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import type { Instant } from '@household/domain'
|
|
|
|
export const TELEGRAM_PENDING_ACTION_TYPES = [
|
|
'anonymous_feedback',
|
|
'assistant_payment_confirmation',
|
|
'household_group_invite',
|
|
'payment_topic_clarification',
|
|
'payment_topic_confirmation',
|
|
'reminder_utility_entry',
|
|
'setup_topic_binding',
|
|
'setup_tracking'
|
|
] as const
|
|
|
|
export type TelegramPendingActionType = (typeof TELEGRAM_PENDING_ACTION_TYPES)[number]
|
|
|
|
export interface TelegramPendingActionRecord {
|
|
telegramUserId: string
|
|
telegramChatId: string
|
|
action: TelegramPendingActionType
|
|
payload: Record<string, unknown>
|
|
expiresAt: Instant | null
|
|
}
|
|
|
|
export interface TelegramPendingActionRepository {
|
|
upsertPendingAction(input: TelegramPendingActionRecord): Promise<TelegramPendingActionRecord>
|
|
getPendingAction(
|
|
telegramChatId: string,
|
|
telegramUserId: string
|
|
): Promise<TelegramPendingActionRecord | null>
|
|
clearPendingAction(telegramChatId: string, telegramUserId: string): Promise<void>
|
|
clearPendingActionsForChat(
|
|
telegramChatId: string,
|
|
action?: TelegramPendingActionType
|
|
): Promise<void>
|
|
}
|