feat(bot): add resident payment confirmation command

This commit is contained in:
2026-03-10 22:04:07 +04:00
parent 753286a1f6
commit 7f8c238a23
6 changed files with 114 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ export interface ScopedTelegramCommands {
export interface TelegramHelpOptions {
includePrivateCommands?: boolean
includeGroupCommands?: boolean
includeAdminCommands?: boolean
}
@@ -26,8 +27,12 @@ const PRIVATE_CHAT_COMMAND_NAMES = [
'cancel'
] as const satisfies readonly TelegramCommandName[]
const GROUP_CHAT_COMMAND_NAMES = DEFAULT_COMMAND_NAMES
const GROUP_ADMIN_COMMAND_NAMES = [
const GROUP_MEMBER_COMMAND_NAMES = [
...GROUP_CHAT_COMMAND_NAMES,
'payment_add'
] as const satisfies readonly TelegramCommandName[]
const GROUP_ADMIN_COMMAND_NAMES = [
...GROUP_MEMBER_COMMAND_NAMES,
'setup',
'bind_purchase_topic',
'bind_feedback_topic',
@@ -61,7 +66,7 @@ export function getTelegramCommandScopes(locale: BotLocale): readonly ScopedTele
},
{
scope: 'all_group_chats',
commands: mapCommands(locale, GROUP_CHAT_COMMAND_NAMES)
commands: mapCommands(locale, GROUP_MEMBER_COMMAND_NAMES)
},
{
scope: 'all_chat_administrators',
@@ -76,14 +81,18 @@ export function formatTelegramHelpText(
): string {
const t = getBotTranslations(locale)
const defaultCommands = new Set<TelegramCommandName>(DEFAULT_COMMAND_NAMES)
const groupMemberCommands = new Set<TelegramCommandName>(GROUP_MEMBER_COMMAND_NAMES)
const includePrivateCommands = options.includePrivateCommands ?? true
const includeGroupCommands = options.includeGroupCommands ?? false
const includeAdminCommands = options.includeAdminCommands ?? false
const privateCommands = includePrivateCommands
? mapCommands(locale, PRIVATE_CHAT_COMMAND_NAMES)
: []
const groupCommands = includeGroupCommands ? mapCommands(locale, GROUP_MEMBER_COMMAND_NAMES) : []
const adminCommands = includeAdminCommands
? mapCommands(locale, GROUP_ADMIN_COMMAND_NAMES).filter(
(command) => !defaultCommands.has(command.command)
(command) =>
!defaultCommands.has(command.command) && !groupMemberCommands.has(command.command)
)
: []
@@ -96,6 +105,13 @@ export function formatTelegramHelpText(
)
}
if (groupCommands.length > 0) {
sections.push(
t.help.groupHeading,
...groupCommands.map((command) => `/${command.command} - ${command.description}`)
)
}
if (adminCommands.length > 0) {
sections.push(
t.help.groupAdminsHeading,