Suvarii commited on
Commit
a8a342a
·
verified ·
1 Parent(s): 601746e

Update bot.js

Browse files
Files changed (1) hide show
  1. bot.js +293 -12
bot.js CHANGED
@@ -74,6 +74,14 @@ const CIFTCI_FILTER_MAX_RETRIES = 10; // güvenlik limiti
74
  const STORAGE_SCAN_INTERVAL_MS = 15 * 60 * 1000; // 15 dakika
75
  const STORAGE_TRACKED_ITEMS = ["diamond", "emerald", "iron_block"]; // internal name eşleşmesi
76
 
 
 
 
 
 
 
 
 
77
  let storageInfoCache = {
78
  diamond: null,
79
  emerald: null,
@@ -83,7 +91,7 @@ let storageInfoCache = {
83
  let storageScanIntervalHandle = null;
84
 
85
  // Çiftçi penceresinin şu an hangi amaçla açık olduğunu tutan bayrak.
86
- // "sell" -> hepsini-sat akışı, "scan" -> storage bilgisi tarama akışı.
87
  let ciftciWindowPurpose = "sell";
88
 
89
  // --- KAZICI FAILOVER (YEDEK HESAP) AYARLARI ---
@@ -138,6 +146,9 @@ let lastCiftciSellTimeStr = "Henüz çiftçi satışı yapılmadı";
138
  let nextCiftciTimeStr = "Botun spawn olması bekleniyor...";
139
  let nextCiftciAtMs = null;
140
 
 
 
 
141
  // --- ÇİFTÇİ/KAZICI PERİYODİK DÖNGÜ KONTROLÜ ---
142
  let lastCheckAtMs = null; // Besleyici için (panel bilgisi amaçlı, artık kazıcı/çiftçiyi etkilemiyor)
143
  let nextScheduledCheckAtMs = null; // Besleyici için
@@ -207,7 +218,8 @@ let botActions = {
207
  sendSkyblockManual: null,
208
  antiBotMove: null,
209
  sendMoneyToNick: null,
210
- scanStorageInfoManual: null
 
211
  };
212
 
213
  function formatDurationMs(ms) {
@@ -1867,6 +1879,15 @@ function activateEntityAtNoLook(entity, position) {
1867
  };
1868
  }
1869
 
 
 
 
 
 
 
 
 
 
1870
  async function navigateCiftciFilterToGenerator() {
1871
  if (!bot || !bot.currentWindow) return false;
1872
 
@@ -2008,6 +2029,236 @@ function activateEntityAtNoLook(entity, position) {
2008
  }
2009
  };
2010
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2011
  function startStorageScanPeriodic() {
2012
  if (storageScanIntervalHandle) return;
2013
  storageScanIntervalHandle = setInterval(() => {
@@ -2101,6 +2352,7 @@ function activateEntityAtNoLook(entity, position) {
2101
  botActions.antiBotMove = antiBotMove;
2102
  botActions.sendMoneyToNick = sendMoneyToNick;
2103
  botActions.scanStorageInfoManual = scanStorageInfoManual;
 
2104
 
2105
  startKaziciPeriodic();
2106
  startCiftciPeriodic();
@@ -2170,13 +2422,20 @@ function activateEntityAtNoLook(entity, position) {
2170
  const isCiftciWindow = !isBesleyiciWindow && !isKaziciWindow &&
2171
  (matchesAnyName(titleRaw, TARGET_CIFTCI_NORMS) || windowMatchesLoreKeyword(window, CIFTCI_LORE_FALLBACK_KEYWORDS));
2172
 
 
 
 
 
2173
  if (!isBesleyiciWindow && !isKaziciWindow && !isCiftciWindow) {
2174
- logger.info(`[${currentBotUsername}] Bi chest açıldı ama window title ı uyuşmadığı için kapatıldı. ${titleRaw}`);
2175
- try { bot.closeWindow(window); } catch(e){}
2176
- return;
2177
- }
2178
-
2179
- if (isKaziciWindow) {
 
 
 
2180
  try {
2181
  logger.info(`[${currentBotUsername}] Kazıcı minyon paneli açıldı. Depo aktarım slotuna (oyun içi 18. slot / mineflayer idx ${KAZICI_STORAGE_TRANSFER_SLOT}) tıklanıyor...`);
2182
  await bot.clickWindow(KAZICI_STORAGE_TRANSFER_SLOT, 0, 0);
@@ -2189,9 +2448,9 @@ function activateEntityAtNoLook(entity, position) {
2189
  try { bot.closeWindow(window); } catch(e){}
2190
 
2191
  } else if (isCiftciWindow) {
2192
- if (ciftciWindowPurpose === "scan") {
2193
- // Storage tarama modu: burada otomatik tıklama/kapatma yapma,
2194
- // scanStorageInfoCore kendi akışını yönetiyor. Sadece resolver'ı tetikle.
2195
  } else {
2196
  try {
2197
  logger.info(`[${currentBotUsername}] Çiftçi (Hepsini Sat) menüsü açıldı. ${formatDurationMs(CIFTCI_CLICK_DELAY_AFTER_OPEN_MS)} bekleniyor, sonra slot ${CIFTCI_SELL_ALL_SLOT}'e ${CIFTCI_CLICK_REPEAT_COUNT} kez tıklanacak...`);
@@ -2298,6 +2557,7 @@ function activateEntityAtNoLook(entity, position) {
2298
  botActions.antiBotMove = null;
2299
  botActions.sendMoneyToNick = null;
2300
  botActions.scanStorageInfoManual = null;
 
2301
 
2302
  safeDestroyAllConnections();
2303
 
@@ -2566,6 +2826,7 @@ app.get("/status", (req, res) => {
2566
  next_kazici_check: nextKaziciTimeStr,
2567
  last_ciftci_sell: lastCiftciSellTimeStr,
2568
  next_ciftci_sell: nextCiftciTimeStr,
 
2569
  gui_lock_busy: guiMutex.isLocked(),
2570
  manually_stopped: manualStopRequested,
2571
  is_connecting: isConnecting,
@@ -2707,6 +2968,26 @@ app.get("/bot/sendmoney", (req, res) => {
2707
  });
2708
  });
2709
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2710
  app.get("/", (req, res) => res.send("Bot Aktif"));
2711
 
2712
  app.get("/messages", (req, res) => {
@@ -2942,4 +3223,4 @@ process.stderr.write = function (chunk, encoding, callback) {
2942
  return true;
2943
  }
2944
  return originalStderrWrite.apply(process.stderr, arguments);
2945
- };
 
74
  const STORAGE_SCAN_INTERVAL_MS = 15 * 60 * 1000; // 15 dakika
75
  const STORAGE_TRACKED_ITEMS = ["diamond", "emerald", "iron_block"]; // internal name eşleşmesi
76
 
77
+ // --- SİPARİŞ (ORDER) SİSTEMİ AYARLARI ---
78
+ const ORDER_COMMAND_PREFIX = "/order";
79
+ const ORDER_WINDOW_TIMEOUT_MS = 8000;
80
+ const ORDER_WINDOW_SETTLE_DELAY_MS = 500;
81
+ const ORDER_AFTER_SELECT_DELAY_MS = 500;
82
+ const ORDER_IS_GO_SECOND_DELAY_MS = 5000;
83
+ const ORDER_ALLOWED_ITEMS = ["diamond", "emerald"];
84
+
85
  let storageInfoCache = {
86
  diamond: null,
87
  emerald: null,
 
91
  let storageScanIntervalHandle = null;
92
 
93
  // Çiftçi penceresinin şu an hangi amaçla açık olduğunu tutan bayrak.
94
+ // "sell" -> hepsini-sat akışı, "scan" -> storage bilgisi tarama akışı, "order" -> sipariş akışı.
95
  let ciftciWindowPurpose = "sell";
96
 
97
  // --- KAZICI FAILOVER (YEDEK HESAP) AYARLARI ---
 
146
  let nextCiftciTimeStr = "Botun spawn olması bekleniyor...";
147
  let nextCiftciAtMs = null;
148
 
149
+ // --- SİPARİŞ (ORDER) PANEL METRİKLERİ ---
150
+ let lastOrderTimeStr = "Henüz sipariş işlemi yapılmadı";
151
+
152
  // --- ÇİFTÇİ/KAZICI PERİYODİK DÖNGÜ KONTROLÜ ---
153
  let lastCheckAtMs = null; // Besleyici için (panel bilgisi amaçlı, artık kazıcı/çiftçiyi etkilemiyor)
154
  let nextScheduledCheckAtMs = null; // Besleyici için
 
218
  sendSkyblockManual: null,
219
  antiBotMove: null,
220
  sendMoneyToNick: null,
221
+ scanStorageInfoManual: null,
222
+ processOrderManual: null
223
  };
224
 
225
  function formatDurationMs(ms) {
 
1879
  };
1880
  }
1881
 
1882
+ function findSlotByInternalName(window, internalName) {
1883
+ if (!window || !Array.isArray(window.slots)) return -1;
1884
+ for (let i = 0; i < window.slots.length; i++) {
1885
+ const s = window.slots[i];
1886
+ if (s && s.name === internalName) return i;
1887
+ }
1888
+ return -1;
1889
+ }
1890
+
1891
  async function navigateCiftciFilterToGenerator() {
1892
  if (!bot || !bot.currentWindow) return false;
1893
 
 
2029
  }
2030
  };
2031
 
2032
+ // =====================================================================
2033
+ // SİPARİŞ (ORDER) SİSTEMİ
2034
+ // Akış:
2035
+ // 1) Çiftçi menüsü -> Jeneratör materyalleri filtresine geç (varsa zaten oradadır)
2036
+ // 2) İstenen item'ın (diamond/emerald) slotuna shift+sağ tık -> envanter dolana kadar item verir
2037
+ // 3) Menüyü kapat
2038
+ // 4) antiBotMove -> /is go -> 5sn bekle -> /is go
2039
+ // 5) /order <nick> gönder
2040
+ // 6) windowOpen bekle, +500ms sonra güncel pencereyi oku
2041
+ // 7) Lore'da nick geçen slotu bul -> sol tık ile seç
2042
+ // 8) +500ms sonra pencere boşsa envanterdeki item'ları shift+sol tık ile order'a aktar
2043
+ // 9) Pencereyi kapat
2044
+ // =====================================================================
2045
+
2046
+ async function waitForNextWindowOpen(timeoutMs) {
2047
+ return new Promise((resolve) => {
2048
+ let timeoutHandle = null;
2049
+ const cleanFinish = (opened) => {
2050
+ clearTimeout(timeoutHandle);
2051
+ windowOpenResolvers = [];
2052
+ resolve(opened);
2053
+ };
2054
+
2055
+ windowOpenResolvers.push(() => cleanFinish(true));
2056
+
2057
+ timeoutHandle = setTimeout(() => {
2058
+ cleanFinish(false);
2059
+ }, timeoutMs);
2060
+ });
2061
+ }
2062
+
2063
+ function findSlotContainingNick(window, nickNorm) {
2064
+ if (!window || !Array.isArray(window.slots)) return -1;
2065
+ for (let i = 0; i < window.slots.length; i++) {
2066
+ const slot = window.slots[i];
2067
+ if (!slot) continue;
2068
+ const texts = getItemDisplayTexts(slot);
2069
+ for (const t of texts) {
2070
+ if (matchesAnyName(t, [nickNorm])) return i;
2071
+ }
2072
+ }
2073
+ return -1;
2074
+ }
2075
+
2076
+ async function processOrderCore(itemInternalName, nick) {
2077
+ if (!bot || !botIsReady) return { success: false, message: "Bot hazır değil." };
2078
+ if (!guiMutex.isLocked()) {
2079
+ logger.error("[GÜVENLİK İHLALİ] processOrderCore kilitsiz çağrıldı! İşlem iptal ediliyor.");
2080
+ return { success: false, message: "Kilitsiz çağrı engellendi." };
2081
+ }
2082
+ if (!ORDER_ALLOWED_ITEMS.includes(itemInternalName)) {
2083
+ return { success: false, message: `Geçersiz item: ${itemInternalName}. İzin verilenler: ${ORDER_ALLOWED_ITEMS.join(", ")}` };
2084
+ }
2085
+ if (!nick || typeof nick !== "string" || nick.trim().length === 0) {
2086
+ return { success: false, message: "nick parametresi zorunlu." };
2087
+ }
2088
+
2089
+ // --- 1) Çiftçi menüsünü aç, jeneratör materyalleri filtresine geç ---
2090
+ ciftciWindowPurpose = "order";
2091
+ logger.info(`[Sipariş] Çiftçi menüsü açılıyor (${CIFTCI_COMMAND})...`);
2092
+
2093
+ if (bot.currentWindow != null) {
2094
+ try { bot.closeWindow(bot.currentWindow); } catch (e) {}
2095
+ await new Promise(r => setTimeout(r, 300));
2096
+ }
2097
+
2098
+ let windowOpened = false;
2099
+ await new Promise((resolve) => {
2100
+ let timeoutHandle = null;
2101
+ const cleanFinish = () => { clearTimeout(timeoutHandle); windowOpenResolvers = []; resolve(); };
2102
+ windowOpenResolvers.push(() => { windowOpened = true; cleanFinish(); });
2103
+ timeoutHandle = setTimeout(() => {
2104
+ logger.warn("[Sipariş] Çiftçi menüsü açılamadı (zaman aşımı).");
2105
+ cleanFinish();
2106
+ }, CIFTCI_WINDOW_TIMEOUT_MS);
2107
+ try { bot.chat(CIFTCI_COMMAND); } catch (e) {}
2108
+ });
2109
+
2110
+ if (!windowOpened || !bot.currentWindow) {
2111
+ ciftciWindowPurpose = "sell";
2112
+ return { success: false, message: "Çiftçi menüsü açılamadı." };
2113
+ }
2114
+
2115
+ const reached = await navigateCiftciFilterToGenerator();
2116
+ if (!reached || !bot.currentWindow) {
2117
+ try { if (bot.currentWindow) bot.closeWindow(bot.currentWindow); } catch (e) {}
2118
+ ciftciWindowPurpose = "sell";
2119
+ return { success: false, message: "Jeneratör materyalleri filtresine ulaşılamadı." };
2120
+ }
2121
+
2122
+ // --- 2) İstenen item'ın slotuna shift+sağ tık (envanter dolana kadar verir) ---
2123
+ const itemSlotIndex = findSlotByInternalName(bot.currentWindow, itemInternalName);
2124
+ if (itemSlotIndex === -1) {
2125
+ try { bot.closeWindow(bot.currentWindow); } catch (e) {}
2126
+ ciftciWindowPurpose = "sell";
2127
+ return { success: false, message: `'${itemInternalName}' slotu jeneratör materyalleri filtresinde bulunamadı.` };
2128
+ }
2129
+
2130
+ try {
2131
+ logger.info(`[Sipariş] '${itemInternalName}' slotuna (idx:${itemSlotIndex}) shift+sağ tık gönderiliyor...`);
2132
+ await bot.clickWindow(itemSlotIndex, 1, 1); // mouseButton=1 (sağ), mode=1 (shift)
2133
+ await new Promise(r => setTimeout(r, KAZICI_ACTION_SETTLE_DELAY_MS));
2134
+ } catch (e) {
2135
+ logger.error(`[Sipariş] Shift+sağ tık hatası: ${e && e.message ? e.message : e}`);
2136
+ }
2137
+
2138
+ // --- 3) Menüyü kapat ---
2139
+ try { if (bot.currentWindow) bot.closeWindow(bot.currentWindow); } catch (e) {}
2140
+ ciftciWindowPurpose = "sell";
2141
+ await new Promise(r => setTimeout(r, 300));
2142
+
2143
+ // --- 4) antiBotMove -> /is go -> 5sn -> /is go ---
2144
+ try { await antiBotMove(); } catch (e) {}
2145
+ try { bot.chat(GO_ISLAND_COMMAND); } catch (e) {}
2146
+ await new Promise(r => setTimeout(r, ORDER_IS_GO_SECOND_DELAY_MS));
2147
+ try { bot.chat(GO_ISLAND_COMMAND); } catch (e) {}
2148
+ await new Promise(r => setTimeout(r, HOME_ARRIVAL_DELAY_MS));
2149
+
2150
+ // --- 5) /order <nick> gönder ---
2151
+ logger.info(`[Sipariş] ${ORDER_COMMAND_PREFIX} ${nick} komutu gönderiliyor...`);
2152
+
2153
+ let orderWindowOpened = false;
2154
+ await new Promise((resolve) => {
2155
+ let timeoutHandle = null;
2156
+ const cleanFinish = () => { clearTimeout(timeoutHandle); windowOpenResolvers = []; resolve(); };
2157
+ windowOpenResolvers.push(() => { orderWindowOpened = true; cleanFinish(); });
2158
+ timeoutHandle = setTimeout(() => {
2159
+ logger.warn("[Sipariş] /order penceresi açılamadı (zaman aşımı).");
2160
+ cleanFinish();
2161
+ }, ORDER_WINDOW_TIMEOUT_MS);
2162
+ try { bot.chat(`${ORDER_COMMAND_PREFIX} ${nick}`); } catch (e) {}
2163
+ });
2164
+
2165
+ if (!orderWindowOpened || !bot.currentWindow) {
2166
+ return { success: false, message: "/order penceresi açılmadı." };
2167
+ }
2168
+
2169
+ // --- 6) +500ms bekle, güncel pencereyi oku (windowOpen anındaki değil) ---
2170
+ await new Promise(r => setTimeout(r, ORDER_WINDOW_SETTLE_DELAY_MS));
2171
+ if (!bot.currentWindow) {
2172
+ return { success: false, message: "Pencere beklenmedik şekilde kapandı." };
2173
+ }
2174
+
2175
+ // --- 7) Lore'da nick geçen slotu bul, sol tık ile seç ---
2176
+ const nickVariants = normalizeVariants(nick);
2177
+ let targetSlotIndex = -1;
2178
+ for (const nv of nickVariants) {
2179
+ targetSlotIndex = findSlotContainingNick(bot.currentWindow, nv);
2180
+ if (targetSlotIndex !== -1) break;
2181
+ }
2182
+
2183
+ if (targetSlotIndex === -1) {
2184
+ logger.warn(`[Sipariş] '${nick}' içeren item bulunamadı, pencere kapatılıyor.`);
2185
+ try { bot.closeWindow(bot.currentWindow); } catch (e) {}
2186
+ return { success: false, message: `'${nick}' için sipariş item'ı bulunamadı.` };
2187
+ }
2188
+
2189
+ logger.info(`[Sipariş] '${nick}' içeren item bulundu (idx:${targetSlotIndex}), sol tık gönderiliyor...`);
2190
+ try {
2191
+ await bot.clickWindow(targetSlotIndex, 0, 0);
2192
+ } catch (e) {
2193
+ logger.error(`[Sipariş] Slot seçim tıklaması hatası: ${e && e.message ? e.message : e}`);
2194
+ }
2195
+
2196
+ // --- 8) +500ms sonra pencere tekrar okunur; boşsa envanterdeki item'ları order'a aktar ---
2197
+ await new Promise(r => setTimeout(r, ORDER_AFTER_SELECT_DELAY_MS));
2198
+
2199
+ if (!bot.currentWindow) {
2200
+ logger.warn("[Sipariş] Slot seçiminden sonra pencere kapandı, işlem yarım kalmış olabilir.");
2201
+ return { success: false, message: "Slot seçiminden sonra pencere kapandı." };
2202
+ }
2203
+
2204
+ const isEmptyNow = bot.currentWindow.slots.every(s => !s || s.type === -1 || s.name == null);
2205
+
2206
+ let transferredCount = 0;
2207
+ if (isEmptyNow) {
2208
+ logger.info("[Sipariş] Order penceresi boş görünüyor, envanterdeki item'lar aktarılıyor...");
2209
+ // Envanterdeki ilgili item'ları shift+sol tık ile order penceresine aktar.
2210
+ let keepGoing = true;
2211
+ let safetyCounter = 0;
2212
+ while (keepGoing && safetyCounter < 40) {
2213
+ safetyCounter++;
2214
+ if (!bot.currentWindow) break;
2215
+
2216
+ const invItem = bot.inventory.items().find(it => it && it.name === itemInternalName);
2217
+ if (!invItem) { keepGoing = false; break; }
2218
+
2219
+ try {
2220
+ await bot.clickWindow(invItem.slot, 0, 1); // mouseButton=0 (sol), mode=1 (shift)
2221
+ transferredCount++;
2222
+ await new Promise(r => setTimeout(r, 250));
2223
+ } catch (e) {
2224
+ logger.error(`[Sipariş] Envanterden aktarım tıklaması hatası: ${e && e.message ? e.message : e}`);
2225
+ keepGoing = false;
2226
+ }
2227
+ }
2228
+ logger.info(`[Sipariş] Envanterden order'a aktarım turu tamamlandı (${transferredCount} yığın gönderildi).`);
2229
+ } else {
2230
+ logger.info("[Sipariş] Order penceresinde zaten item var, envanterden aktarım yapılmadı.");
2231
+ }
2232
+
2233
+ // --- 9) Pencereyi kapat ---
2234
+ try { if (bot.currentWindow) bot.closeWindow(bot.currentWindow); } catch (e) {}
2235
+
2236
+ return {
2237
+ success: true,
2238
+ message: "Sipariş işlemi tamamlandı.",
2239
+ item: itemInternalName,
2240
+ nick,
2241
+ inventory_transferred_batches: transferredCount,
2242
+ inventory_auto_filled: isEmptyNow
2243
+ };
2244
+ }
2245
+
2246
+ async function processOrderManual(itemInternalName, nick) {
2247
+ logger.info(`[Sipariş - Manuel] Panelden istek geldi (item:${itemInternalName}, nick:${nick}), sırasını bekliyor (öncelikli)...`);
2248
+ await guiMutex.acquire();
2249
+ try {
2250
+ logger.info("[Sipariş - Manuel] Kilit alındı, işlem başlıyor.");
2251
+ const result = await processOrderCore(itemInternalName, nick);
2252
+ lastOrderTimeStr = `${getExtendedDateTimeString()} (item:${itemInternalName}, nick:${nick}, sonuç:${result.success ? "başarılı" : "başarısız"})`;
2253
+ return result;
2254
+ } catch (err) {
2255
+ logger.error(`[processOrderManual Hatası] ${err && err.stack ? err.stack : err}`);
2256
+ return { success: false, message: "Beklenmeyen bir hata oluştu." };
2257
+ } finally {
2258
+ guiMutex.release();
2259
+ }
2260
+ }
2261
+
2262
  function startStorageScanPeriodic() {
2263
  if (storageScanIntervalHandle) return;
2264
  storageScanIntervalHandle = setInterval(() => {
 
2352
  botActions.antiBotMove = antiBotMove;
2353
  botActions.sendMoneyToNick = sendMoneyToNick;
2354
  botActions.scanStorageInfoManual = scanStorageInfoManual;
2355
+ botActions.processOrderManual = processOrderManual;
2356
 
2357
  startKaziciPeriodic();
2358
  startCiftciPeriodic();
 
2422
  const isCiftciWindow = !isBesleyiciWindow && !isKaziciWindow &&
2423
  (matchesAnyName(titleRaw, TARGET_CIFTCI_NORMS) || windowMatchesLoreKeyword(window, CIFTCI_LORE_FALLBACK_KEYWORDS));
2424
 
2425
+ // Sipariş (/order) penceresi çiftçi/kazıcı/besleyici isimleriyle eşleşmez,
2426
+ // bu yüzden ayrıca ele alınır: ciftciWindowPurpose "order" ise otomatik
2427
+ // tıklama/kapatma yapılmaz, sadece resolver tetiklenir ve processOrderCore
2428
+ // kendi akışını (500ms bekleme + güncel pencere okuma) yönetir.
2429
  if (!isBesleyiciWindow && !isKaziciWindow && !isCiftciWindow) {
2430
+ if (ciftciWindowPurpose === "order") {
2431
+ logger.info(`[${currentBotUsername}] Sipariş (/order) penceresi açıldı: ${titleRaw}`);
2432
+ // otomatik kapatma yapma, processOrderCore yönetecek
2433
+ } else {
2434
+ logger.info(`[${currentBotUsername}] Bi chest açıldı ama window title ı uyuşmadığı için kapatıldı. ${titleRaw}`);
2435
+ try { bot.closeWindow(window); } catch(e){}
2436
+ return;
2437
+ }
2438
+ } else if (isKaziciWindow) {
2439
  try {
2440
  logger.info(`[${currentBotUsername}] Kazıcı minyon paneli açıldı. Depo aktarım slotuna (oyun içi 18. slot / mineflayer idx ${KAZICI_STORAGE_TRANSFER_SLOT}) tıklanıyor...`);
2441
  await bot.clickWindow(KAZICI_STORAGE_TRANSFER_SLOT, 0, 0);
 
2448
  try { bot.closeWindow(window); } catch(e){}
2449
 
2450
  } else if (isCiftciWindow) {
2451
+ if (ciftciWindowPurpose === "scan" || ciftciWindowPurpose === "order") {
2452
+ // Storage tarama / sipariş modu: burada otomatik tıklama/kapatma yapma,
2453
+ // ilgili core fonksiyon kendi akışını yönetiyor. Sadece resolver'ı tetikle.
2454
  } else {
2455
  try {
2456
  logger.info(`[${currentBotUsername}] Çiftçi (Hepsini Sat) menüsü açıldı. ${formatDurationMs(CIFTCI_CLICK_DELAY_AFTER_OPEN_MS)} bekleniyor, sonra slot ${CIFTCI_SELL_ALL_SLOT}'e ${CIFTCI_CLICK_REPEAT_COUNT} kez tıklanacak...`);
 
2557
  botActions.antiBotMove = null;
2558
  botActions.sendMoneyToNick = null;
2559
  botActions.scanStorageInfoManual = null;
2560
+ botActions.processOrderManual = null;
2561
 
2562
  safeDestroyAllConnections();
2563
 
 
2826
  next_kazici_check: nextKaziciTimeStr,
2827
  last_ciftci_sell: lastCiftciSellTimeStr,
2828
  next_ciftci_sell: nextCiftciTimeStr,
2829
+ last_order: lastOrderTimeStr,
2830
  gui_lock_busy: guiMutex.isLocked(),
2831
  manually_stopped: manualStopRequested,
2832
  is_connecting: isConnecting,
 
2968
  });
2969
  });
2970
 
2971
+ app.get("/bot/order", (req, res) => {
2972
+ if (!bot || !botIsReady || !botActions.processOrderManual) {
2973
+ return res.status(503).send({ success: false, message: "Bot hazır değil." });
2974
+ }
2975
+
2976
+ const item = req.query.item;
2977
+ const nick = req.query.nick;
2978
+
2979
+ if (!item || typeof item !== "string" || !ORDER_ALLOWED_ITEMS.includes(item)) {
2980
+ return res.status(400).send({ success: false, message: `item query parametresi zorunlu ve şunlardan biri olmalı: ${ORDER_ALLOWED_ITEMS.join(", ")}` });
2981
+ }
2982
+ if (!nick || typeof nick !== "string" || nick.trim().length === 0) {
2983
+ return res.status(400).send({ success: false, message: "nick query parametresi zorunlu." });
2984
+ }
2985
+
2986
+ res.send({ success: true, message: "Sipariş işlemi öncelikli olarak kuyruğa alındı, işleniyor." });
2987
+ botActions.processOrderManual(item, nick)
2988
+ .catch(e => logger.error(`[/bot/order Hatası] ${e && e.stack ? e.stack : e}`));
2989
+ });
2990
+
2991
  app.get("/", (req, res) => res.send("Bot Aktif"));
2992
 
2993
  app.get("/messages", (req, res) => {
 
3223
  return true;
3224
  }
3225
  return originalStderrWrite.apply(process.stderr, arguments);
3226
+ };