feat(localization): add Pro subscription information and update command list

- Introduced new localization entry for Pro subscription information.
- Updated command list to include 'pro' command for better user guidance.
- Enhanced existing subscription messages for clarity and consistency.
This commit is contained in:
vchikalkin 2025-09-17 12:20:38 +03:00
parent 297ab1df2b
commit 2b2b8ebdc4
4 changed files with 37 additions and 2 deletions

View File

@ -32,6 +32,8 @@ help =
.description = Список команд и поддержка
subscribe =
.description = Оформить подписку
pro =
.description = Информация о Pro подписке
commands-list =
📋 Доступные команды:
• /addcontact — добавить контакт клиента
@ -98,4 +100,8 @@ msg-subscribe-success = ✅ Платеж успешно обработан!
msg-subscribe-error = ❌ Произошла ошибка при обработке платежа
msg-subscription-active-until = 📅 Ваша подписка активна до { $date }
msg-subscription-active-days = 📅 Осталось еще { $days } дней вашей подписки
msg-subscribe-disabled = 🚫 Подписка отключена. Все ограничения сняты! Наслаждайтесь полным доступом! 🎉
msg-subscribe-disabled = 🚫 Подписка отключена. Все ограничения сняты! Наслаждайтесь полным доступом! 🎉
# Информация о лимитах
msg-remaining-orders-this-month = 🧾 Доступно заказов в этом месяце: { $count }
msg-subscription-active-days = 📅 Осталось еще { $days } дней вашей подписки

View File

@ -1,5 +1,6 @@
export * from './add-contact';
export * from './help';
export * from './pro';
export * from './registration';
export * from './share-bot';
export * from './subscription';

View File

@ -0,0 +1,28 @@
import { type Context } from '@/bot/context';
import { logHandle } from '@/bot/helpers/logging';
import { SubscriptionsService } from '@repo/graphql/api/subscriptions';
import { Composer } from 'grammy';
const composer = new Composer<Context>();
const feature = composer.chatType('private');
feature.command('pro', logHandle('command-pro'), async (ctx) => {
const telegramId = ctx.from.id;
const subscriptionsService = new SubscriptionsService({ telegramId });
const { subscriptionSetting } = await subscriptionsService.getSubscriptionSettings();
const proEnabled = subscriptionSetting?.proEnabled;
if (!proEnabled) return ctx.reply(ctx.t('msg-subscribe-disabled'));
const { hasActiveSubscription, remainingDays, remainingOrdersCount } =
await subscriptionsService.getSubscription({ telegramId });
if (hasActiveSubscription && remainingDays > 0) {
return ctx.reply(ctx.t('msg-subscription-active-days', { days: remainingDays }));
}
return ctx.reply(ctx.t('msg-remaining-orders-this-month', { count: remainingOrdersCount }));
});
export { composer as pro };

View File

@ -5,7 +5,7 @@ import { type LanguageCode } from '@grammyjs/types';
import { type Api, type Bot, type RawApi } from 'grammy';
export async function setCommands({ api }: Bot<Context, Api<RawApi>>) {
const commands = createCommands(['start', 'addcontact', 'sharebot', 'help', 'subscribe']);
const commands = createCommands(['start', 'addcontact', 'sharebot', 'help', 'subscribe', 'pro']);
for (const command of commands) {
addLocalizations(command);