fix mini app bot father

This commit is contained in:
lendry
2026-06-26 11:18:07 +03:00
parent 7ed7cbdd16
commit d3ea470d02
12 changed files with 313 additions and 39 deletions

View File

@@ -1160,7 +1160,13 @@ export class AuthGrpcController {
@GrpcMethod('BotService', 'ListAllBots')
listAllBots(command: { requesterId: string; isSuperAdmin?: boolean; search?: string; page?: number; limit?: number }) {
return this.botFather.listAllBots(command.requesterId, Boolean(command.isSuperAdmin), command.search, command.page, command.limit);
return this.botFather.listAllBots(
command.requesterId,
Boolean(command.isSuperAdmin),
command.search,
Number(command.page) || 1,
Number(command.limit) || 20
);
}
@GrpcMethod('BotService', 'SetBotActive')

View File

@@ -9,15 +9,19 @@ export function resolvePublicFrontendUrl() {
return (process.env.PUBLIC_FRONTEND_URL ?? 'http://localhost:3002').replace(/\/$/, '');
}
export function buildBotFatherWebAppUrl() {
return `${resolvePublicFrontendUrl()}/mini-apps/bot-father`;
}
export function buildBotManageWebAppUrl(botId: string) {
return `${resolvePublicFrontendUrl()}/mini-apps/bot-manage?botId=${botId}`;
return `${resolvePublicFrontendUrl()}/mini-apps/bot-father?botId=${encodeURIComponent(botId)}`;
}
export function buildBotCreateWebAppUrl() {
return `${resolvePublicFrontendUrl()}/mini-apps/bot-create`;
return `${buildBotFatherWebAppUrl()}?mode=create`;
}
export function isBotManageWebAppUrl(url: string | null | undefined) {
if (!url?.trim()) return false;
return url.includes('/mini-apps/bot-manage');
return url.includes('/mini-apps/bot-manage') || url.includes('/mini-apps/bot-father');
}

View File

@@ -1,4 +1,4 @@
import { BOTFATHER_BOT_USERNAME, buildBotCreateWebAppUrl, isBotManageWebAppUrl } from './bot-father.constants';
import { BOTFATHER_BOT_USERNAME, buildBotFatherWebAppUrl, isBotManageWebAppUrl } from './bot-father.constants';
export type TelegramMenuButtonDefault = { type: 'default' };
export type TelegramMenuButtonCommands = { type: 'commands' };
@@ -141,11 +141,11 @@ export function resolveComposerMenuButton(options: {
}
if (options.bot.isSystemBot || options.bot.username === BOTFATHER_BOT_USERNAME) {
const url = buildBotCreateWebAppUrl();
const url = buildBotFatherWebAppUrl();
return {
menuButton: { type: 'web_app', text: 'Создать бота', web_app: { url } },
menuButton: { type: 'web_app', text: 'BotFather', web_app: { url } },
composerWebAppUrl: url,
buttonText: 'Создать бота'
buttonText: 'BotFather'
};
}