Spaces:
Running
Running
feat/fix: Stagger pollinations generation to avoid proxy rate-limits and log english prompt in telegram
Browse files- 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
|
| 816 |
-
|
| 817 |
-
|
| 818 |
-
|
| 819 |
-
|
| 820 |
|
| 821 |
let msg1, msg2;
|
| 822 |
let fileId1 = null, fileId2 = null;
|
| 823 |
|
| 824 |
// 1-variant tekshiriladi
|
| 825 |
-
if (
|
| 826 |
-
msg1 = await ctx.replyWithPhoto({ source:
|
| 827 |
-
caption: `π¨ *Variant 1*\nπ _"${originalPrompt}"_\n\n
|
| 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 (
|
| 838 |
-
msg2 = await ctx.replyWithPhoto({ source:
|
| 839 |
-
caption: `π¨ *Variant 2*\nπ _"${originalPrompt}"_\n\n
|
| 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 |
});
|