beast-agent 0.26.4 → 0.26.5
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/agent/whatsapp.js +36 -6
- package/src/renderer/i18n.js +6 -4
- package/src/renderer/renderer.js +12 -2
package/package.json
CHANGED
package/src/agent/whatsapp.js
CHANGED
|
@@ -337,8 +337,20 @@ class WhatsAppBridge {
|
|
|
337
337
|
async _processIncoming(msg) {
|
|
338
338
|
try {
|
|
339
339
|
const jid = msg.key && msg.key.remoteJid;
|
|
340
|
-
if (!jid
|
|
340
|
+
if (!jid) return;
|
|
341
341
|
if (jid === 'status@broadcast' || jid.endsWith('@newsletter')) return;
|
|
342
|
+
/* botun kendi kimliği: telefon base'i + LID base'i (LID dönemi) */
|
|
343
|
+
const meBase = String(this._userIdRaw || '').split('@')[0].split(':')[0];
|
|
344
|
+
const lidBase = String((this.sock && this.sock.user && this.sock.user.lid) || '').split('@')[0].split(':')[0];
|
|
345
|
+
/* KENDİ KENDİNE SOHBET (Saved Messages): kullanıcı kendi numarasını izinliye
|
|
346
|
+
ekleyip kendi sohbetinden bota yazabilsin. Bu sohbetteki HER mesaj fromMe
|
|
347
|
+
gelir; botun KENDİ gönderdiği mesajlar (_tracked) filtrelenir → döngü yok.
|
|
348
|
+
Diğer sohbetlerdeki elle yazılan fromMe mesajları bot etkilenmesin diye yutulur. */
|
|
349
|
+
const selfChat = !!(meBase && (jid === meBase + '@s.whatsapp.net' || (lidBase && jid === lidBase + '@lid')));
|
|
350
|
+
if (msg.key.fromMe) {
|
|
351
|
+
if (this._tracked.has(String(msg.key.id))) return; // botun kendi cevabı — echo
|
|
352
|
+
if (!selfChat) return;
|
|
353
|
+
}
|
|
342
354
|
const isGroup = jid.endsWith('@g.us');
|
|
343
355
|
const participantJid = isGroup && msg.key.participant ? String(msg.key.participant) : '';
|
|
344
356
|
const mm = msg.message || {};
|
|
@@ -351,20 +363,35 @@ class WhatsAppBridge {
|
|
|
351
363
|
const t = String(text || '').trim();
|
|
352
364
|
|
|
353
365
|
// gruplarda bot'un kendisi @mention edilmiş mi
|
|
366
|
+
/* LİD DÖNEMİ UYARISI: mentionedJid artık çoğu zaman botun @lid numarasıyla
|
|
367
|
+
gelir (telefon JID'i DEĞİL) — bu yüzden yalnız meBase ile karşılaştırma
|
|
368
|
+
mention'ı ıskalıyordu. Şimdi: botun telefon base'i + LID base'i ikisiyle
|
|
369
|
+
de eşitlik aranır; contextInfo görsel/video/belge caption'larından da alınır. */
|
|
354
370
|
let mentioned = false;
|
|
355
371
|
if (isGroup) {
|
|
356
|
-
const ci =
|
|
372
|
+
const ci =
|
|
373
|
+
(mm.extendedTextMessage && mm.extendedTextMessage.contextInfo) ||
|
|
374
|
+
(mm.imageMessage && mm.imageMessage.contextInfo) ||
|
|
375
|
+
(mm.videoMessage && mm.videoMessage.contextInfo) ||
|
|
376
|
+
(mm.documentMessage && mm.documentMessage.contextInfo) ||
|
|
377
|
+
null;
|
|
357
378
|
const men = (ci && ci.mentionedJid) || [];
|
|
358
|
-
const
|
|
379
|
+
const baseOf = (j) => String(j || '').split('?')[0].split(':')[0].split('@')[0];
|
|
359
380
|
for (const m of men) {
|
|
360
|
-
|
|
381
|
+
const base = baseOf(m);
|
|
382
|
+
if (base && ((meBase && base === meBase) || (lidBase && base === lidBase))) {
|
|
361
383
|
mentioned = true;
|
|
362
384
|
break;
|
|
363
385
|
}
|
|
364
386
|
}
|
|
365
|
-
if (!mentioned && ci && ci.participant
|
|
366
|
-
|
|
387
|
+
if (!mentioned && ci && ci.participant) {
|
|
388
|
+
const pBase = baseOf(ci.participant);
|
|
389
|
+
if ((meBase && pBase === meBase) || (lidBase && pBase === lidBase)) {
|
|
390
|
+
mentioned = true; // mesajımıza reply verilmiş
|
|
391
|
+
}
|
|
367
392
|
}
|
|
393
|
+
/* metin yedeği: @<bot numarası> elle yazılmışsa da mention sayılır */
|
|
394
|
+
if (!mentioned && meBase && t.includes('@' + meBase)) mentioned = true;
|
|
368
395
|
}
|
|
369
396
|
|
|
370
397
|
// medya çıkarımı (varsa)
|
|
@@ -406,6 +433,9 @@ class WhatsAppBridge {
|
|
|
406
433
|
senderNum = (participantJid || jid).split('@')[0].split(':')[0];
|
|
407
434
|
if (!/^\d+$/.test(senderNum)) senderNum = '';
|
|
408
435
|
}
|
|
436
|
+
/* kendi kendine sohbette gönderen = botun telefon numarası — izin listesi
|
|
437
|
+
telefon numarasıyla eşleşsin (LID self-chat'te jid @lid olur) */
|
|
438
|
+
if (selfChat && meBase) senderNum = meBase;
|
|
409
439
|
this.onIncoming(jid, {
|
|
410
440
|
text: t,
|
|
411
441
|
media,
|
package/src/renderer/i18n.js
CHANGED
|
@@ -195,8 +195,9 @@
|
|
|
195
195
|
it_connect: 'QR ile Bağlan',
|
|
196
196
|
it_disconnect: 'Kes',
|
|
197
197
|
it_reset_pair: 'Eşlemeyi Sıfırla',
|
|
198
|
-
it_groups_on: 'WhatsApp gruplarında çalış
|
|
199
|
-
|
|
198
|
+
it_groups_on: 'WhatsApp gruplarında çalış',
|
|
199
|
+
it_groups_mention: 'Sadece @mention edilince cevap ver (grupta botu etiketle)',
|
|
200
|
+
it_groups_all: 'Grubun her mesajına karış',
|
|
200
201
|
it_allow_label: 'İzinli numaralar',
|
|
201
202
|
it_name_ph: 'İsim (zorunlu)',
|
|
202
203
|
it_num_ph: 'Numara 905xxxxxxxxx',
|
|
@@ -723,8 +724,9 @@
|
|
|
723
724
|
it_connect: 'Connect via QR',
|
|
724
725
|
it_disconnect: 'Disconnect',
|
|
725
726
|
it_reset_pair: 'Reset pairing',
|
|
726
|
-
it_groups_on: 'Work in WhatsApp groups
|
|
727
|
-
|
|
727
|
+
it_groups_on: 'Work in WhatsApp groups',
|
|
728
|
+
it_groups_mention: 'Reply only when @mentioned (tag the bot in the group)',
|
|
729
|
+
it_groups_all: 'Respond to every group message',
|
|
728
730
|
it_allow_label: 'Allowed numbers',
|
|
729
731
|
it_name_ph: 'Name (required)',
|
|
730
732
|
it_num_ph: 'Number 905xxxxxxxxx',
|
package/src/renderer/renderer.js
CHANGED
|
@@ -1498,7 +1498,8 @@ async function renderIntegrationsPane() {
|
|
|
1498
1498
|
</div>
|
|
1499
1499
|
<div style="height:14px"></div>
|
|
1500
1500
|
<label class="lock-row"><input type="checkbox" id="waGroupsOn" ${g.enabled ? 'checked' : ''}/><span>${_t('it_groups_on')}</span></label>
|
|
1501
|
-
<label class="lock-row" style="${g.enabled ? '' : 'opacity:.45'}"><input type="
|
|
1501
|
+
<label class="lock-row" style="${g.enabled ? '' : 'opacity:.45'}"><input type="radio" name="waGroupMode" id="waGroupsMention" ${g.mentionOnly !== false ? 'checked' : ''}/><span>${_t('it_groups_mention')}</span></label>
|
|
1502
|
+
<label class="lock-row" style="${g.enabled ? '' : 'opacity:.45'}"><input type="radio" name="waGroupMode" id="waGroupsAll" ${g.mentionOnly === false ? 'checked' : ''}/><span>${_t('it_groups_all')}</span></label>
|
|
1502
1503
|
<div class="divider"></div>
|
|
1503
1504
|
<label class="mem-label" style="margin-top:0">${_t('it_allow_label')}</label>
|
|
1504
1505
|
<div id="waAllowChips" class="chips-inline"></div>
|
|
@@ -1571,16 +1572,25 @@ async function renderIntegrationsPane() {
|
|
|
1571
1572
|
</div>`;
|
|
1572
1573
|
|
|
1573
1574
|
const waGroupsOn = $('#waGroupsOn');
|
|
1575
|
+
const waGroupsMention = $('#waGroupsMention');
|
|
1574
1576
|
const waGroupsAll = $('#waGroupsAll');
|
|
1577
|
+
/* iki mod BİRBİRİNE HARIÇTİR: ya @mention ya her mesaja karışma (radio) */
|
|
1578
|
+
const syncGroupMode = () => {
|
|
1579
|
+
const op = waGroupsOn.checked ? '' : '.45';
|
|
1580
|
+
if (waGroupsMention) waGroupsMention.parentElement.style.opacity = op;
|
|
1581
|
+
if (waGroupsAll) waGroupsAll.parentElement.style.opacity = op;
|
|
1582
|
+
};
|
|
1575
1583
|
const saveGroups = async () => {
|
|
1576
1584
|
const r = await beast.waSetGroups({ enabled: waGroupsOn.checked, mentionOnly: !waGroupsAll.checked });
|
|
1577
1585
|
toast(r.enabled ? (r.mentionOnly ? 'Gruplar açık — @mention bekler' : 'Gruplar açık — tüm mesajlara karışır') : 'Gruplar kapalı');
|
|
1578
1586
|
};
|
|
1579
1587
|
waGroupsOn.addEventListener('change', async () => {
|
|
1580
|
-
|
|
1588
|
+
syncGroupMode();
|
|
1581
1589
|
await saveGroups();
|
|
1582
1590
|
});
|
|
1591
|
+
waGroupsMention.addEventListener('change', saveGroups);
|
|
1583
1592
|
waGroupsAll.addEventListener('change', saveGroups);
|
|
1593
|
+
syncGroupMode();
|
|
1584
1594
|
|
|
1585
1595
|
$('#waStartBtn').addEventListener('click', async () => {
|
|
1586
1596
|
toast('Bağlanıyor…');
|