@poucode/baileys 2.0.0 → 2.0.1

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/README.md CHANGED
@@ -36,7 +36,7 @@ npm install github:pou-code/Baileys
36
36
  Or add it to your `package.json` manually:
37
37
  ```json
38
38
  "dependencies": {
39
- "@poucode/baileys": "latest"
39
+ "@poucode/baileys": "github:pou-code/Baileys"
40
40
  }
41
41
  ```
42
42
 
@@ -45,7 +45,7 @@ Already have a bot built on the original `@whiskeysockets/baileys` and don't wan
45
45
  name points to this fork:
46
46
  ```json
47
47
  "dependencies": {
48
- "@whiskeysockets/baileys": "npm:poucode/baileys"
48
+ "@whiskeysockets/baileys": "github:pou-code/Baileys"
49
49
  }
50
50
  ```
51
51
  With this alias, keep using `require('@whiskeysockets/baileys')` in your code as-is — npm will
@@ -60,7 +60,7 @@ export const DEFAULT_CONNECTION_CONFIG = {
60
60
  fireInitQueries: true,
61
61
  auth: undefined,
62
62
  markOnlineOnConnect: true,
63
- aiLabel: true,
63
+ aiLabel: false,
64
64
  syncFullHistory: true,
65
65
  patchMessageBeforeSending: msg => msg,
66
66
  shouldSyncHistoryMessage: ({ syncType }) => {
@@ -428,6 +428,20 @@ export const makeMessagesSocket = (config) => {
428
428
  }
429
429
  return { nodes, shouldIncludeDeviceIdentity };
430
430
  };
431
+ /** Hapus penanda AI label dari konten pesan (chat 1:1 biasa, bukan bot). */
432
+ const stripAiLabelMarkers = (root) => {
433
+ const seen = new WeakSet()
434
+ const walk = (obj) => {
435
+ if (!obj || typeof obj !== 'object' || seen.has(obj)) return
436
+ seen.add(obj)
437
+ if (obj.messageContextInfo && typeof obj.messageContextInfo === 'object') {
438
+ delete obj.messageContextInfo.aiLabel
439
+ delete obj.messageContextInfo.botForwarded
440
+ }
441
+ for (const key of Object.keys(obj)) walk(obj[key])
442
+ }
443
+ walk(root)
444
+ }
431
445
  const relayMessage = async (
432
446
  jid,
433
447
  message,
@@ -446,6 +460,11 @@ export const makeMessagesSocket = (config) => {
446
460
  const meId = authState.creds.me.id
447
461
  const meLid = authState.creds.me?.lid
448
462
  const isRetryResend = Boolean(participant?.jid)
463
+ // Retry ke participant: selalu lewati sinkron ke perangkat sendiri (adaptasi XzBailss FIX 1)
464
+ if (isRetryResend) noSelfSync = true
465
+ // Bersihkan penanda AI label hanya untuk chat personal biasa (adaptasi XzBailss FIX 3)
466
+ const isPlainChat = !isJidGroup(jid) && jid !== 'status@broadcast' && jidDecode(jid)?.server !== 'newsletter' && !isJidBot(jid) && !isJidMetaAI(jid)
467
+ if (isPlainChat) stripAiLabelMarkers(message)
449
468
  let shouldIncludeDeviceIdentity = isRetryResend
450
469
  const statusJid = 'status@broadcast'
451
470
  const { user, server } = jidDecode(jid)
@@ -476,6 +495,13 @@ export const makeMessagesSocket = (config) => {
476
495
  const pollMessage =
477
496
  messages.pollCreationMessage || messages.pollCreationMessageV2 || messages.pollCreationMessageV3
478
497
  await authState.keys.transaction(async () => {
498
+ if (isRetryResend && participant?.jid) {
499
+ try {
500
+ await assertSessions([participant.jid], true)
501
+ } catch (e) {
502
+ logger.warn({ participant, e }, 'Failed to assert session for participant, continuing anyway')
503
+ }
504
+ }
479
505
  const mediaType = getMediaType(message)
480
506
  if (mediaType) extraAttrs.mediatype = mediaType
481
507
  if (isNewsletter) {
@@ -831,13 +857,7 @@ export const makeMessagesSocket = (config) => {
831
857
  stanza.content.push(buttonsNode)
832
858
  }
833
859
  }
834
- if (!aiLabel && isPnUser(destinationJid)) {
835
- const alreadyHasBizBot = getBinaryFilteredBizBot(additionalNodes || []) || getBinaryFilteredBizBot(stanza.content)
836
- if (!alreadyHasBizBot) stanza.content.push({ tag: 'bot', attrs: { biz_bot: '1' } })
837
- } else if (aiLabel &&!isGroup &&!isStatus &&!isNewsletter) {
838
- const existingBizBot = getBinaryFilteredBizBot(additionalNodes || [])
839
- if (!existingBizBot) stanza.content.push({ tag: 'bot', attrs: { biz_bot: '1' } })
840
- }
860
+ // Catatan: node <bot biz_bot> tidak lagi disuntikkan ke chat 1:1 biasa (penyebab pesan private gagal terkirim)
841
861
  const isPeerMessage = additionalAttributes?.['category'] === 'peer'
842
862
  const is1on1Send =!isGroup &&!isRetryResend &&!isStatus &&!isNewsletter &&!isPeerMessage
843
863
  const tcTokenJid = is1on1Send? await resolveTcTokenJid(destinationJid, getLIDForPN) : destinationJid
@@ -876,11 +896,14 @@ export const makeMessagesSocket = (config) => {
876
896
  } catch (err) {
877
897
  logger.debug({ jid: destinationJid, err: err?.message }, 'cstoken attach failed')
878
898
  }
879
- }
899
+ }
880
900
  if (additionalNodes && additionalNodes.length > 0 &&!didPushAdditional) {
881
901
  stanza.content.push(...additionalNodes)
882
902
  }
883
903
  logger.debug({ msgId }, `sending message to ${participants.length} devices`)
904
+ if (isPlainChat && Array.isArray(stanza.content)) {
905
+ stanza.content = stanza.content.filter(node => node?.tag !== 'bot')
906
+ }
884
907
  await sendNode(stanza)
885
908
  if (message.messageContextInfo?.messageSecret) {
886
909
  setBotMessageSecret(msgId, message.messageContextInfo.messageSecret, destinationJid)
@@ -3,8 +3,8 @@ export * from './USyncContactProtocol.js'
3
3
  export * from './USyncStatusProtocol.js'
4
4
  export * from './USyncDisappearingModeProtocol.js'
5
5
  export * from './USyncUsernameProtocol.js'
6
- export * from './USyncBotProfileProtocol.js'
7
- export * from './USyncLIDProtocol.js'
6
+ export * from './BotProfileProtocol.js'
7
+ export * from './LIDProtocol.js'
8
8
  export * from './USyncBusinessProtocol.js'
9
9
  export * from './USyncPictureProtocol.js'
10
10
  export * from './USyncTextStatusProtocol.js'
@@ -1,6 +1,6 @@
1
1
  import { getBinaryNodeChild } from '../WABinary/index.js'
2
- import { USyncBotProfileProtocol } from './Protocols/USyncBotProfileProtocol.js'
3
- import { USyncLIDProtocol } from './Protocols/USyncLIDProtocol.js'
2
+ import { USyncBotProfileProtocol } from './Protocols/BotProfileProtocol.js'
3
+ import { USyncLIDProtocol } from './Protocols/LIDProtocol.js'
4
4
  import { USyncBusinessProtocol } from './Protocols/USyncBusinessProtocol.js'
5
5
  import { USyncPictureProtocol } from './Protocols/USyncPictureProtocol.js'
6
6
  import { USyncTextStatusProtocol } from './Protocols/USyncTextStatusProtocol.js'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@poucode/baileys",
3
3
  "type": "module",
4
- "version": "2.0.0",
4
+ "version": "2.0.1",
5
5
  "description": "WaBail — PouCode fork of Baileys: WhatsApp Web WebSocket library with merged extra socket layers (privacy, interop, GraphQL, message builder), sticker packs and SQLite auth state",
6
6
  "keywords": [
7
7
  "poucode",