updates commands

This commit is contained in:
2026-04-20 00:14:48 +03:00
parent 10cca7135a
commit c801b1800c
3 changed files with 12 additions and 12 deletions

View File

@@ -6,6 +6,8 @@
// @author Dimitrios
// @match https://*.grepolis.com/game/*
// @grant unsafeWindow
// @updateURL https://git.haunter-pets.top/haunter/grepo-remote/raw/branch/main/GrepolisRemoteControl.user.js
// @downloadURL https://git.haunter-pets.top/haunter/grepo-remote/raw/branch/main/GrepolisRemoteControl.user.js
// ==/UserScript==
(function () {
@@ -128,11 +130,11 @@
// ----------------------------------------------------------------
// Report command result back to relay
// ----------------------------------------------------------------
function reportResult(cmdId, success, message) {
function reportResult(cmdId, status, message) {
fetch(`${BASE_URL}/api/commands/${cmdId}/result`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ status: success ? 'done' : 'failed', message })
body: JSON.stringify({ status, message })
}).catch(e => log(`reportResult failed: ${e}`));
}
@@ -153,7 +155,7 @@
const hasCurator = uw.GameDataPremium?.isAdvisorActivated?.('curator');
const maxQueue = hasCurator ? 7 : 2;
if (queueLen >= maxQueue) {
return { ok: false, msg: `Build queue full (${queueLen}/${maxQueue})` };
return { ok: false, requeue: true, msg: `Build queue full (${queueLen}/${maxQueue})` };
}
// Check resources
@@ -248,8 +250,9 @@
result = { ok: false, msg: `Exception: ${e.message}` };
}
log(`Command #${cmd.id} result: ${result.ok ? '✅' : '❌'} ${result.msg}`);
reportResult(cmd.id, result.ok, result.msg);
const finalStatus = result.requeue ? 'pending' : (result.ok ? 'done' : 'failed');
log(`Command #${cmd.id} result: ${finalStatus === 'done' ? '✅' : (finalStatus === 'pending' ? '⏳' : '❌')} ${result.msg}`);
reportResult(cmd.id, finalStatus, result.msg);
}
// ----------------------------------------------------------------