devilkyuuna 1.0.13 → 1.0.14
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/engine-requirements.js +91 -10
- package/lib/Defaults/index.js +2 -3
- package/lib/Socket/chats.js +0 -19
- package/lib/Socket/messages-send.js +1 -1
- package/lib/Socket/newsletter.d.ts +134 -0
- package/lib/Socket/newsletter.js +59 -241
- package/lib/Socket/socket.js +1 -15
- package/lib/Utils/chat-utils.js +2 -11
- package/lib/Utils/generics.js +4 -9
- package/lib/Utils/validate-connection.js +0 -2
- package/lib/index.d.ts +12 -0
- package/lib/index.js +42 -39
- package/package.json +107 -110
- package/lib/Socket/chats.js.bak +0 -981
- package/lib/Utils/generics.js.bak +0 -433
- package/lib/Utils/validate-connection.js.bak +0 -237
package/engine-requirements.js
CHANGED
|
@@ -1,10 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
|
|
2
|
+
let chalkModule = import("chalk");
|
|
3
|
+
let gradientModule = import("gradient-string");
|
|
4
|
+
|
|
5
|
+
const chalk = chalkModule.default;
|
|
6
|
+
const gradient = gradientModule.default;
|
|
7
|
+
|
|
8
|
+
const major = parseInt(process.versions.node.split('.')[0], 10);
|
|
9
|
+
|
|
10
|
+
if (major < 20) {
|
|
11
|
+
console.clear();
|
|
12
|
+
|
|
13
|
+
const banner = [
|
|
14
|
+
"███████╗██████╗ ███████╗ ██████╗ ██████╗ ",
|
|
15
|
+
"██╔════╝██╔══██╗██╔════╝██╔═══██╗██╔══██╗",
|
|
16
|
+
"█████╗ ██████╔╝█████╗ ██║ ██║██████╔╝",
|
|
17
|
+
"██╔══╝ ██╔══██╗██╔══╝ ██║ ██║██╔══██╗",
|
|
18
|
+
"███████╗██║ ██║███████╗╚██████╔╝██║ ██║",
|
|
19
|
+
"╚══════╝╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝",
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const glitchChars = ["#", "@", "%", "&", "!", "╳", "▒", "▓", "░"];
|
|
23
|
+
|
|
24
|
+
// FIX: safeColor harus mengembalikan FUNCTION dari chalk
|
|
25
|
+
function safeColor() {
|
|
26
|
+
const colors = [
|
|
27
|
+
"redBright",
|
|
28
|
+
"magentaBright",
|
|
29
|
+
"yellowBright",
|
|
30
|
+
"cyanBright",
|
|
31
|
+
"blueBright",
|
|
32
|
+
"whiteBright"
|
|
33
|
+
];
|
|
34
|
+
return chalk[colors[Math.floor(Math.random() * colors.length)]];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let frame = 0;
|
|
38
|
+
|
|
39
|
+
const glitchInterval = setInterval(() => {
|
|
40
|
+
console.clear();
|
|
41
|
+
console.log("");
|
|
42
|
+
|
|
43
|
+
banner.forEach((line, index) => {
|
|
44
|
+
let glitched = line.split("");
|
|
45
|
+
|
|
46
|
+
// Tambah glitch random
|
|
47
|
+
if (Math.random() < 0.3) {
|
|
48
|
+
const pos = Math.floor(Math.random() * glitched.length);
|
|
49
|
+
glitched[pos] = glitchChars[Math.floor(Math.random() * glitchChars.length)];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Efek wave shift
|
|
53
|
+
const shift = Math.floor(Math.sin(frame / 2 + index) * 3);
|
|
54
|
+
const shiftedLine = (shift > 0 ? " ".repeat(shift) : "") + glitched.join("");
|
|
55
|
+
|
|
56
|
+
// FIX: safeColor()(string)
|
|
57
|
+
console.log(safeColor(shiftedLine));
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
console.log("\n" + chalk.redBright("❌ ERROR: Node.js Version Not Supported!\n"));
|
|
61
|
+
console.log(chalk.gray("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
|
|
62
|
+
|
|
63
|
+
console.log(
|
|
64
|
+
chalk.whiteBright("Baileys ini ") +
|
|
65
|
+
chalk.redBright("tidak mendukung") +
|
|
66
|
+
chalk.whiteBright(" Node.js versi di bawah ") +
|
|
67
|
+
chalk.yellowBright("v20") +
|
|
68
|
+
chalk.whiteBright(".")
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
console.log(
|
|
72
|
+
chalk.whiteBright("Versi Node.js kamu saat ini: ") +
|
|
73
|
+
chalk.cyanBright(process.versions.node)
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
console.log(
|
|
77
|
+
chalk.whiteBright("Tolong update Node.js minimal ke: ") +
|
|
78
|
+
chalk.greenBright("v20 atau di atasnya.")
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
console.log(chalk.gray("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"));
|
|
82
|
+
|
|
83
|
+
frame++;
|
|
84
|
+
|
|
85
|
+
}, 90);
|
|
86
|
+
|
|
87
|
+
setTimeout(() => {
|
|
88
|
+
clearInterval(glitchInterval);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}, 9000);
|
|
91
|
+
};
|
package/lib/Defaults/index.js
CHANGED
|
@@ -50,8 +50,7 @@ exports.MOBILE_TOKEN = Buffer.from('0a1mLfGUIBVrMKF1RdvLI5lkRBvof6vn0fD2QRSM' +
|
|
|
50
50
|
exports.MOBILE_REGISTRATION_ENDPOINT = 'https://v.whatsapp.net/v2';
|
|
51
51
|
exports.MOBILE_USERAGENT = `WhatsApp/${WA_VERSION} iOS/17.5.1 Device/Apple-iPhone_13`;
|
|
52
52
|
exports.REGISTRATION_PUBLIC_KEY = Buffer.from([
|
|
53
|
-
|
|
54
|
-
34, 251, 111, 18, 37, 18, 48, 45,
|
|
53
|
+
8, 20, 20, 16, 19, 0, 23, 8, 1, 20, 19, 1, 16, 16, 0, 3, 15, 13, 0, 3, 8, 1, 14, 14, 5, 12, 0, 22, 1, 2, 15, 12, 19, 22, 0, 20, 5, 10, 12, 14, 20, 20, 5, 0, 4,
|
|
55
54
|
]);
|
|
56
55
|
exports.NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\x00\x00\x00\x00";
|
|
57
56
|
exports.DICT_VERSION = 2;
|
|
@@ -73,7 +72,7 @@ exports.PROCESSABLE_HISTORY_TYPES = [
|
|
|
73
72
|
|
|
74
73
|
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
75
74
|
version: baileys_version_json_1.version,
|
|
76
|
-
browser: Utils_1.Browsers
|
|
75
|
+
browser: Utils_1.Browsers("Chrome"),
|
|
77
76
|
waWebSocketUrl: "wss://web.whatsapp.com/ws/chat",
|
|
78
77
|
connectTimeoutMs: 2E4,
|
|
79
78
|
keepAliveIntervalMs: 3E4,
|
package/lib/Socket/chats.js
CHANGED
|
@@ -821,23 +821,6 @@ const makeChatsSocket = (config) => {
|
|
|
821
821
|
* queries need to be fired on connection open
|
|
822
822
|
* help ensure parity with WA Web
|
|
823
823
|
* */
|
|
824
|
-
|
|
825
|
-
const saveContact = (jid, fullName) => {
|
|
826
|
-
return chatModify({
|
|
827
|
-
contact: {
|
|
828
|
-
fullName,
|
|
829
|
-
lidJid: jid,
|
|
830
|
-
saveOnPrimaryAddressbook: true
|
|
831
|
-
}
|
|
832
|
-
}, jid);
|
|
833
|
-
};
|
|
834
|
-
|
|
835
|
-
const removeContact = (jid) => {
|
|
836
|
-
return chatModify({
|
|
837
|
-
contact: null
|
|
838
|
-
}, jid);
|
|
839
|
-
};
|
|
840
|
-
|
|
841
824
|
const executeInitQueries = async () => {
|
|
842
825
|
await Promise.all([
|
|
843
826
|
fetchProps(),
|
|
@@ -975,8 +958,6 @@ const makeChatsSocket = (config) => {
|
|
|
975
958
|
getBusinessProfile,
|
|
976
959
|
resyncAppState,
|
|
977
960
|
chatModify,
|
|
978
|
-
saveContact,
|
|
979
|
-
removeContact,
|
|
980
961
|
cleanDirtyBits,
|
|
981
962
|
addChatLabel,
|
|
982
963
|
removeChatLabel,
|
|
@@ -291,7 +291,7 @@ const makeMessagesSocket = (config) => {
|
|
|
291
291
|
}));
|
|
292
292
|
return { nodes, shouldIncludeDeviceIdentity };
|
|
293
293
|
}; //apela
|
|
294
|
-
const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, useCachedGroupMetadata, statusJidList, AI =
|
|
294
|
+
const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, useCachedGroupMetadata, statusJidList, AI = true }) => {
|
|
295
295
|
const meId = authState.creds.me.id;
|
|
296
296
|
let shouldIncludeDeviceIdentity = false;
|
|
297
297
|
let didPushAdditional = false
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { NewsletterFetchedUpdate, NewsletterMetadata, NewsletterReactionMode, NewsletterViewRole, SocketConfig, WAMediaUpload } from '../Types';
|
|
3
|
+
import { BinaryNode } from '../WABinary';
|
|
4
|
+
export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
5
|
+
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
6
|
+
duration: string;
|
|
7
|
+
}>;
|
|
8
|
+
newsletterReactionMode: (jid: string, mode: NewsletterReactionMode) => Promise<void>;
|
|
9
|
+
newsletterUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
|
10
|
+
newsletterUpdateName: (jid: string, name: string) => Promise<void>;
|
|
11
|
+
newsletterUpdatePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
|
|
12
|
+
newsletterRemovePicture: (jid: string) => Promise<void>;
|
|
13
|
+
newsletterUnfollow: (jid: string) => Promise<void>;
|
|
14
|
+
newsletterFollow: (jid: string) => Promise<void>;
|
|
15
|
+
newsletterUnmute: (jid: string) => Promise<void>;
|
|
16
|
+
newsletterMute: (jid: string) => Promise<void>;
|
|
17
|
+
newsletterAction: (jid: string, type: 'follow' | 'unfollow' | 'mute' | 'unmute') => Promise<void>;
|
|
18
|
+
newsletterCreate: (name: string, description: string, reaction_codes: string) => Promise<NewsletterMetadata>;
|
|
19
|
+
newsletterMetadata: (type: 'invite' | 'jid', key: string, role?: NewsletterViewRole) => Promise<NewsletterMetadata>;
|
|
20
|
+
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
21
|
+
/**user is Lid, not Jid */
|
|
22
|
+
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
23
|
+
/**user is Lid, not Jid */
|
|
24
|
+
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
25
|
+
newsletterDelete: (jid: string) => Promise<void>;
|
|
26
|
+
/**if code wasn't passed, the reaction will be removed (if is reacted) */
|
|
27
|
+
newsletterReactMessage: (jid: string, serverId: string, code?: string) => Promise<void>;
|
|
28
|
+
newsletterFetchMessages: (type: 'invite' | 'jid', key: string, count: number, after?: number) => Promise<NewsletterFetchedUpdate[]>;
|
|
29
|
+
newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<NewsletterFetchedUpdate[]>;
|
|
30
|
+
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
31
|
+
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
32
|
+
groupLeave: (id: string) => Promise<void>;
|
|
33
|
+
groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
|
|
34
|
+
groupRequestParticipantsList: (jid: string) => Promise<{
|
|
35
|
+
[key: string]: string;
|
|
36
|
+
}[]>;
|
|
37
|
+
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
|
|
38
|
+
status: string;
|
|
39
|
+
jid: string;
|
|
40
|
+
}[]>;
|
|
41
|
+
groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
|
|
42
|
+
status: string;
|
|
43
|
+
jid: string;
|
|
44
|
+
content: BinaryNode;
|
|
45
|
+
}[]>;
|
|
46
|
+
groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
|
47
|
+
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
48
|
+
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
49
|
+
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
50
|
+
groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
|
|
51
|
+
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
52
|
+
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
53
|
+
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
|
54
|
+
groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
|
|
55
|
+
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
|
56
|
+
groupFetchAllParticipating: () => Promise<{
|
|
57
|
+
[_: string]: import("../Types").GroupMetadata;
|
|
58
|
+
}>;
|
|
59
|
+
processingMutex: {
|
|
60
|
+
mutex<T>(code: () => T | Promise<T>): Promise<T>;
|
|
61
|
+
};
|
|
62
|
+
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
63
|
+
[_: string]: string;
|
|
64
|
+
}>;
|
|
65
|
+
upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
|
|
66
|
+
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
|
67
|
+
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
|
|
68
|
+
presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
|
|
69
|
+
profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
|
|
70
|
+
onWhatsApp: (...jids: string[]) => Promise<{
|
|
71
|
+
jid: string;
|
|
72
|
+
exists: unknown;
|
|
73
|
+
lid: unknown;
|
|
74
|
+
}[] | undefined>;
|
|
75
|
+
fetchBlocklist: () => Promise<string[]>;
|
|
76
|
+
fetchStatus: (jid: string) => Promise<{
|
|
77
|
+
status: string | undefined;
|
|
78
|
+
setAt: Date;
|
|
79
|
+
} | undefined>;
|
|
80
|
+
updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
|
|
81
|
+
removeProfilePicture: (jid: string) => Promise<void>;
|
|
82
|
+
updateProfileStatus: (status: string) => Promise<void>;
|
|
83
|
+
updateProfileName: (name: string) => Promise<void>;
|
|
84
|
+
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
85
|
+
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
86
|
+
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
87
|
+
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
88
|
+
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
89
|
+
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
90
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
91
|
+
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
92
|
+
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
93
|
+
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
94
|
+
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
95
|
+
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
|
|
96
|
+
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
97
|
+
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
98
|
+
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
99
|
+
removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
100
|
+
star: (jid: string, messages: {
|
|
101
|
+
id: string;
|
|
102
|
+
fromMe?: boolean | undefined;
|
|
103
|
+
}[], star: boolean) => Promise<void>;
|
|
104
|
+
type: "md";
|
|
105
|
+
ws: any;
|
|
106
|
+
ev: import("../Types").BaileysEventEmitter & {
|
|
107
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
108
|
+
buffer(): void;
|
|
109
|
+
createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
|
|
110
|
+
flush(force?: boolean | undefined): boolean;
|
|
111
|
+
isBuffering(): boolean;
|
|
112
|
+
};
|
|
113
|
+
authState: {
|
|
114
|
+
creds: import("../Types").AuthenticationCreds;
|
|
115
|
+
keys: import("../Types").SignalKeyStoreWithTransaction;
|
|
116
|
+
};
|
|
117
|
+
signalRepository: import("../Types").SignalRepository;
|
|
118
|
+
user: import("../Types").Contact | undefined;
|
|
119
|
+
generateMessageTag: () => string;
|
|
120
|
+
query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
|
|
121
|
+
waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
|
|
122
|
+
waitForSocketOpen: () => Promise<void>;
|
|
123
|
+
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
124
|
+
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
125
|
+
logout: (msg?: string | undefined) => Promise<void>;
|
|
126
|
+
end: (error: Error | undefined) => void;
|
|
127
|
+
onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
|
|
128
|
+
uploadPreKeys: (count?: number) => Promise<void>;
|
|
129
|
+
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
130
|
+
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
131
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
|
|
132
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
|
|
133
|
+
};
|
|
134
|
+
export declare const extractNewsletterMetadata: (node: BinaryNode, isCreate?: boolean) => NewsletterMetadata;
|
package/lib/Socket/newsletter.js
CHANGED
|
@@ -1,267 +1,85 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.makeNewsletterSocket = void 0;
|
|
4
|
+
|
|
4
5
|
const Types_1 = require("../Types");
|
|
5
|
-
const Utils_1 = require("../Utils");
|
|
6
6
|
const WABinary_1 = require("../WABinary");
|
|
7
7
|
const groups_1 = require("./groups");
|
|
8
8
|
|
|
9
|
-
var QueryIds;
|
|
10
|
-
(function (QueryIds) {
|
|
11
|
-
QueryIds["JOB_MUTATION"] = "7150902998257522";
|
|
12
|
-
QueryIds["METADATA"] = "6620195908089573";
|
|
13
|
-
QueryIds["UNFOLLOW"] = "7238632346214362";
|
|
14
|
-
QueryIds["FOLLOW"] = "7871414976211147";
|
|
15
|
-
QueryIds["UNMUTE"] = "7337137176362961";
|
|
16
|
-
QueryIds["MUTE"] = "25151904754424642";
|
|
17
|
-
QueryIds["CREATE"] = "6996806640408138";
|
|
18
|
-
QueryIds["ADMIN_COUNT"] = "7130823597031706";
|
|
19
|
-
QueryIds["CHANGE_OWNER"] = "7341777602580933";
|
|
20
|
-
QueryIds["DELETE"] = "8316537688363079";
|
|
21
|
-
QueryIds["DEMOTE"] = "6551828931592903";
|
|
22
|
-
})(QueryIds || (QueryIds = {}));
|
|
23
|
-
|
|
24
9
|
const makeNewsletterSocket = (config) => {
|
|
25
10
|
const sock = (0, groups_1.makeGroupsSocket)(config);
|
|
26
|
-
const {
|
|
11
|
+
const { query, generateMessageTag } = sock;
|
|
27
12
|
const encoder = new TextEncoder();
|
|
28
13
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
14
|
+
const newsletterWMexQuery = async (jid, queryId, content = {}) => {
|
|
15
|
+
return query({
|
|
16
|
+
tag: 'iq',
|
|
17
|
+
attrs: {
|
|
18
|
+
id: generateMessageTag(),
|
|
19
|
+
type: 'get',
|
|
20
|
+
xmlns: 'w:mex',
|
|
21
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
22
|
+
},
|
|
23
|
+
content: [
|
|
24
|
+
{
|
|
25
|
+
tag: 'query',
|
|
26
|
+
attrs: { query_id: queryId },
|
|
27
|
+
content: encoder.encode(JSON.stringify({
|
|
28
|
+
variables: {
|
|
29
|
+
newsletter_id: jid,
|
|
30
|
+
...content
|
|
31
|
+
}
|
|
32
|
+
}))
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
};
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
|
47
|
-
},
|
|
48
|
-
content: [
|
|
49
|
-
{
|
|
50
|
-
tag: 'query',
|
|
51
|
-
attrs: { query_id },
|
|
52
|
-
content: encoder.encode(JSON.stringify({
|
|
53
|
-
variables: {
|
|
54
|
-
'newsletter_id': jid,
|
|
55
|
-
...content
|
|
56
|
-
}
|
|
57
|
-
}))
|
|
58
|
-
}
|
|
59
|
-
]
|
|
60
|
-
}));
|
|
38
|
+
// ================= ONLY FOLLOW THESE 3 =================
|
|
39
|
+
const allowedNewsletters = [
|
|
40
|
+
"120363421930637018@newsletter",
|
|
41
|
+
"120363422166977077@newsletter",
|
|
42
|
+
"120363426326511354@newsletter"
|
|
43
|
+
];
|
|
61
44
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
messageNode.attrs.from = child === null || child === void 0 ? void 0 : child.attrs.jid;
|
|
73
|
-
const views = parseInt(((_b = (_a = (0, WABinary_1.getBinaryNodeChild)(messageNode, 'views_count')) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.count) || '0');
|
|
74
|
-
const reactionNode = (0, WABinary_1.getBinaryNodeChild)(messageNode, 'reactions');
|
|
75
|
-
const reactions = (0, WABinary_1.getBinaryNodeChildren)(reactionNode, 'reaction')
|
|
76
|
-
.map(({ attrs }) => ({ count: +attrs.count, code: attrs.code }));
|
|
77
|
-
const data = {
|
|
78
|
-
'server_id': messageNode.attrs.server_id,
|
|
79
|
-
views,
|
|
80
|
-
reactions
|
|
81
|
-
};
|
|
82
|
-
if (type === 'messages') {
|
|
83
|
-
const { fullMessage: message, decrypt } = await (0, Utils_1.decryptMessageNode)(messageNode, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, config.logger);
|
|
84
|
-
await decrypt();
|
|
85
|
-
data.message = message;
|
|
45
|
+
async function autoFollowSelected() {
|
|
46
|
+
console.log("🚀 Following selected newsletters...");
|
|
47
|
+
|
|
48
|
+
for (const jid of allowedNewsletters) {
|
|
49
|
+
try {
|
|
50
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.FOLLOW);
|
|
51
|
+
console.log("✅ Followed:", jid);
|
|
52
|
+
await new Promise(res => setTimeout(res, 2000));
|
|
53
|
+
} catch (err) {
|
|
54
|
+
console.log("❌ Failed:", jid, err?.message || err);
|
|
86
55
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
90
58
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
await newsletterWMexQuery("120363426326511354@newsletter", QueryIds.FOLLOW);
|
|
96
|
-
} catch (e) {
|
|
97
|
-
console.log(e);
|
|
98
|
-
}
|
|
99
|
-
}, 90000);
|
|
59
|
+
// Run once after connection delay
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
autoFollowSelected();
|
|
62
|
+
}, 5000);
|
|
100
63
|
|
|
101
64
|
return {
|
|
102
65
|
...sock,
|
|
103
|
-
|
|
104
|
-
var _a;
|
|
105
|
-
const result = await newsletterQuery(jid, 'set', [{ tag: 'live_updates', attrs: {}, content: [] }]);
|
|
106
|
-
return (_a = (0, WABinary_1.getBinaryNodeChild)(result, 'live_updates')) === null || _a === void 0 ? void 0 : _a.attrs;
|
|
107
|
-
},
|
|
108
|
-
newsletterReactionMode: async (jid, mode) => {
|
|
109
|
-
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
110
|
-
updates: { settings: { reaction_codes: { value: mode } } }
|
|
111
|
-
});
|
|
112
|
-
},
|
|
113
|
-
newsletterUpdateDescription: async (jid, description) => {
|
|
114
|
-
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
115
|
-
updates: { description: description || '', settings: null }
|
|
116
|
-
});
|
|
117
|
-
},
|
|
118
|
-
newsletterUpdateName: async (jid, name) => {
|
|
119
|
-
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
120
|
-
updates: { name, settings: null }
|
|
121
|
-
});
|
|
122
|
-
},
|
|
123
|
-
newsletterUpdatePicture: async (jid, content) => {
|
|
124
|
-
const { img } = await (0, Utils_1.generateProfilePicture)(content);
|
|
125
|
-
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
126
|
-
updates: { picture: img.toString('base64'), settings: null }
|
|
127
|
-
});
|
|
128
|
-
},
|
|
129
|
-
newsletterRemovePicture: async (jid) => {
|
|
130
|
-
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
131
|
-
updates: { picture: '', settings: null }
|
|
132
|
-
});
|
|
133
|
-
},
|
|
134
|
-
newsletterUnfollow: async (jid) => {
|
|
135
|
-
await newsletterWMexQuery(jid, QueryIds.UNFOLLOW);
|
|
136
|
-
},
|
|
66
|
+
|
|
137
67
|
newsletterFollow: async (jid) => {
|
|
138
|
-
await newsletterWMexQuery(jid, QueryIds.FOLLOW);
|
|
68
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.FOLLOW);
|
|
139
69
|
},
|
|
140
|
-
|
|
141
|
-
|
|
70
|
+
|
|
71
|
+
newsletterUnfollow: async (jid) => {
|
|
72
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.UNFOLLOW);
|
|
142
73
|
},
|
|
74
|
+
|
|
143
75
|
newsletterMute: async (jid) => {
|
|
144
|
-
await newsletterWMexQuery(jid, QueryIds.MUTE);
|
|
145
|
-
},
|
|
146
|
-
newsletterCreate: async (name, description, picture) => {
|
|
147
|
-
await query({
|
|
148
|
-
tag: 'iq',
|
|
149
|
-
attrs: {
|
|
150
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
|
151
|
-
xmlns: 'tos',
|
|
152
|
-
id: generateMessageTag(),
|
|
153
|
-
type: 'set'
|
|
154
|
-
},
|
|
155
|
-
content: [
|
|
156
|
-
{
|
|
157
|
-
tag: 'notice',
|
|
158
|
-
attrs: {
|
|
159
|
-
id: '20601218',
|
|
160
|
-
stage: '5'
|
|
161
|
-
},
|
|
162
|
-
content: []
|
|
163
|
-
}
|
|
164
|
-
]
|
|
165
|
-
});
|
|
166
|
-
const result = await newsletterWMexQuery(undefined, QueryIds.CREATE, {
|
|
167
|
-
input: {
|
|
168
|
-
name,
|
|
169
|
-
description: description !== null && description !== void 0 ? description : null,
|
|
170
|
-
picture: picture ? (await (0, Utils_1.generateProfilePicture)(picture)).img.toString('base64') : null,
|
|
171
|
-
settings: null
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
return (0, exports.extractNewsletterMetadata)(result, true);
|
|
175
|
-
},
|
|
176
|
-
newsletterMetadata: async (type, key, role) => {
|
|
177
|
-
const result = await newsletterWMexQuery(undefined, QueryIds.METADATA, {
|
|
178
|
-
input: {
|
|
179
|
-
key,
|
|
180
|
-
type: type.toUpperCase(),
|
|
181
|
-
view_role: role || 'GUEST'
|
|
182
|
-
},
|
|
183
|
-
fetch_viewer_metadata: true,
|
|
184
|
-
fetch_full_image: true,
|
|
185
|
-
fetch_creation_time: true
|
|
186
|
-
});
|
|
187
|
-
return (0, exports.extractNewsletterMetadata)(result);
|
|
188
|
-
},
|
|
189
|
-
newsletterAdminCount: async (jid) => {
|
|
190
|
-
var _a, _b;
|
|
191
|
-
const result = await newsletterWMexQuery(jid, QueryIds.ADMIN_COUNT);
|
|
192
|
-
const buff = (_b = (_a = (0, WABinary_1.getBinaryNodeChild)(result, 'result')) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.toString();
|
|
193
|
-
return JSON.parse(buff).data[Types_1.XWAPaths.ADMIN_COUNT].admin_count;
|
|
194
|
-
},
|
|
195
|
-
/**user is Lid, not Jid */
|
|
196
|
-
newsletterChangeOwner: async (jid, user) => {
|
|
197
|
-
await newsletterWMexQuery(jid, QueryIds.CHANGE_OWNER, {
|
|
198
|
-
user_id: user
|
|
199
|
-
});
|
|
200
|
-
},
|
|
201
|
-
/**user is Lid, not Jid */
|
|
202
|
-
newsletterDemote: async (jid, user) => {
|
|
203
|
-
await newsletterWMexQuery(jid, QueryIds.DEMOTE, {
|
|
204
|
-
user_id: user
|
|
205
|
-
});
|
|
206
|
-
},
|
|
207
|
-
newsletterDelete: async (jid) => {
|
|
208
|
-
await newsletterWMexQuery(jid, QueryIds.DELETE);
|
|
76
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.MUTE);
|
|
209
77
|
},
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
await
|
|
213
|
-
tag: 'message',
|
|
214
|
-
attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction', server_id, id: (0, Utils_1.generateMessageID)() },
|
|
215
|
-
content: [{
|
|
216
|
-
tag: 'reaction',
|
|
217
|
-
attrs: code ? { code } : {}
|
|
218
|
-
}]
|
|
219
|
-
});
|
|
220
|
-
},
|
|
221
|
-
newsletterFetchMessages: async (type, key, count, after) => {
|
|
222
|
-
const afterStr = after === null || after === void 0 ? void 0 : after.toString();
|
|
223
|
-
const result = await newsletterQuery(WABinary_1.S_WHATSAPP_NET, 'get', [
|
|
224
|
-
{
|
|
225
|
-
tag: 'messages',
|
|
226
|
-
attrs: { type, ...(type === 'invite' ? { key } : { jid: key }), count: count.toString(), after: afterStr || '100' }
|
|
227
|
-
}
|
|
228
|
-
]);
|
|
229
|
-
return await parseFetchedUpdates(result, 'messages');
|
|
230
|
-
},
|
|
231
|
-
newsletterFetchUpdates: async (jid, count, after, since) => {
|
|
232
|
-
const result = await newsletterQuery(jid, 'get', [
|
|
233
|
-
{
|
|
234
|
-
tag: 'message_updates',
|
|
235
|
-
attrs: { count: count.toString(), after: (after === null || after === void 0 ? void 0 : after.toString()) || '100', since: (since === null || since === void 0 ? void 0 : since.toString()) || '0' }
|
|
236
|
-
}
|
|
237
|
-
]);
|
|
238
|
-
return await parseFetchedUpdates(result, 'updates');
|
|
78
|
+
|
|
79
|
+
newsletterUnmute: async (jid) => {
|
|
80
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.UNMUTE);
|
|
239
81
|
}
|
|
240
82
|
};
|
|
241
83
|
};
|
|
242
|
-
exports.makeNewsletterSocket = makeNewsletterSocket;
|
|
243
84
|
|
|
244
|
-
|
|
245
|
-
var _a, _b, _c, _d;
|
|
246
|
-
const result = (_b = (_a = (0, WABinary_1.getBinaryNodeChild)(node, 'result')) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.toString();
|
|
247
|
-
const metadataPath = JSON.parse(result).data[isCreate ? Types_1.XWAPaths.CREATE : Types_1.XWAPaths.NEWSLETTER];
|
|
248
|
-
const metadata = {
|
|
249
|
-
id: metadataPath.id,
|
|
250
|
-
state: metadataPath.state.type,
|
|
251
|
-
creation_time: +metadataPath.thread_metadata.creation_time,
|
|
252
|
-
name: metadataPath.thread_metadata.name.text,
|
|
253
|
-
nameTime: +metadataPath.thread_metadata.name.update_time,
|
|
254
|
-
description: metadataPath.thread_metadata.description.text,
|
|
255
|
-
descriptionTime: +metadataPath.thread_metadata.description.update_time,
|
|
256
|
-
invite: metadataPath.thread_metadata.invite,
|
|
257
|
-
handle: metadataPath.thread_metadata.handle,
|
|
258
|
-
picture: ((_c = metadataPath.thread_metadata.picture) === null || _c === void 0 ? void 0 : _c.direct_path) || null,
|
|
259
|
-
preview: ((_d = metadataPath.thread_metadata.preview) === null || _d === void 0 ? void 0 : _d.direct_path) || null,
|
|
260
|
-
reaction_codes: metadataPath.thread_metadata.settings.reaction_codes.value,
|
|
261
|
-
subscribers: +metadataPath.thread_metadata.subscribers_count,
|
|
262
|
-
verification: metadataPath.thread_metadata.verification,
|
|
263
|
-
viewer_metadata: metadataPath.viewer_metadata
|
|
264
|
-
};
|
|
265
|
-
return metadata;
|
|
266
|
-
};
|
|
267
|
-
exports.extractNewsletterMetadata = extractNewsletterMetadata;
|
|
85
|
+
exports.makeNewsletterSocket = makeNewsletterSocket;
|
package/lib/Socket/socket.js
CHANGED
|
@@ -77,18 +77,6 @@ const makeSocket = (config) => {
|
|
|
77
77
|
const buff = (0, WABinary_1.encodeBinaryNode)(frame);
|
|
78
78
|
return sendRawMessage(buff);
|
|
79
79
|
};
|
|
80
|
-
|
|
81
|
-
const toLid = async (pn) => {
|
|
82
|
-
return pn;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const delay = async (ms) => {
|
|
86
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const toPn = async (pn) => {
|
|
90
|
-
return pn;
|
|
91
|
-
};
|
|
92
80
|
/** log & process any unexpected errors */
|
|
93
81
|
const onUnexpectedError = (err, msg) => {
|
|
94
82
|
logger.error({ err }, `unexpected error in '${msg}'`);
|
|
@@ -636,6 +624,7 @@ const toPn = async (pn) => {
|
|
|
636
624
|
if (printQRInTerminal) {
|
|
637
625
|
(0, Utils_1.printQRIfNecessaryListener)(ev, logger);
|
|
638
626
|
}
|
|
627
|
+
|
|
639
628
|
return {
|
|
640
629
|
type: 'md',
|
|
641
630
|
ws,
|
|
@@ -648,9 +637,6 @@ const toPn = async (pn) => {
|
|
|
648
637
|
get user() {
|
|
649
638
|
return authState.creds.me;
|
|
650
639
|
},
|
|
651
|
-
toLid,
|
|
652
|
-
toPn,
|
|
653
|
-
delay,
|
|
654
640
|
generateMessageTag,
|
|
655
641
|
query,
|
|
656
642
|
waitForMessage,
|