feat: add chat topic binding for casual conversation

Add ability to bind a dedicated chat topic where normal conversation
happens, separate from functional topics (purchases, payments, etc.)

- Add 'chat' to HOUSEHOLD_TOPIC_ROLES
- Add /bind_chat_topic command for admins
- Update i18n strings for en/ru
- Add command to admin scope in telegram-commands
This commit is contained in:
2026-03-14 23:32:14 +04:00
parent 290b18545e
commit 0af8ea6f48
6 changed files with 51 additions and 7 deletions

View File

@@ -28,6 +28,7 @@ const GROUP_INVITE_TTL_MS = 3 * 24 * 60 * 60 * 1000
const SETUP_BIND_TOPIC_ACTION = 'setup_topic_binding' as const
const SETUP_BIND_TOPIC_TTL_MS = 10 * 60 * 1000
const HOUSEHOLD_TOPIC_ROLE_ORDER: readonly HouseholdTopicRole[] = [
'chat',
'purchase',
'feedback',
'reminders',
@@ -106,11 +107,13 @@ function bindRejectionMessage(
function bindTopicUsageMessage(
locale: BotLocale,
role: 'purchase' | 'feedback' | 'reminders' | 'payments'
role: 'chat' | 'purchase' | 'feedback' | 'reminders' | 'payments'
): string {
const t = getBotTranslations(locale).setup
switch (role) {
case 'chat':
return t.useBindChatTopicInGroup
case 'purchase':
return t.useBindPurchaseTopicInGroup
case 'feedback':
@@ -124,13 +127,15 @@ function bindTopicUsageMessage(
function bindTopicSuccessMessage(
locale: BotLocale,
role: 'purchase' | 'feedback' | 'reminders' | 'payments',
role: 'chat' | 'purchase' | 'feedback' | 'reminders' | 'payments',
householdName: string,
threadId: string
): string {
const t = getBotTranslations(locale).setup
switch (role) {
case 'chat':
return t.chatTopicSaved(householdName, threadId)
case 'purchase':
return t.purchaseTopicSaved(householdName, threadId)
case 'feedback':
@@ -358,7 +363,11 @@ function setupReply(input: {
function isHouseholdTopicRole(value: string): value is HouseholdTopicRole {
return (
value === 'purchase' || value === 'feedback' || value === 'reminders' || value === 'payments'
value === 'chat' ||
value === 'purchase' ||
value === 'feedback' ||
value === 'reminders' ||
value === 'payments'
)
}
@@ -647,7 +656,7 @@ export function registerHouseholdSetupCommands(options: {
async function handleBindTopicCommand(
ctx: Context,
role: 'purchase' | 'feedback' | 'reminders' | 'payments'
role: 'chat' | 'purchase' | 'feedback' | 'reminders' | 'payments'
): Promise<void> {
const locale = await resolveReplyLocale({
ctx,
@@ -1129,6 +1138,10 @@ export function registerHouseholdSetupCommands(options: {
await ctx.reply(t.setup.unsetupComplete(result.household.householdName))
})
options.bot.command('bind_chat_topic', async (ctx) => {
await handleBindTopicCommand(ctx, 'chat')
})
options.bot.command('bind_purchase_topic', async (ctx) => {
await handleBindTopicCommand(ctx, 'purchase')
})