- Added new buttons and messages in Russian localization for improved user interaction. - Integrated '@grammyjs/menu' version 1.3.1 to enhance menu functionality. - Refactored bot command handlers to streamline conversation flows and improve code organization. - Updated the main menu structure to include new options for adding contacts and subscription information.
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
import { env } from './env';
|
|
import { type Context } from '@/bot/context';
|
|
import { handleAddContact, handlePro, handleShareBot, handleSubscribe } from '@/bot/handlers';
|
|
import { Menu } from '@grammyjs/menu';
|
|
import {
|
|
type InlineKeyboardMarkup,
|
|
type ReplyKeyboardMarkup,
|
|
type ReplyKeyboardRemove,
|
|
} from '@grammyjs/types';
|
|
|
|
export const KEYBOARD_SHARE_PHONE = {
|
|
reply_markup: {
|
|
keyboard: [
|
|
[
|
|
{
|
|
request_contact: true,
|
|
text: ' Отправить номер телефона',
|
|
},
|
|
],
|
|
],
|
|
one_time_keyboard: true,
|
|
} as ReplyKeyboardMarkup,
|
|
};
|
|
|
|
export const KEYBOARD_REMOVE = {
|
|
reply_markup: {
|
|
remove_keyboard: true,
|
|
} as ReplyKeyboardRemove,
|
|
};
|
|
|
|
export const KEYBOARD_SHARE_BOT = {
|
|
reply_markup: {
|
|
inline_keyboard: [
|
|
[
|
|
{
|
|
text: ' Воспользоваться ботом',
|
|
url: env.BOT_URL + '?start=new',
|
|
},
|
|
],
|
|
],
|
|
} as InlineKeyboardMarkup,
|
|
};
|
|
|
|
// Главное меню
|
|
export const mainMenu = new Menu<Context>('main-menu', { autoAnswer: true })
|
|
.text((ctx) => ctx.t('btn-add-contact'), handleAddContact)
|
|
.row()
|
|
.text((ctx) => ctx.t('btn-subscribe'), handleSubscribe)
|
|
.text((ctx) => ctx.t('btn-pro-info'), handlePro)
|
|
.row()
|
|
.text((ctx) => ctx.t('btn-share-bot'), handleShareBot)
|
|
.row()
|
|
.url(
|
|
(ctx) => ctx.t('btn-open-app'),
|
|
() => {
|
|
const botUrl = new URL(env.BOT_URL);
|
|
botUrl.searchParams.set('startapp', '');
|
|
return botUrl.toString();
|
|
},
|
|
);
|