fix(bot): localize reminder cancellation replies

This commit is contained in:
2026-03-24 04:23:22 +04:00
parent efc2e91bf6
commit 2888438260

View File

@@ -81,6 +81,10 @@ function cancelledDraftReply(locale: BotLocale): string {
return locale === 'ru' ? 'Окей, тогда не напоминаю.' : 'Okay, I will drop this reminder.' return locale === 'ru' ? 'Окей, тогда не напоминаю.' : 'Okay, I will drop this reminder.'
} }
function cancelledSavedReply(locale: BotLocale): string {
return locale === 'ru' ? 'Окей, это напоминание убираю.' : 'Okay, I will drop this reminder.'
}
function localNowText(timezone: string, now = nowInstant()): string { function localNowText(timezone: string, now = nowInstant()): string {
const local = now.toZonedDateTimeISO(timezone) const local = now.toZonedDateTimeISO(timezone)
return [ return [
@@ -1136,8 +1140,18 @@ export function registerAdHocNotifications(options: {
if (data.startsWith(AD_HOC_NOTIFICATION_CANCEL_DRAFT_PREFIX)) { if (data.startsWith(AD_HOC_NOTIFICATION_CANCEL_DRAFT_PREFIX)) {
const proposalId = data.slice(AD_HOC_NOTIFICATION_CANCEL_DRAFT_PREFIX.length) const proposalId = data.slice(AD_HOC_NOTIFICATION_CANCEL_DRAFT_PREFIX.length)
const reminderContext = await resolveReminderTopicContext(
ctx,
options.householdConfigurationRepository
)
const payload = await loadDraft(options.promptRepository, ctx) const payload = await loadDraft(options.promptRepository, ctx)
if (!payload || payload.proposalId !== proposalId || !ctx.chat || !ctx.from) { if (
!payload ||
payload.proposalId !== proposalId ||
!ctx.chat ||
!ctx.from ||
!reminderContext
) {
await next() await next()
return return
} }
@@ -1147,9 +1161,9 @@ export function registerAdHocNotifications(options: {
ctx.from.id.toString() ctx.from.id.toString()
) )
await ctx.answerCallbackQuery({ await ctx.answerCallbackQuery({
text: 'Cancelled' text: cancelledDraftReply(reminderContext.locale)
}) })
await ctx.editMessageText('Cancelled', { await ctx.editMessageText(cancelledDraftReply(reminderContext.locale), {
reply_markup: { reply_markup: {
inline_keyboard: [] inline_keyboard: []
} }
@@ -1262,18 +1276,13 @@ export function registerAdHocNotifications(options: {
} }
await ctx.answerCallbackQuery({ await ctx.answerCallbackQuery({
text: reminderContext.locale === 'ru' ? 'Напоминание отменено.' : 'Notification cancelled.' text: cancelledSavedReply(reminderContext.locale)
}) })
await ctx.editMessageText( await ctx.editMessageText(cancelledSavedReply(reminderContext.locale), {
reminderContext.locale === 'ru'
? `Напоминание отменено: ${result.notification.notificationText}`
: `Notification cancelled: ${result.notification.notificationText}`,
{
reply_markup: { reply_markup: {
inline_keyboard: [] inline_keyboard: []
} }
} })
)
return return
} }