ibrohm commited on
Commit
7560d9e
Β·
1 Parent(s): b0dcff5

feat/fix: Stagger pollinations generation to avoid proxy rate-limits and log english prompt in telegram

Browse files
Files changed (1) hide show
  1. bot/bot.js +11 -11
bot/bot.js CHANGED
@@ -812,19 +812,19 @@ if (process.env.BOT_TOKEN && process.env.BOT_TOKEN !== 'YOUR_TELEGRAM_BOT_TOKEN'
812
  await ctx.reply('⏳ Gemini promptni kengaytirib, Flux 2 ta variant yaratmoqda... (Kuting, 20-40 soniya)');
813
 
814
  try {
815
- // Ikkalasini xavfsiz yuklab olish (biri xato qilsa ham ikkinchisi ishlaydi)
816
- const results = await Promise.allSettled([
817
- downloadImage(url1),
818
- downloadImage(url2)
819
- ]);
820
 
821
  let msg1, msg2;
822
  let fileId1 = null, fileId2 = null;
823
 
824
  // 1-variant tekshiriladi
825
- if (results[0].status === 'fulfilled') {
826
- msg1 = await ctx.replyWithPhoto({ source: results[0].value, filename: 'variant1.jpg' }, {
827
- caption: `🎨 *Variant 1*\nπŸ“ _"${originalPrompt}"_\n\nπŸ€– _Gemini kuchi bilan yozildi_`,
828
  parse_mode: 'Markdown',
829
  ...Markup.inlineKeyboard([[Markup.button.callback('βœ… Shu rasmni tanlash', 'ai_pick_1')]])
830
  });
@@ -834,9 +834,9 @@ if (process.env.BOT_TOKEN && process.env.BOT_TOKEN !== 'YOUR_TELEGRAM_BOT_TOKEN'
834
  }
835
 
836
  // 2-variant tekshiriladi
837
- if (results[1].status === 'fulfilled') {
838
- msg2 = await ctx.replyWithPhoto({ source: results[1].value, filename: 'variant2.jpg' }, {
839
- caption: `🎨 *Variant 2*\nπŸ“ _"${originalPrompt}"_\n\nπŸ€– _Gemini kuchi bilan yozildi_`,
840
  parse_mode: 'Markdown',
841
  ...Markup.inlineKeyboard([[Markup.button.callback('βœ… Shu rasmni tanlash', 'ai_pick_2')]])
842
  });
 
812
  await ctx.reply('⏳ Gemini promptni kengaytirib, Flux 2 ta variant yaratmoqda... (Kuting, 20-40 soniya)');
813
 
814
  try {
815
+ // Ikkalasini xavfsiz yuklab olish qotib qolmasligi uchun biroz kutamiz (stagger resquests)
816
+ let res1, res2;
817
+ try { res1 = await downloadImage(url1); } catch (err) { res1 = null; console.error("URL1 fail:", err); }
818
+ await new Promise(r => setTimeout(r, 1000)); // 1 soniya pauza
819
+ try { res2 = await downloadImage(url2); } catch (err) { res2 = null; console.error("URL2 fail:", err); }
820
 
821
  let msg1, msg2;
822
  let fileId1 = null, fileId2 = null;
823
 
824
  // 1-variant tekshiriladi
825
+ if (res1) {
826
+ msg1 = await ctx.replyWithPhoto({ source: res1, filename: 'variant1.jpg' }, {
827
+ caption: `🎨 *Variant 1*\nπŸ“ _"${originalPrompt}"_\n\nπŸ” *Gemini yozgan Inglizcha buyruq:* \n\`${finalPrompt}\``,
828
  parse_mode: 'Markdown',
829
  ...Markup.inlineKeyboard([[Markup.button.callback('βœ… Shu rasmni tanlash', 'ai_pick_1')]])
830
  });
 
834
  }
835
 
836
  // 2-variant tekshiriladi
837
+ if (res2) {
838
+ msg2 = await ctx.replyWithPhoto({ source: res2, filename: 'variant2.jpg' }, {
839
+ caption: `🎨 *Variant 2*\nπŸ“ _"${originalPrompt}"_\n\nπŸ” *Gemini yozgan Inglizcha buyruq:* \n\`${finalPrompt}\``,
840
  parse_mode: 'Markdown',
841
  ...Markup.inlineKeyboard([[Markup.button.callback('βœ… Shu rasmni tanlash', 'ai_pick_2')]])
842
  });