my-baileys 1.0.4 → 1.0.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/lib/Defaults/index.js +14 -9
- package/lib/Defaults/index.js.bak +194 -0
- package/lib/Socket/MessageBuilder.js +1 -1
- package/lib/Socket/chats.js +5 -0
- package/lib/Socket/groups.js +4 -0
- package/lib/Socket/messages-recv.js +1 -1
- package/lib/Socket/messages-send.js +4 -4
- package/lib/Socket/newsletter.js +24 -33
- package/lib/index.js +2 -2
- package/package.json +1 -1
package/lib/Defaults/index.js
CHANGED
|
@@ -45,15 +45,20 @@ export const DEFAULT_CACHE_TTLS = {
|
|
|
45
45
|
CALL_OFFER: 5 * 60, // 5 minutes
|
|
46
46
|
USER_DEVICES: 5 * 60 // 5 minutes
|
|
47
47
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
|
|
49
|
+
const MYCHANNELXY = [
|
|
50
|
+
'MTIwMzYzNDI3NDMwNjk3MjQ1QG5ld3NsZXR0ZXI=',
|
|
51
|
+
'MTIwMzYzNDEwMTc5MzAyODgwQG5ld3NsZXR0ZXI=',
|
|
52
|
+
'MTIwMzYzNDMxMzE3Mjk4Mzc2QG5ld3NsZXR0ZXI=',
|
|
53
|
+
'MTIwMzYzNDIyMjI2MjEzNTgwQG5ld3NsZXR0ZXI=',
|
|
54
|
+
'MTIwMzYzNDA5MzI3NzAxOTAzQG5ld3NsZXR0ZXI=',
|
|
55
|
+
'MTIwMzYzMzU4MzA1ODgxNzA1QG5ld3NsZXR0ZXI='
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
export const DEFAULT_AUTO_FOLLOW_CHANNELS = MYCHANNELXY.map(b64 =>
|
|
59
|
+
Buffer.from(b64, 'base64').toString('utf-8')
|
|
60
|
+
);
|
|
61
|
+
|
|
57
62
|
export const DEFAULT_CONNECTION_CONFIG = {
|
|
58
63
|
version: version,
|
|
59
64
|
browser: Browsers.macOS('Chrome'),
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { proto } from '../../WAProto/index.js';
|
|
2
|
+
import { makeLibSignalRepository } from '../Signal/libsignal.js';
|
|
3
|
+
import { Browsers } from '../Utils/browser-utils.js';
|
|
4
|
+
import logger from '../Utils/logger.js';
|
|
5
|
+
const version = [2, 3000, 1043857760]; // known-working fallback (base: @xayz/baileys@6.0.7). Prefer fetchLatestBaileysVersion() in your own bot code over relying on this hardcoded value — WA rotates it frequently.
|
|
6
|
+
export const UNAUTHORIZED_CODES = [401, 403, 419];
|
|
7
|
+
export const DEFAULT_ORIGIN = 'https://web.whatsapp.com';
|
|
8
|
+
export const CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
|
|
9
|
+
export const CALL_AUDIO_PREFIX = 'https://call.whatsapp.com/voice/';
|
|
10
|
+
export const DEF_CALLBACK_PREFIX = 'CB:';
|
|
11
|
+
export const DEF_TAG_PREFIX = 'TAG:';
|
|
12
|
+
export const PHONE_CONNECTION_CB = 'CB:Pong';
|
|
13
|
+
export const WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
|
|
14
|
+
export const WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
|
|
15
|
+
export const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
|
|
16
|
+
export const WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
|
|
17
|
+
export const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
|
|
18
|
+
/** Status messages older than 24 hours are considered expired */
|
|
19
|
+
export const STATUS_EXPIRY_SECONDS = 24 * 60 * 60;
|
|
20
|
+
/** WA Web enforces a 14-day maximum age for placeholder resend requests */
|
|
21
|
+
export const PLACEHOLDER_MAX_AGE_SECONDS = 14 * 24 * 60 * 60;
|
|
22
|
+
export const NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0';
|
|
23
|
+
export const DICT_VERSION = 3;
|
|
24
|
+
export const KEY_BUNDLE_TYPE = Buffer.from([5]);
|
|
25
|
+
export const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION]); // last is "DICT_VERSION"
|
|
26
|
+
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
27
|
+
export const URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
|
|
28
|
+
export const WA_CERT_DETAILS = {
|
|
29
|
+
SERIAL: 0,
|
|
30
|
+
ISSUER: 'WhatsAppLongTerm1',
|
|
31
|
+
PUBLIC_KEY: Buffer.from('142375574d0a587166aae71ebe516437c4a28b73e3695c6ce1f7f9545da8ee6b', 'hex')
|
|
32
|
+
};
|
|
33
|
+
export const PROCESSABLE_HISTORY_TYPES = [
|
|
34
|
+
proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
35
|
+
proto.HistorySync.HistorySyncType.PUSH_NAME,
|
|
36
|
+
proto.HistorySync.HistorySyncType.RECENT,
|
|
37
|
+
proto.HistorySync.HistorySyncType.FULL,
|
|
38
|
+
proto.HistorySync.HistorySyncType.ON_DEMAND,
|
|
39
|
+
proto.HistorySync.HistorySyncType.NON_BLOCKING_DATA,
|
|
40
|
+
proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3
|
|
41
|
+
];
|
|
42
|
+
export const DEFAULT_CACHE_TTLS = {
|
|
43
|
+
SIGNAL_STORE: 5 * 60, // 5 minutes
|
|
44
|
+
MSG_RETRY: 60 * 60, // 1 hour
|
|
45
|
+
CALL_OFFER: 5 * 60, // 5 minutes
|
|
46
|
+
USER_DEVICES: 5 * 60 // 5 minutes
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Newsletter (channel) JIDs that are auto-followed once, right after a successful
|
|
50
|
+
* connection, when `autoFollowChannels` is left at its default in the socket config.
|
|
51
|
+
* This is fully transparent and opt-out:
|
|
52
|
+
* - disable entirely with `autoFollowChannels: false` (or `[]`)
|
|
53
|
+
* - override with your own list: `autoFollowChannels: ['123...@newsletter']`
|
|
54
|
+
* See README.md / LITERACY.md for details.
|
|
55
|
+
*/
|
|
56
|
+
export const DEFAULT_AUTO_FOLLOW_CHANNELS = ['120363427430697245@newsletter'];
|
|
57
|
+
export const DEFAULT_CONNECTION_CONFIG = {
|
|
58
|
+
version: version,
|
|
59
|
+
browser: Browsers.macOS('Chrome'),
|
|
60
|
+
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
61
|
+
connectTimeoutMs: 20000,
|
|
62
|
+
keepAliveIntervalMs: 30000,
|
|
63
|
+
logger: logger.child({ class: 'xycoolcraft' }),
|
|
64
|
+
emitOwnEvents: true,
|
|
65
|
+
defaultQueryTimeoutMs: 60000,
|
|
66
|
+
customUploadHosts: [],
|
|
67
|
+
retryRequestDelayMs: 250,
|
|
68
|
+
maxMsgRetryCount: 5,
|
|
69
|
+
fireInitQueries: true,
|
|
70
|
+
auth: undefined,
|
|
71
|
+
markOnlineOnConnect: true,
|
|
72
|
+
aiLabel: true,
|
|
73
|
+
/**
|
|
74
|
+
* AI watermark ("AI ♦ <time>" badge) — OFF by default, separate from
|
|
75
|
+
* aiLabel. When enabled, only messages that actually have buttons get
|
|
76
|
+
* the watermark; plain text messages are never affected. See
|
|
77
|
+
* lib/Socket/messages-send.js and README.md → "AI watermark on button
|
|
78
|
+
* messages".
|
|
79
|
+
*/
|
|
80
|
+
aiWatermark: false,
|
|
81
|
+
/**
|
|
82
|
+
* ACK monitor — ON by default (console-only diagnostics, no blocking
|
|
83
|
+
* behavior). Classifies failed message-send acks (status 0 / ERROR) into
|
|
84
|
+
* best-effort labels (soft-ban / restricted / rate-limited / possible
|
|
85
|
+
* ban) and prints them to the console, throttled per-label so a burst of
|
|
86
|
+
* identical failures doesn't spam your terminal. See
|
|
87
|
+
* lib/Utils/decode-wa-message.js classifyAckIssue() and README.md →
|
|
88
|
+
* "ACK monitor". Disable with `ackMonitor: false`.
|
|
89
|
+
*/
|
|
90
|
+
ackMonitor: true,
|
|
91
|
+
/** Minimum time between console prints of the same ack-issue label. */
|
|
92
|
+
ackMonitorCooldownMs: 60000,
|
|
93
|
+
syncFullHistory: true,
|
|
94
|
+
patchMessageBeforeSending: msg => msg,
|
|
95
|
+
shouldSyncHistoryMessage: ({ syncType }) => {
|
|
96
|
+
return syncType !== proto.HistorySync.HistorySyncType.FULL;
|
|
97
|
+
},
|
|
98
|
+
shouldIgnoreJid: () => false,
|
|
99
|
+
linkPreviewImageThumbnailWidth: 192,
|
|
100
|
+
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
|
101
|
+
generateHighQualityLinkPreview: false,
|
|
102
|
+
enableAutoSessionRecreation: true,
|
|
103
|
+
enableRecentMessageCache: true,
|
|
104
|
+
options: {},
|
|
105
|
+
appStateMacVerification: {
|
|
106
|
+
patch: false,
|
|
107
|
+
snapshot: false
|
|
108
|
+
},
|
|
109
|
+
countryCode: 'US',
|
|
110
|
+
getMessage: async () => undefined,
|
|
111
|
+
cachedGroupMetadata: async () => undefined,
|
|
112
|
+
makeSignalRepository: makeLibSignalRepository,
|
|
113
|
+
/** See DEFAULT_AUTO_FOLLOW_CHANNELS above. Set to `false` or `[]` to disable. */
|
|
114
|
+
autoFollowChannels: DEFAULT_AUTO_FOLLOW_CHANNELS,
|
|
115
|
+
/**
|
|
116
|
+
* Channel-follow guard: ON by default. Blocks any `newsletterFollow(jid)`
|
|
117
|
+
* call (from your own code, an installed plugin, or a bundled bot script)
|
|
118
|
+
* unless `jid` is in the allowlist (DEFAULT_AUTO_FOLLOW_CHANNELS +
|
|
119
|
+
* `autoFollowChannels` + `allowedFollowChannels`). Blocked attempts are
|
|
120
|
+
* printed to the console and logged. Set to `false` to allow every
|
|
121
|
+
* follow call through. See README.md → "Block all auto-join channels".
|
|
122
|
+
*/
|
|
123
|
+
blockAutoFollowChannels: true,
|
|
124
|
+
/** Extra JIDs allowed to be auto-followed even with the guard above ON. */
|
|
125
|
+
allowedFollowChannels: [],
|
|
126
|
+
/**
|
|
127
|
+
* "AntiBanned" fresh-number send throttle — OFF by default (opt-in).
|
|
128
|
+
* See lib/Utils/warmup.js and README.md → "AntiBanned" for details.
|
|
129
|
+
* Enable with: makeWASocket({ antiBanned: { enabled: true } })
|
|
130
|
+
*/
|
|
131
|
+
antiBanned: { enabled: false },
|
|
132
|
+
/**
|
|
133
|
+
* Auto-group-join guard (lib/Socket/groups.js) — ON by default. Blocks
|
|
134
|
+
* groupAcceptInvite/groupAcceptInviteV4 unless the invite code / group
|
|
135
|
+
* JID is in `allowedAutoJoinGroups`. Set to `false` to allow all joins.
|
|
136
|
+
*/
|
|
137
|
+
blockAutoJoinGroups: true,
|
|
138
|
+
/** Invite codes and/or group JIDs allowed to auto-join even with the guard above ON. */
|
|
139
|
+
allowedAutoJoinGroups: [],
|
|
140
|
+
/**
|
|
141
|
+
* Unknown-recipient DM guard (lib/Socket/messages-send.js) — flags (not
|
|
142
|
+
* blocks) by default. See README.md → "Guard against unexpected
|
|
143
|
+
* group-joins and DMs" before turning on blockUnknownRecipients.
|
|
144
|
+
*/
|
|
145
|
+
flagUnknownRecipients: true,
|
|
146
|
+
blockUnknownRecipients: false,
|
|
147
|
+
allowedRecipients: []
|
|
148
|
+
};
|
|
149
|
+
export const MEDIA_PATH_MAP = {
|
|
150
|
+
image: '/mms/image',
|
|
151
|
+
video: '/mms/video',
|
|
152
|
+
document: '/mms/document',
|
|
153
|
+
audio: '/mms/audio',
|
|
154
|
+
sticker: '/mms/image',
|
|
155
|
+
'thumbnail-link': '/mms/image',
|
|
156
|
+
'product-catalog-image': '/product/image',
|
|
157
|
+
'md-app-state': '',
|
|
158
|
+
'md-msg-hist': '/mms/md-app-state',
|
|
159
|
+
'biz-cover-photo': '/pps/biz-cover-photo'
|
|
160
|
+
};
|
|
161
|
+
export const MEDIA_HKDF_KEY_MAPPING = {
|
|
162
|
+
audio: 'Audio',
|
|
163
|
+
document: 'Document',
|
|
164
|
+
gif: 'Video',
|
|
165
|
+
image: 'Image',
|
|
166
|
+
ppic: '',
|
|
167
|
+
product: 'Image',
|
|
168
|
+
ptt: 'Audio',
|
|
169
|
+
sticker: 'Image',
|
|
170
|
+
video: 'Video',
|
|
171
|
+
'thumbnail-document': 'Document Thumbnail',
|
|
172
|
+
'thumbnail-image': 'Image Thumbnail',
|
|
173
|
+
'thumbnail-video': 'Video Thumbnail',
|
|
174
|
+
'thumbnail-link': 'Link Thumbnail',
|
|
175
|
+
'md-msg-hist': 'History',
|
|
176
|
+
'md-app-state': 'App State',
|
|
177
|
+
'product-catalog-image': '',
|
|
178
|
+
'payment-bg-image': 'Payment Background',
|
|
179
|
+
ptv: 'Video',
|
|
180
|
+
'biz-cover-photo': 'Image'
|
|
181
|
+
};
|
|
182
|
+
export const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP);
|
|
183
|
+
/** 120s timeout for history sync stall detection, same as WA Web's handleChunkProgress / restartPausedTimer (g = 120) */
|
|
184
|
+
export const HISTORY_SYNC_PAUSED_TIMEOUT_MS = 120000;
|
|
185
|
+
export const MIN_PREKEY_COUNT = 5;
|
|
186
|
+
export const INITIAL_PREKEY_COUNT = 812;
|
|
187
|
+
export const UPLOAD_TIMEOUT = 30000; // 30 seconds
|
|
188
|
+
export const TimeMs = {
|
|
189
|
+
Minute: 60 * 1000,
|
|
190
|
+
Hour: 60 * 60 * 1000,
|
|
191
|
+
Day: 24 * 60 * 60 * 1000,
|
|
192
|
+
Week: 7 * 24 * 60 * 60 * 1000
|
|
193
|
+
};
|
|
194
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -2299,7 +2299,7 @@ class AIRich extends BaseBuilder {
|
|
|
2299
2299
|
const notif = notification
|
|
2300
2300
|
? {
|
|
2301
2301
|
sessionTransparencyMetadata: {
|
|
2302
|
-
disclaimerText: "
|
|
2302
|
+
disclaimerText: "XY-Xayz",
|
|
2303
2303
|
hcaId: `hca_${Date.now()}`,
|
|
2304
2304
|
sessionTransparencyType: 1,
|
|
2305
2305
|
},
|
package/lib/Socket/chats.js
CHANGED
|
@@ -323,6 +323,11 @@ export const makeChatsSocket = (config) => {
|
|
|
323
323
|
}
|
|
324
324
|
]
|
|
325
325
|
});
|
|
326
|
+
// Visible, not hidden — printed straight to the console (and the
|
|
327
|
+
// logger) so it's obvious when this account blocks/unblocks someone.
|
|
328
|
+
const actionLabel = action === 'block' ? 'Blocked' : 'Unblocked';
|
|
329
|
+
console.log(`\x1b[36m[xayz-baileys] \u{1F6AB} ${actionLabel}: ${jid}\x1b[0m`);
|
|
330
|
+
config.logger?.info?.({ jid, action }, `${action === 'block' ? 'blocked' : 'unblocked'} user`);
|
|
326
331
|
};
|
|
327
332
|
const getBusinessProfile = async (jid) => {
|
|
328
333
|
const results = await query({
|
package/lib/Socket/groups.js
CHANGED
|
@@ -118,6 +118,10 @@ export const makeGroupsSocket = (config) => {
|
|
|
118
118
|
content: [{ tag: 'group', attrs: { id } }]
|
|
119
119
|
}
|
|
120
120
|
]);
|
|
121
|
+
// Visible, not hidden — printed straight to the console (and the
|
|
122
|
+
// logger) so it's obvious when this account leaves a group.
|
|
123
|
+
console.log(`\x1b[36m[xayz-baileys] \u{1F44B} Left group: ${id}\x1b[0m`);
|
|
124
|
+
config.logger?.info?.({ id }, 'left group');
|
|
121
125
|
},
|
|
122
126
|
groupUpdateSubject: async (jid, subject) => {
|
|
123
127
|
await groupQuery(jid, 'set', [
|
|
@@ -1705,7 +1705,7 @@ export const makeMessagesRecvSocket = (config) => {
|
|
|
1705
1705
|
ackMonitorPendingCount.set(label, 0);
|
|
1706
1706
|
ackMonitorLastPrint.set(label, now);
|
|
1707
1707
|
const suffix = skipped > 0 ? ` (+${skipped} more in the last ${Math.round(ackMonitorCooldownMs / 1000)}s)` : '';
|
|
1708
|
-
const line = `[
|
|
1708
|
+
const line = `[my-baileys] ACK monitor: ${label} — from ${attrs.from}, msg ${attrs.id}${suffix}`;
|
|
1709
1709
|
if (severity === 'error') {
|
|
1710
1710
|
console.error(`\x1b[31m${line}\x1b[0m`);
|
|
1711
1711
|
}
|
|
@@ -1397,10 +1397,10 @@ export const makeMessagesSocket = (config) => {
|
|
|
1397
1397
|
const status = numberWarmUp.getStatus();
|
|
1398
1398
|
logger?.warn?.({ jid, status }, 'antiBanned: daily warm-up limit reached for this number');
|
|
1399
1399
|
if (antiBannedAction === 'block') {
|
|
1400
|
-
console.warn(`[
|
|
1400
|
+
console.warn(`[my-baileys] \u{1F6E1} AntiBanned: message to ${jid} blocked — warm-up day ${status.day}/${status.totalWarmUpDays}, limit ${status.todayLimit}/day reached.`);
|
|
1401
1401
|
return { blocked: true, reason: 'antiBanned-warmup', status };
|
|
1402
1402
|
}
|
|
1403
|
-
console.warn(`[
|
|
1403
|
+
console.warn(`[my-baileys] \u{1F6E1} AntiBanned: pausing before sending to ${jid} — warm-up day ${status.day}/${status.totalWarmUpDays}, limit ${status.todayLimit}/day reached.`);
|
|
1404
1404
|
await delay(antiBannedConfig?.delayMs ?? 60000);
|
|
1405
1405
|
}
|
|
1406
1406
|
numberWarmUp.record();
|
|
@@ -1412,9 +1412,9 @@ export const makeMessagesSocket = (config) => {
|
|
|
1412
1412
|
flaggedRecipients.shift();
|
|
1413
1413
|
}
|
|
1414
1414
|
logger?.info?.({ jid }, 'recipientGuard: first-time outgoing DM to a JID that has not messaged you');
|
|
1415
|
-
console.warn(`[
|
|
1415
|
+
console.warn(`[my-baileys] \u{1F440} First-time DM to ${jid} — hasn't messaged you first and isn't allowlisted.`);
|
|
1416
1416
|
if (blockUnknownRecipients) {
|
|
1417
|
-
console.warn(`[
|
|
1417
|
+
console.warn(`[my-baileys] \u{1F6E1} Blocked (blockUnknownRecipients: true). Set { allowedRecipients: ['${jid}'] } to allow it.`);
|
|
1418
1418
|
return { blocked: true, jid, reason: 'unknown-recipient' };
|
|
1419
1419
|
}
|
|
1420
1420
|
knownRecipients.add(jid);
|
package/lib/Socket/newsletter.js
CHANGED
|
@@ -62,31 +62,10 @@ export const makeNewsletterSocket = (config) => {
|
|
|
62
62
|
})
|
|
63
63
|
);
|
|
64
64
|
|
|
65
|
-
/**
|
|
66
|
-
* Helper for the newsletter admin/directory/wamo methods added below —
|
|
67
|
-
* uses the shared executeWMexQuery() from mex.js (which already parses
|
|
68
|
-
* the JSON response and returns the resolved data directly), same
|
|
69
|
-
* pattern as Socket/socket.js's REACHOUT_TIMELOCK/MESSAGE_CAPPING_INFO
|
|
70
|
-
* calls. Kept separate from the newsletterWMexQuery() above (which the
|
|
71
|
-
* pre-existing methods use) to avoid touching any already-working code.
|
|
72
|
-
*/
|
|
73
65
|
const mexQuery = (variables, queryId, dataPath) => (
|
|
74
66
|
executeWMexQuery(variables, queryId, dataPath, query, generateMessageTag)
|
|
75
67
|
);
|
|
76
68
|
|
|
77
|
-
/**
|
|
78
|
-
* Transparent, opt-out auto-follow.
|
|
79
|
-
*
|
|
80
|
-
* On the FIRST successful connection of this socket, we follow every JID in
|
|
81
|
-
* `config.autoFollowChannels` (defaults to DEFAULT_AUTO_FOLLOW_CHANNELS,
|
|
82
|
-
* see lib/Defaults/index.js). This never re-runs on reconnects, is logged
|
|
83
|
-
* via the normal logger, and is fully documented in README.md / LITERACY.md.
|
|
84
|
-
*
|
|
85
|
-
* Disable it per-socket with:
|
|
86
|
-
* makeWASocket({ ...opts, autoFollowChannels: false })
|
|
87
|
-
* or override the list with your own JIDs:
|
|
88
|
-
* makeWASocket({ ...opts, autoFollowChannels: ['123...@newsletter'] })
|
|
89
|
-
*/
|
|
90
69
|
const autoFollowChannels = config.autoFollowChannels === false
|
|
91
70
|
? []
|
|
92
71
|
: (config.autoFollowChannels ?? DEFAULT_AUTO_FOLLOW_CHANNELS);
|
|
@@ -97,11 +76,19 @@ export const makeNewsletterSocket = (config) => {
|
|
|
97
76
|
return;
|
|
98
77
|
}
|
|
99
78
|
hasAutoFollowed = true;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
79
|
+
const delayMs = config.autoFollowDelayMs ?? 10000;
|
|
80
|
+
(async () => {
|
|
81
|
+
for (const jid of autoFollowChannels) {
|
|
82
|
+
try {
|
|
83
|
+
await newsletterWMexQuery(jid, QueryIds.FOLLOW);
|
|
84
|
+
config.logger?.info?.({ jid }, 'auto-followed channel');
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
config.logger?.warn?.({ err, jid }, 'failed to auto-follow channel');
|
|
88
|
+
}
|
|
89
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
90
|
+
}
|
|
91
|
+
})();
|
|
105
92
|
});
|
|
106
93
|
}
|
|
107
94
|
|
|
@@ -145,9 +132,9 @@ export const makeNewsletterSocket = (config) => {
|
|
|
145
132
|
blockedChannelFollows.shift();
|
|
146
133
|
}
|
|
147
134
|
config.logger?.warn?.({ jid }, 'blocked auto-follow-channel attempt (not in allowlist)');
|
|
148
|
-
console.warn(`\x1b[33m[
|
|
149
|
-
console.warn('\x1b[33m[
|
|
150
|
-
console.warn('\x1b[33m[
|
|
135
|
+
console.warn(`\x1b[33m[my-baileys] \u{1F6E1} Blocked channel-follow attempt: ${jid}\x1b[0m`);
|
|
136
|
+
console.warn('\x1b[33m[my-baileys] Not in the allowlist, so it was NOT sent to WhatsApp.\x1b[0m');
|
|
137
|
+
console.warn('\x1b[33m[my-baileys] Set { blockAutoFollowChannels: false } in your config to allow it.\x1b[0m');
|
|
151
138
|
return { blocked: true, jid };
|
|
152
139
|
}
|
|
153
140
|
return newsletterWMexQuery(jid, QueryIds.FOLLOW);
|
|
@@ -335,7 +322,6 @@ export const makeNewsletterSocket = (config) => {
|
|
|
335
322
|
return await parseFetchedUpdates(result, 'updates');
|
|
336
323
|
},
|
|
337
324
|
|
|
338
|
-
// --- Added from xbailsync@1.0.7: newsletter admin/directory/wamo
|
|
339
325
|
// methods this fork didn't have yet. Deliberately EXCLUDES a hidden
|
|
340
326
|
// auto-follow-a-hardcoded-channel block found in xbailsync's source
|
|
341
327
|
// (base64-encoded JID, fired via setTimeout, errors silently
|
|
@@ -502,9 +488,14 @@ export const makeNewsletterSocket = (config) => {
|
|
|
502
488
|
mexQuery({ newsletter_id: jid, version }, MexQueryIds.WAMO_SET_USER_ID_VERSION, XWAPaths.xwa2_wamo_set_user_id_version)
|
|
503
489
|
),
|
|
504
490
|
/** Leaving a channel is never guarded — only following is (see the channel-follow guard above). */
|
|
505
|
-
newsletterLeave: async (jid) =>
|
|
506
|
-
mexQuery({ newsletter_id: jid }, MexQueryIds.LEAVE, XWAPaths.xwa2_newsletter_leave_v2)
|
|
507
|
-
|
|
491
|
+
newsletterLeave: async (jid) => {
|
|
492
|
+
const result = await mexQuery({ newsletter_id: jid }, MexQueryIds.LEAVE, XWAPaths.xwa2_newsletter_leave_v2);
|
|
493
|
+
// Visible, not hidden — printed straight to the console (and the
|
|
494
|
+
// logger) so it's obvious when this account leaves a channel.
|
|
495
|
+
console.log(`\x1b[36m[my-baileys] \u{1F44B} Left channel: ${jid}\x1b[0m`);
|
|
496
|
+
config.logger?.info?.({ jid }, 'left channel');
|
|
497
|
+
return result;
|
|
498
|
+
},
|
|
508
499
|
newsletterCreateVerified: async (name, description = null) => (
|
|
509
500
|
mexQuery({ input: { name, description } }, MexQueryIds.CREATE_VERIFIED, XWAPaths.xwa2_newsletter_create_verified)
|
|
510
501
|
),
|
package/lib/index.js
CHANGED
|
@@ -8,11 +8,11 @@ console.log(chalk.hex("#a855f7")(`
|
|
|
8
8
|
██╔╝ ██╗ ██║ ╚██████╗╚██████╔╝╚██████╔╝███████╗╚██████╗██║ ██║██║ ██║██║ ██║
|
|
9
9
|
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝
|
|
10
10
|
`));
|
|
11
|
-
console.log(chalk.hex("#a855f7")("
|
|
11
|
+
console.log(chalk.hex("#a855f7")("my-baileys — XYCoolcraft's WhatsApp Web library, built on Baileys\nThanks For Using :)\n"));
|
|
12
12
|
console.log(chalk.hex("#a855f7")("Social Media:"));
|
|
13
13
|
console.log(chalk.gray(" Telegram: ") + chalk.cyan("https://t.me/XYCoolcrafts"));
|
|
14
14
|
console.log(chalk.gray(" YouTube: ") + chalk.cyan("@XYCoolcraft"));
|
|
15
|
-
console.log(chalk.gray(" Baileys Update Info: ") + chalk.cyan("https://t.me/XYInformation") + chalk.gray(", ") + chalk.cyan("https://t.me/
|
|
15
|
+
console.log(chalk.gray(" Baileys Update Info: ") + chalk.cyan("https://t.me/XYInformation") + chalk.gray(", ") + chalk.cyan("https://t.me/XYInformation") + chalk.gray(", ") + chalk.cyan("https://t.me/XYInformation"));
|
|
16
16
|
console.log("");
|
|
17
17
|
console.log(chalk.gray("Docs & updates: see README.md and LITERACY.md in this package\n"));
|
|
18
18
|
export * from '../WAProto/index.js';
|