mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 15:54:03 +00:00
fix(bot): avoid invalid group join button
This commit is contained in:
@@ -52,7 +52,6 @@ export function registerHouseholdSetupCommands(options: {
|
|||||||
bot: Bot
|
bot: Bot
|
||||||
householdSetupService: HouseholdSetupService
|
householdSetupService: HouseholdSetupService
|
||||||
householdOnboardingService: HouseholdOnboardingService
|
householdOnboardingService: HouseholdOnboardingService
|
||||||
miniAppBaseUrl?: string
|
|
||||||
logger?: Logger
|
logger?: Logger
|
||||||
}): void {
|
}): void {
|
||||||
options.bot.command('start', async (ctx) => {
|
options.bot.command('start', async (ctx) => {
|
||||||
@@ -161,43 +160,22 @@ export function registerHouseholdSetupCommands(options: {
|
|||||||
const joinDeepLink = ctx.me.username
|
const joinDeepLink = ctx.me.username
|
||||||
? `https://t.me/${ctx.me.username}?start=join_${encodeURIComponent(joinToken.token)}`
|
? `https://t.me/${ctx.me.username}?start=join_${encodeURIComponent(joinToken.token)}`
|
||||||
: null
|
: null
|
||||||
const joinMiniAppUrl = options.miniAppBaseUrl
|
|
||||||
? (() => {
|
|
||||||
const url = new URL(options.miniAppBaseUrl)
|
|
||||||
url.searchParams.set('join', joinToken.token)
|
|
||||||
if (ctx.me.username) {
|
|
||||||
url.searchParams.set('bot', ctx.me.username)
|
|
||||||
}
|
|
||||||
return url.toString()
|
|
||||||
})()
|
|
||||||
: null
|
|
||||||
|
|
||||||
await ctx.reply(
|
await ctx.reply(
|
||||||
[
|
[
|
||||||
`Household ${action}: ${result.household.householdName}`,
|
`Household ${action}: ${result.household.householdName}`,
|
||||||
`Chat ID: ${result.household.telegramChatId}`,
|
`Chat ID: ${result.household.telegramChatId}`,
|
||||||
'Next: open the purchase topic and run /bind_purchase_topic, then open the feedback topic and run /bind_feedback_topic.',
|
'Next: open the purchase topic and run /bind_purchase_topic, then open the feedback topic and run /bind_feedback_topic.',
|
||||||
'Members can join from the button below or from the bot link.'
|
'Members should open the bot chat from the button below and confirm the join request there.'
|
||||||
].join('\n'),
|
].join('\n'),
|
||||||
joinMiniAppUrl || joinDeepLink
|
joinDeepLink
|
||||||
? {
|
? {
|
||||||
reply_markup: {
|
reply_markup: {
|
||||||
inline_keyboard: [
|
inline_keyboard: [
|
||||||
[
|
[
|
||||||
...(joinMiniAppUrl
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
text: 'Join household',
|
|
||||||
web_app: {
|
|
||||||
url: joinMiniAppUrl
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
...(joinDeepLink
|
...(joinDeepLink
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
text: 'Open bot chat',
|
text: 'Join household',
|
||||||
url: joinDeepLink
|
url: joinDeepLink
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -130,11 +130,6 @@ if (householdConfigurationRepositoryClient) {
|
|||||||
householdConfigurationRepositoryClient.repository
|
householdConfigurationRepositoryClient.repository
|
||||||
),
|
),
|
||||||
householdOnboardingService: householdOnboardingService!,
|
householdOnboardingService: householdOnboardingService!,
|
||||||
...(runtime.miniAppAllowedOrigins[0]
|
|
||||||
? {
|
|
||||||
miniAppBaseUrl: runtime.miniAppAllowedOrigins[0]
|
|
||||||
}
|
|
||||||
: {}),
|
|
||||||
logger: getLogger('household-setup')
|
logger: getLogger('household-setup')
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user