beast-agent 0.23.4 → 0.23.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/renderer/renderer.js +48 -10
package/package.json
CHANGED
package/src/renderer/renderer.js
CHANGED
|
@@ -1962,11 +1962,11 @@ async function renderWaAllow() {
|
|
|
1962
1962
|
const list = await beast.waGetAllow();
|
|
1963
1963
|
let botChoices = [];
|
|
1964
1964
|
try { botChoices = (await beast.botsList()) || []; } catch {}
|
|
1965
|
-
const multiBot = botChoices.length >= 2;
|
|
1966
1965
|
const botSelHtml = (cur) =>
|
|
1967
1966
|
`<select class="perm-select" title="${_t('bot_bind_title')}">` +
|
|
1967
|
+
`<option value="">${_t('bot_sel_empty')}</option>` +
|
|
1968
1968
|
botChoices
|
|
1969
|
-
.map((bb) => `<option value="${bb.id}" ${
|
|
1969
|
+
.map((bb) => `<option value="${bb.id}" ${cur === bb.id ? 'selected' : ''}>${bb.icon} ${escapeHtml(bb.name)}</option>`)
|
|
1970
1970
|
.join('') +
|
|
1971
1971
|
`</select>`;
|
|
1972
1972
|
wrap.innerHTML = '';
|
|
@@ -1980,7 +1980,8 @@ async function renderWaAllow() {
|
|
|
1980
1980
|
const name = String((e && e.name) || '').trim();
|
|
1981
1981
|
const ownerTag = e && e.owner ? ' 👑' : '';
|
|
1982
1982
|
const bot = botChoices.find((bb) => bb.id === (e && e.bot_id));
|
|
1983
|
-
|
|
1983
|
+
/* bağlı olduğu bot her koşulda etikette görünsün */
|
|
1984
|
+
const botTag = bot && e && e.bot_id ? ' → ' + bot.name : '';
|
|
1984
1985
|
return (name ? name + ' ' : '') + (num ? '+' + num : '') + ownerTag + botTag;
|
|
1985
1986
|
};
|
|
1986
1987
|
const waNeedsName = (e) => e !== '*' && String((e && e.name) || '').trim() === '';
|
|
@@ -2076,8 +2077,8 @@ async function renderWaAllow() {
|
|
|
2076
2077
|
});
|
|
2077
2078
|
c.appendChild(selP);
|
|
2078
2079
|
|
|
2079
|
-
/* BOT SİSTEMİ:
|
|
2080
|
-
if (
|
|
2080
|
+
/* BOT SİSTEMİ: bağlı olduğu bot chip'te seçili gelir — buradan değiştirilebilir */
|
|
2081
|
+
if (botChoices.length) {
|
|
2081
2082
|
const selB = document.createElement('span');
|
|
2082
2083
|
selB.innerHTML = botSelHtml(typeof entry === 'object' ? entry.bot_id : undefined);
|
|
2083
2084
|
const sel = selB.firstChild;
|
|
@@ -2246,13 +2247,14 @@ async function renderTgAllow() {
|
|
|
2246
2247
|
const list = await beast.tgGetAllow();
|
|
2247
2248
|
let botChoices = [];
|
|
2248
2249
|
try { botChoices = (await beast.botsList()) || []; } catch {}
|
|
2249
|
-
const multiBot = botChoices.length >= 2;
|
|
2250
2250
|
const tgLabel = (e) => {
|
|
2251
2251
|
if (e === '*') return '* herkes';
|
|
2252
2252
|
if (typeof e === 'string') return e;
|
|
2253
2253
|
const name = String((e && e.name) || '').trim();
|
|
2254
2254
|
const id = String((e && e.id) || '');
|
|
2255
|
-
|
|
2255
|
+
/* bağlı olduğu bot her koşulda etikette görünsün */
|
|
2256
|
+
const bot = e && e.bot_id ? botChoices.find((bb) => bb.id === e.bot_id) : null;
|
|
2257
|
+
return (name ? name + ' ' : '') + id + (bot ? ' → ' + bot.name : '');
|
|
2256
2258
|
};
|
|
2257
2259
|
wrap.innerHTML = '';
|
|
2258
2260
|
if (!list.length) wrap.innerHTML = '<span class="sub">— boş —</span>';
|
|
@@ -2298,11 +2300,15 @@ async function renderTgAllow() {
|
|
|
2298
2300
|
});
|
|
2299
2301
|
c.appendChild(selP);
|
|
2300
2302
|
|
|
2301
|
-
/* BOT SİSTEMİ:
|
|
2302
|
-
if (
|
|
2303
|
+
/* BOT SİSTEMİ: bağlı olduğu bot chip'te seçili gelir — buradan değiştirilebilir */
|
|
2304
|
+
if (botChoices.length) {
|
|
2303
2305
|
const sel = document.createElement('select');
|
|
2304
2306
|
sel.className = 'perm-select';
|
|
2305
2307
|
sel.title = _t('bot_bind_title');
|
|
2308
|
+
const empty = document.createElement('option');
|
|
2309
|
+
empty.value = '';
|
|
2310
|
+
empty.textContent = _t('bot_sel_empty');
|
|
2311
|
+
sel.appendChild(empty);
|
|
2306
2312
|
for (const bb of botChoices) {
|
|
2307
2313
|
const o = document.createElement('option');
|
|
2308
2314
|
o.value = bb.id;
|
|
@@ -2325,6 +2331,32 @@ async function renderTgAllow() {
|
|
|
2325
2331
|
});
|
|
2326
2332
|
c.appendChild(sel);
|
|
2327
2333
|
}
|
|
2334
|
+
|
|
2335
|
+
/* SAHİP rolü — yalnız biri olabilir (WA ile aynı): tıkla → sahiplik devret */
|
|
2336
|
+
const isOwnerEntry = typeof entry === 'object' && !!entry.owner;
|
|
2337
|
+
const ownerBtn = document.createElement('span');
|
|
2338
|
+
ownerBtn.className = 'lk';
|
|
2339
|
+
ownerBtn.style.cssText = 'font-size:11px;padding:1px 6px;' + (isOwnerEntry ? 'color:#c9a227;font-weight:800' : '');
|
|
2340
|
+
ownerBtn.title = isOwnerEntry ? _t('wa_owner_title_on') : _t('wa_owner_title_off');
|
|
2341
|
+
ownerBtn.textContent = isOwnerEntry ? _t('wa_owner_on') : _t('wa_owner_off');
|
|
2342
|
+
ownerBtn.addEventListener('click', async () => {
|
|
2343
|
+
if (isOwnerEntry) return; // sahibi tekrar tıklamayla alma; önce başkasına devret
|
|
2344
|
+
const cur = await beast.tgGetAllow();
|
|
2345
|
+
const next = cur.map((e, i) => {
|
|
2346
|
+
if (typeof e === 'object' && e && e.owner) return { ...e, owner: false };
|
|
2347
|
+
if (i === idx) {
|
|
2348
|
+
const obj = typeof e === 'string' ? { id: e, name: '' } : { ...e };
|
|
2349
|
+
obj.owner = true;
|
|
2350
|
+
return obj;
|
|
2351
|
+
}
|
|
2352
|
+
return e;
|
|
2353
|
+
});
|
|
2354
|
+
const tgt = next[idx];
|
|
2355
|
+
await beast.tgSetAllow(next);
|
|
2356
|
+
renderTgAllow();
|
|
2357
|
+
toast('Sahip: ' + tgLabel(tgt));
|
|
2358
|
+
});
|
|
2359
|
+
c.appendChild(ownerBtn);
|
|
2328
2360
|
}
|
|
2329
2361
|
const x = document.createElement('span');
|
|
2330
2362
|
x.className = 'x';
|
|
@@ -2364,7 +2396,13 @@ async function renderTgAllow() {
|
|
|
2364
2396
|
v = v.startsWith('@') ? '@' + v.slice(1).replace(/[^\w]/g, '') : v.replace(/[^\d]/g, '');
|
|
2365
2397
|
if (!v) { toast(_t('it_tg_id_ph')); return; }
|
|
2366
2398
|
const botId = botSel && botSel.value ? { bot_id: botSel.value } : {};
|
|
2367
|
-
|
|
2399
|
+
const next = [...(await beast.tgGetAllow()), { id: v, name, ...botId }];
|
|
2400
|
+
/* İLK EKLENEN KİŞİ OTOMATİK SAHİP — listede sahip yoksa en eski kayıt atanır
|
|
2401
|
+
(sahiplik sonradan chip'teki 'sahip yap' butonundan devredilebilir) */
|
|
2402
|
+
if (!next.some((e) => e && typeof e === 'object' && e.owner)) {
|
|
2403
|
+
if (next.length && typeof next[0] === 'object') next[0].owner = true;
|
|
2404
|
+
}
|
|
2405
|
+
await beast.tgSetAllow(next);
|
|
2368
2406
|
inp.value = '';
|
|
2369
2407
|
nameInp.value = '';
|
|
2370
2408
|
renderTgAllow();
|