diff --git a/WhatsApp Image 2026-10-06 at 11.31.02 _1_-1.jpeg b/WhatsApp Image 2026-10-06 at 11.31.02 _1_-1.jpeg new file mode 100644 index 0000000..950c30f Binary files /dev/null and b/WhatsApp Image 2026-10-06 at 11.31.02 _1_-1.jpeg differ diff --git a/WhatsApp Image 2026-10-06 at 11.31.02 _2_-1.jpeg b/WhatsApp Image 2026-10-06 at 11.31.02 _2_-1.jpeg new file mode 100644 index 0000000..0ab89b8 Binary files /dev/null and b/WhatsApp Image 2026-10-06 at 11.31.02 _2_-1.jpeg differ diff --git a/WhatsApp Image 2026-10-06 at 11.31.02-1.jpeg b/WhatsApp Image 2026-10-06 at 11.31.02-1.jpeg new file mode 100644 index 0000000..4581c46 Binary files /dev/null and b/WhatsApp Image 2026-10-06 at 11.31.02-1.jpeg differ diff --git a/WhatsApp Image 2026-10-06 at 11.31.03 _1_-1.jpeg b/WhatsApp Image 2026-10-06 at 11.31.03 _1_-1.jpeg new file mode 100644 index 0000000..c84acad Binary files /dev/null and b/WhatsApp Image 2026-10-06 at 11.31.03 _1_-1.jpeg differ diff --git a/WhatsApp Image 2026-10-06 at 11.31.03 _2_-1.jpeg b/WhatsApp Image 2026-10-06 at 11.31.03 _2_-1.jpeg new file mode 100644 index 0000000..73a99b6 Binary files /dev/null and b/WhatsApp Image 2026-10-06 at 11.31.03 _2_-1.jpeg differ diff --git a/bot.js b/bot.js index 8af3859..08c5e62 100644 --- a/bot.js +++ b/bot.js @@ -59,6 +59,7 @@ function formatOrder(order) { return `πŸ“¦ НомСр Π·Π°ΠΊΠ°Π·Π°: ${order.id}\n` + `🧁 Π’ΠΈΠ΄: ${order.type}\n` + `πŸ”’ ΠšΠΎΠ»β€‘Π²ΠΎ: ${order.quantity}\n` + + `🧩 Π’Π°Ρ€ΠΈΠ°Π½Ρ‚: ${order.variant + 1}\n` + `πŸ“… Π”Π°Ρ‚Π° доставки: ${order.date}\n` + `πŸ•’ ВрСмя: ${order.time}\n` + `πŸ‘€ Имя: ${order.name}\n` @@ -77,14 +78,20 @@ bot.command('start', async (ctx) => { await ctx.replyWithPhoto(new InputFile(filePath), { caption: `Π’Π°Ρ€ΠΈΠ°Π½Ρ‚ ${i + 1}` }).catch(() => {}); } // Кнопки Π²Ρ‹Π±ΠΎΡ€Π° Ρ‚ΠΈΠΏΠ° ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚Π° - await ctx.reply('Какой Π²Π°Ρ€ΠΈΠ°Π½Ρ‚ вас интСрСсуСт?', { + // ΠŸΡ€Π΅Π΄Π»Π°Π³Π°Π΅ΠΌ Π²Ρ‹Π±Ρ€Π°Ρ‚ΡŒ Π²Π°Ρ€ΠΈΠ°Π½Ρ‚ Ρ‚ΠΎΠ²Π°Ρ€Π° с Ρ†Π΅Π½ΠΎΠΉ + const variantButtons = images.map((_, i) => { + const price = i % 2 === 0 ? PRICE['Π±ΡƒΠΊΠ΅Ρ‚'] : PRICE['ΠΊΠΎΡ€ΠΎΠ±ΠΊΠ°']; + return `Π’Π°Ρ€ΠΈΠ°Π½Ρ‚ ${i + 1} – ${price}β‚Έ`; + }); + const variantKeyboard = variantButtons.map(b => [b]); + await ctx.reply('Π’Ρ‹Π±Π΅Ρ€ΠΈΡ‚Π΅ Π²Π°Ρ€ΠΈΠ°Π½Ρ‚ Ρ‚ΠΎΠ²Π°Ρ€Π°:', { reply_markup: { - keyboard: [['Π‘ΡƒΠΊΠ΅Ρ‚', 'ΠšΠΎΡ€ΠΎΠ±ΠΊΠ°']], + keyboard: variantKeyboard, one_time_keyboard: true, resize_keyboard: true, }, }); - setStage(ctx.chat.id, { stage: 'choose_type' }); + setStage(ctx.chat.id, { stage: 'choose_variant' }); }); bot.on('message:text', async (ctx) => { @@ -99,7 +106,28 @@ bot.on('message:text', async (ctx) => { } switch (session.stage) { -case 'choose_type': { +case 'choose_variant': { + const match = text.match(/Π’Π°Ρ€ΠΈΠ°Π½Ρ‚\s(\d+)/); + if (!match) { + await ctx.reply('ΠŸΠΎΠΆΠ°Π»ΡƒΠΉΡΡ‚Π°, Π²Ρ‹Π±Π΅Ρ€ΠΈΡ‚Π΅ Π²Π°Ρ€ΠΈΠ°Π½Ρ‚ ΠΈΠ· списка.'); + return; + } + const idx = parseInt(match[1], 10) - 1; + if (idx < 0 || idx >= images.length) { + await ctx.reply('ΠΠ΅ΠΏΡ€Π°Π²ΠΈΠ»ΡŒΠ½Ρ‹ΠΉ Π²Π°Ρ€ΠΈΠ°Π½Ρ‚.'); + return; + } + setStage(chatId, { variant: idx, stage: 'choose_type' }); + await ctx.reply('Какой Π²Π°Ρ€ΠΈΠ°Π½Ρ‚ вас интСрСсуСт? Π’Ρ‹Π±Π΅Ρ€ΠΈΡ‚Π΅: Π‘ΡƒΠΊΠ΅Ρ‚ ΠΈΠ»ΠΈ ΠšΠΎΡ€ΠΎΠ±ΠΊΠ°.', { + reply_markup: { + keyboard: [['Π‘ΡƒΠΊΠ΅Ρ‚', 'ΠšΠΎΡ€ΠΎΠ±ΠΊΠ°']], + one_time_keyboard: true, + resize_keyboard: true, + }, + }); + break; + } + case 'choose_type': { if (text !== 'Π±ΡƒΠΊΠ΅Ρ‚' && text !== 'ΠΊΠΎΡ€ΠΎΠ±ΠΊΠ°') { await ctx.reply('ΠŸΠΎΠΆΠ°Π»ΡƒΠΉΡΡ‚Π°, ΡƒΠΊΠ°ΠΆΠΈΡ‚Π΅ "Π±ΡƒΠΊΠ΅Ρ‚" ΠΈΠ»ΠΈ "ΠΊΠΎΡ€ΠΎΠ±ΠΊΠ°".'); return; @@ -253,7 +281,7 @@ case 'await_time': { const { type, quantity, date, time, name } = session; const total = PRICE[type] * quantity; const orderId = Date.now(); - const order = { id: orderId, type, quantity, date, time, name, phone, total }; + const order = { id: orderId, type, quantity, date, time, name, phone, total, variant: session.variant }; saveOrder(order); // Π€ΠΎΡ€ΠΌΠΈΡ€ΡƒΠ΅ΠΌ ΠΈΡ‚ΠΎΠ³ΠΎΠ²ΠΎΠ΅ сообщСниС await ctx.reply(formatOrder(order)); diff --git a/data.json b/data.json index e14e3da..ff0c19d 100644 --- a/data.json +++ b/data.json @@ -28,5 +28,25 @@ "name": "Π ΠΎΠΌΠ°Π½", "phone": "+77059631941", "total": 9000 + }, + { + "id": 1791288625288, + "type": "Π±ΡƒΠΊΠ΅Ρ‚", + "quantity": 3, + "date": "2026-10-07", + "time": "12:00", + "name": "Π ΠΎΠΌΠ°Π½", + "phone": "+77059631941", + "total": 15000 + }, + { + "id": 1791288816480, + "type": "ΠΊΠΎΡ€ΠΎΠ±ΠΊΠ°", + "quantity": 4, + "date": "2026-10-06", + "time": "12:00", + "name": "Π ΠΎ", + "phone": "97483828727181", + "total": 12000 } ] \ No newline at end of file