dread-fork 2.0.0-dread.0
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/DREAD_PATCHES.md +34 -0
- package/README.md +34 -0
- package/WAProto/index.js +169661 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +53 -0
- package/lib/Defaults/index.js +158 -0
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.d.ts +14 -0
- package/lib/Signal/Group/group-session-builder.js +64 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.js +96 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +57 -0
- package/lib/Signal/Group/keyhelper.d.ts +10 -0
- package/lib/Signal/Group/keyhelper.js +55 -0
- package/lib/Signal/Group/queue-job.d.ts +1 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-chain-key.js +34 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.d.ts +17 -0
- package/lib/Signal/Group/sender-key-name.js +51 -0
- package/lib/Signal/Group/sender-key-record.d.ts +30 -0
- package/lib/Signal/Group/sender-key-record.js +53 -0
- package/lib/Signal/Group/sender-key-state.d.ts +38 -0
- package/lib/Signal/Group/sender-key-state.js +99 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/lib/Signal/Group/sender-message-key.js +29 -0
- package/lib/Signal/libsignal.d.ts +3 -0
- package/lib/Signal/libsignal.js +174 -0
- package/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.js +19 -0
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/web-socket-client.d.ts +12 -0
- package/lib/Socket/Client/web-socket-client.js +62 -0
- package/lib/Socket/business.d.ts +171 -0
- package/lib/Socket/business.js +260 -0
- package/lib/Socket/chats.d.ts +267 -0
- package/lib/Socket/chats.js +1019 -0
- package/lib/Socket/dugong.d.ts +254 -0
- package/lib/Socket/dugong.js +509 -0
- package/lib/Socket/groups.d.ts +115 -0
- package/lib/Socket/groups.js +317 -0
- package/lib/Socket/index.d.ts +174 -0
- package/lib/Socket/index.js +12 -0
- package/lib/Socket/index.js.bak +26 -0
- package/lib/Socket/messages-recv.d.ts +161 -0
- package/lib/Socket/messages-recv.js +1113 -0
- package/lib/Socket/messages-send.d.ts +149 -0
- package/lib/Socket/messages-send.js +762 -0
- package/lib/Socket/newsletter.d.ts +134 -0
- package/lib/Socket/newsletter.js +347 -0
- package/lib/Socket/registration.d.ts +267 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +43 -0
- package/lib/Socket/socket.js +694 -0
- package/lib/Socket/usync.d.ts +36 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/index.js +10 -0
- package/lib/Store/make-cache-manager-store.d.ts +13 -0
- package/lib/Store/make-cache-manager-store.js +83 -0
- package/lib/Store/make-in-memory-store.d.ts +118 -0
- package/lib/Store/make-in-memory-store.js +427 -0
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/make-ordered-dictionary.js +81 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +27 -0
- package/lib/Types/Auth.d.ts +110 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Call.d.ts +13 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.d.ts +102 -0
- package/lib/Types/Chat.js +4 -0
- package/lib/Types/Contact.d.ts +19 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.d.ts +157 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.d.ts +55 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.d.ts +35 -0
- package/lib/Types/Label.js +27 -0
- package/lib/Types/LabelAssociation.d.ts +29 -0
- package/lib/Types/LabelAssociation.js +9 -0
- package/lib/Types/Message.d.ts +273 -0
- package/lib/Types/Message.js +9 -0
- package/lib/Types/Newsletter.d.ts +103 -0
- package/lib/Types/Newsletter.js +38 -0
- package/lib/Types/Product.d.ts +78 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Signal.d.ts +57 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.d.ts +111 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.d.ts +27 -0
- package/lib/Types/State.js +2 -0
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.d.ts +57 -0
- package/lib/Types/index.js +42 -0
- package/lib/Utils/auth-utils.d.ts +18 -0
- package/lib/Utils/auth-utils.js +206 -0
- package/lib/Utils/baileys-event-stream.d.ts +16 -0
- package/lib/Utils/baileys-event-stream.js +63 -0
- package/lib/Utils/business.d.ts +22 -0
- package/lib/Utils/business.js +234 -0
- package/lib/Utils/chat-utils.d.ts +71 -0
- package/lib/Utils/chat-utils.js +729 -0
- package/lib/Utils/crypto.d.ts +41 -0
- package/lib/Utils/crypto.js +151 -0
- package/lib/Utils/decode-wa-message.d.ts +19 -0
- package/lib/Utils/decode-wa-message.js +198 -0
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/lib/Utils/event-buffer.js +514 -0
- package/lib/Utils/generics.d.ts +92 -0
- package/lib/Utils/generics.js +423 -0
- package/lib/Utils/history.d.ts +15 -0
- package/lib/Utils/history.js +96 -0
- package/lib/Utils/index.d.ts +17 -0
- package/lib/Utils/index.js +33 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.js +93 -0
- package/lib/Utils/logger.d.ts +4 -0
- package/lib/Utils/logger.js +7 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/lt-hash.js +51 -0
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/lib/Utils/make-mutex.js +43 -0
- package/lib/Utils/messages-media.d.ts +116 -0
- package/lib/Utils/messages-media.js +819 -0
- package/lib/Utils/messages.d.ts +77 -0
- package/lib/Utils/messages.js +816 -0
- package/lib/Utils/noise-handler.d.ts +21 -0
- package/lib/Utils/noise-handler.js +155 -0
- package/lib/Utils/process-message.d.ts +41 -0
- package/lib/Utils/process-message.js +321 -0
- package/lib/Utils/signal.d.ts +32 -0
- package/lib/Utils/signal.js +153 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-multi-file-auth-state.js +119 -0
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.js +229 -0
- package/lib/WABinary/constants.d.ts +30 -0
- package/lib/WABinary/constants.js +40 -0
- package/lib/WABinary/decode.d.ts +7 -0
- package/lib/WABinary/decode.js +252 -0
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.js +260 -0
- package/lib/WABinary/generic-utils.d.ts +17 -0
- package/lib/WABinary/generic-utils.js +198 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +21 -0
- package/lib/WABinary/jid-utils.d.ts +31 -0
- package/lib/WABinary/jid-utils.js +62 -0
- package/lib/WABinary/types.d.ts +18 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.d.ts +17 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.d.ts +38 -0
- package/lib/WAM/constants.js +15350 -0
- package/lib/WAM/encode.d.ts +3 -0
- package/lib/WAM/encode.js +155 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +19 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
- package/lib/WAUSync/Protocols/index.d.ts +4 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/USyncQuery.d.ts +28 -0
- package/lib/WAUSync/USyncQuery.js +89 -0
- package/lib/WAUSync/USyncUser.d.ts +12 -0
- package/lib/WAUSync/USyncUser.js +26 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +19 -0
- package/lib/dread-features.d.ts +76 -0
- package/lib/dread-features.js +543 -0
- package/lib/dread-index.d.ts +6 -0
- package/lib/dread-index.js +19 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +38 -0
- package/package.json +111 -0
|
@@ -0,0 +1,762 @@
|
|
|
1
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
2
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
3
|
+
};
|
|
4
|
+
var ListType;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.makeMessagesSocket = void 0;
|
|
9
|
+
const boom_1 = require("@hapi/boom"),
|
|
10
|
+
node_cache_1 = __importDefault(require("node-cache")),
|
|
11
|
+
WAProto_1 = require("../../WAProto"),
|
|
12
|
+
Defaults_1 = require("../Defaults"),
|
|
13
|
+
axios_1 = require("axios"),
|
|
14
|
+
Types_1 = require("../Types"),
|
|
15
|
+
Utils_1 = require("../Utils"),
|
|
16
|
+
link_preview_1 = require("../Utils/link-preview"),
|
|
17
|
+
WABinary_1 = require("../WABinary"),
|
|
18
|
+
newsletter_1 = require("./newsletter"),
|
|
19
|
+
WAUSync_1 = require("../WAUSync"),
|
|
20
|
+
crypto_1 = require("crypto"),
|
|
21
|
+
kikyy = require("./dugong");
|
|
22
|
+
ListType = WAProto_1.proto.Message.ListMessage.ListType;
|
|
23
|
+
const makeMessagesSocket = config => {
|
|
24
|
+
const {
|
|
25
|
+
logger: logger,
|
|
26
|
+
linkPreviewImageThumbnailWidth: linkPreviewImageThumbnailWidth,
|
|
27
|
+
generateHighQualityLinkPreview: generateHighQualityLinkPreview,
|
|
28
|
+
options: axiosOptions,
|
|
29
|
+
patchMessageBeforeSending: patchMessageBeforeSending
|
|
30
|
+
} = config,
|
|
31
|
+
sock = (0, newsletter_1.makeNewsletterSocket)(config),
|
|
32
|
+
{
|
|
33
|
+
ev,
|
|
34
|
+
authState: authState,
|
|
35
|
+
processingMutex: processingMutex,
|
|
36
|
+
signalRepository: signalRepository,
|
|
37
|
+
upsertMessage: upsertMessage,
|
|
38
|
+
query: query,
|
|
39
|
+
fetchPrivacySettings: fetchPrivacySettings,
|
|
40
|
+
generateMessageTag: generateMessageTag,
|
|
41
|
+
sendNode: sendNode,
|
|
42
|
+
groupMetadata: groupMetadata,
|
|
43
|
+
groupToggleEphemeral: groupToggleEphemeral,
|
|
44
|
+
executeUSyncQuery: executeUSyncQuery
|
|
45
|
+
} = sock,
|
|
46
|
+
userDevicesCache = config.userDevicesCache || new node_cache_1["default"]({
|
|
47
|
+
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.USER_DEVICES,
|
|
48
|
+
useClones: false
|
|
49
|
+
});
|
|
50
|
+
let mediaConn;
|
|
51
|
+
const refreshMediaConn = async (forceGet = false) => {
|
|
52
|
+
const media = await mediaConn;
|
|
53
|
+
if (!media || forceGet || new Date().getTime() - media.fetchDate.getTime() > media.ttl * 1000) {
|
|
54
|
+
mediaConn = (async () => {
|
|
55
|
+
const result = await query({
|
|
56
|
+
tag: "iq",
|
|
57
|
+
attrs: {
|
|
58
|
+
type: "set",
|
|
59
|
+
xmlns: "w:m",
|
|
60
|
+
to: WABinary_1.S_WHATSAPP_NET
|
|
61
|
+
},
|
|
62
|
+
content: [{
|
|
63
|
+
tag: "media_conn",
|
|
64
|
+
attrs: {}
|
|
65
|
+
}]
|
|
66
|
+
}),
|
|
67
|
+
mediaConnNode = WABinary_1.getBinaryNodeChild(result, "media_conn"),
|
|
68
|
+
node = {
|
|
69
|
+
hosts: WABinary_1.getBinaryNodeChildren(mediaConnNode, "host").map(({
|
|
70
|
+
attrs: attrs
|
|
71
|
+
}) => {
|
|
72
|
+
return {
|
|
73
|
+
hostname: attrs.hostname,
|
|
74
|
+
maxContentLengthBytes: +attrs.maxContentLengthBytes
|
|
75
|
+
};
|
|
76
|
+
}),
|
|
77
|
+
auth: mediaConnNode.attrs.auth,
|
|
78
|
+
ttl: +mediaConnNode.attrs.ttl,
|
|
79
|
+
fetchDate: new Date()
|
|
80
|
+
};
|
|
81
|
+
logger.debug("fetched media conn");
|
|
82
|
+
return node;
|
|
83
|
+
})();
|
|
84
|
+
}
|
|
85
|
+
return mediaConn;
|
|
86
|
+
},
|
|
87
|
+
sendReceipt = async (jid, participant, messageIds, type) => {
|
|
88
|
+
const node = {
|
|
89
|
+
tag: "receipt",
|
|
90
|
+
attrs: {
|
|
91
|
+
id: messageIds[0]
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
isReadReceipt = type === "read" || type === "read-self";
|
|
95
|
+
if (isReadReceipt) {
|
|
96
|
+
node.attrs.t = (0, Utils_1.unixTimestampSeconds)().toString();
|
|
97
|
+
}
|
|
98
|
+
if (type === "sender" && WABinary_1.isJidUser(jid)) {
|
|
99
|
+
node.attrs.recipient = jid;
|
|
100
|
+
node.attrs.to = participant;
|
|
101
|
+
} else {
|
|
102
|
+
node.attrs.to = jid;
|
|
103
|
+
if (participant) {
|
|
104
|
+
node.attrs.participant = participant;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (type) {
|
|
108
|
+
node.attrs.type = WABinary_1.isJidNewsLetter(jid) ? "read-self" : type;
|
|
109
|
+
}
|
|
110
|
+
const remainingMessageIds = messageIds.slice(1);
|
|
111
|
+
if (remainingMessageIds.length) {
|
|
112
|
+
node.content = [{
|
|
113
|
+
tag: "list",
|
|
114
|
+
attrs: {},
|
|
115
|
+
content: remainingMessageIds.map(id => {
|
|
116
|
+
return {
|
|
117
|
+
tag: "item",
|
|
118
|
+
attrs: {
|
|
119
|
+
id: id
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
})
|
|
123
|
+
}];
|
|
124
|
+
}
|
|
125
|
+
logger.debug({
|
|
126
|
+
attrs: node.attrs,
|
|
127
|
+
messageIds: messageIds
|
|
128
|
+
}, "sending receipt for messages");
|
|
129
|
+
await sendNode(node);
|
|
130
|
+
},
|
|
131
|
+
sendReceipts = async (keys, type) => {
|
|
132
|
+
const recps = (0, Utils_1.aggregateMessageKeysNotFromMe)(keys);
|
|
133
|
+
for (const {
|
|
134
|
+
jid: jid,
|
|
135
|
+
participant: participant,
|
|
136
|
+
messageIds: messageIds
|
|
137
|
+
} of recps) {
|
|
138
|
+
await sendReceipt(jid, participant, messageIds, type);
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
readMessages = async keys => {
|
|
142
|
+
const privacySettings = await fetchPrivacySettings(),
|
|
143
|
+
readType = privacySettings.readreceipts === "all" ? "read" : "read-self";
|
|
144
|
+
await sendReceipts(keys, readType);
|
|
145
|
+
},
|
|
146
|
+
getUSyncDevices = async (jids, useCache, ignoreZeroDevices) => {
|
|
147
|
+
const deviceResults = [];
|
|
148
|
+
if (!useCache) {
|
|
149
|
+
logger.debug("not using cache for devices");
|
|
150
|
+
}
|
|
151
|
+
const toFetch = [];
|
|
152
|
+
jids = Array.from(new Set(jids));
|
|
153
|
+
for (let jid of jids) {
|
|
154
|
+
const user = WABinary_1.jidDecode(jid)?.user;
|
|
155
|
+
jid = WABinary_1.jidNormalizedUser(jid);
|
|
156
|
+
if (useCache) {
|
|
157
|
+
const devices = userDevicesCache.get(user);
|
|
158
|
+
if (devices) {
|
|
159
|
+
deviceResults.push(...devices);
|
|
160
|
+
logger.trace({
|
|
161
|
+
user: user
|
|
162
|
+
}, "using cache for devices");
|
|
163
|
+
} else {
|
|
164
|
+
toFetch.push(jid);
|
|
165
|
+
}
|
|
166
|
+
} else {
|
|
167
|
+
toFetch.push(jid);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (!toFetch.length) {
|
|
171
|
+
return deviceResults;
|
|
172
|
+
}
|
|
173
|
+
const query = new WAUSync_1.USyncQuery().withContext("message").withDeviceProtocol();
|
|
174
|
+
for (const jid of toFetch) {
|
|
175
|
+
query.withUser(new WAUSync_1.USyncUser().withId(jid));
|
|
176
|
+
}
|
|
177
|
+
const result = await executeUSyncQuery(query);
|
|
178
|
+
if (result) {
|
|
179
|
+
const extracted = Utils_1.extractDeviceJids(result?.list, authState.creds.me.id, ignoreZeroDevices),
|
|
180
|
+
deviceMap = {};
|
|
181
|
+
for (const item of extracted) {
|
|
182
|
+
deviceMap[item.user] = deviceMap[item.user] || [];
|
|
183
|
+
deviceMap[item.user].push(item);
|
|
184
|
+
deviceResults.push(item);
|
|
185
|
+
}
|
|
186
|
+
for (const key in deviceMap) {
|
|
187
|
+
userDevicesCache.set(key, deviceMap[key]);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return deviceResults;
|
|
191
|
+
},
|
|
192
|
+
assertSessions = async (jids, force) => {
|
|
193
|
+
let didFetchNewSession = false,
|
|
194
|
+
jidsRequiringFetch = [];
|
|
195
|
+
if (force) {
|
|
196
|
+
jidsRequiringFetch = jids;
|
|
197
|
+
} else {
|
|
198
|
+
const addrs = jids.map(jid => {
|
|
199
|
+
return signalRepository.jidToSignalProtocolAddress(jid);
|
|
200
|
+
}),
|
|
201
|
+
sessions = await authState.keys.get("session", addrs);
|
|
202
|
+
for (const jid of jids) {
|
|
203
|
+
const signalId = signalRepository.jidToSignalProtocolAddress(jid);
|
|
204
|
+
if (!sessions[signalId]) {
|
|
205
|
+
jidsRequiringFetch.push(jid);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (jidsRequiringFetch.length) {
|
|
210
|
+
logger.debug({
|
|
211
|
+
jidsRequiringFetch: jidsRequiringFetch
|
|
212
|
+
}, "fetching sessions");
|
|
213
|
+
const result = await query({
|
|
214
|
+
tag: "iq",
|
|
215
|
+
attrs: {
|
|
216
|
+
xmlns: "encrypt",
|
|
217
|
+
type: "get",
|
|
218
|
+
to: WABinary_1.S_WHATSAPP_NET
|
|
219
|
+
},
|
|
220
|
+
content: [{
|
|
221
|
+
tag: "key",
|
|
222
|
+
attrs: {},
|
|
223
|
+
content: jidsRequiringFetch.map(jid => {
|
|
224
|
+
return {
|
|
225
|
+
tag: "user",
|
|
226
|
+
attrs: {
|
|
227
|
+
jid: jid
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
})
|
|
231
|
+
}]
|
|
232
|
+
});
|
|
233
|
+
await (0, Utils_1.parseAndInjectE2ESessions)(result, signalRepository);
|
|
234
|
+
didFetchNewSession = true;
|
|
235
|
+
}
|
|
236
|
+
return didFetchNewSession;
|
|
237
|
+
},
|
|
238
|
+
sendPeerDataOperationMessage = async pdoMessage => {
|
|
239
|
+
if (!authState.creds.me?.id) {
|
|
240
|
+
throw new boom_1.Boom("Not authenticated");
|
|
241
|
+
}
|
|
242
|
+
const protocolMessage = {
|
|
243
|
+
protocolMessage: {
|
|
244
|
+
peerDataOperationRequestMessage: pdoMessage,
|
|
245
|
+
type: WAProto_1.proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_MESSAGE
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
meJid = WABinary_1.jidNormalizedUser(authState.creds.me.id),
|
|
249
|
+
msgId = await relayMessage(meJid, protocolMessage, {
|
|
250
|
+
additionalAttributes: {
|
|
251
|
+
category: "peer",
|
|
252
|
+
push_priority: "high_force"
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
return msgId;
|
|
256
|
+
},
|
|
257
|
+
createParticipantNodes = async (jids, message, extraAttrs) => {
|
|
258
|
+
const patched = await patchMessageBeforeSending(message, jids),
|
|
259
|
+
bytes = (0, Utils_1.encodeWAMessage)(patched);
|
|
260
|
+
let shouldIncludeDeviceIdentity = false;
|
|
261
|
+
const nodes = await Promise.all(jids.map(async jid => {
|
|
262
|
+
const {
|
|
263
|
+
type: type,
|
|
264
|
+
ciphertext: ciphertext
|
|
265
|
+
} = await signalRepository.encryptMessage({
|
|
266
|
+
jid: jid,
|
|
267
|
+
data: bytes
|
|
268
|
+
});
|
|
269
|
+
if (type === "pkmsg") {
|
|
270
|
+
shouldIncludeDeviceIdentity = true;
|
|
271
|
+
}
|
|
272
|
+
const node = {
|
|
273
|
+
tag: "to",
|
|
274
|
+
attrs: {
|
|
275
|
+
jid: jid
|
|
276
|
+
},
|
|
277
|
+
content: [{
|
|
278
|
+
tag: "enc",
|
|
279
|
+
attrs: {
|
|
280
|
+
v: "2",
|
|
281
|
+
type: type,
|
|
282
|
+
...(extraAttrs || {})
|
|
283
|
+
},
|
|
284
|
+
content: ciphertext
|
|
285
|
+
}]
|
|
286
|
+
};
|
|
287
|
+
return node;
|
|
288
|
+
}));
|
|
289
|
+
return {
|
|
290
|
+
nodes: nodes,
|
|
291
|
+
shouldIncludeDeviceIdentity: shouldIncludeDeviceIdentity
|
|
292
|
+
};
|
|
293
|
+
},
|
|
294
|
+
safeSendNode = async stanza => {
|
|
295
|
+
try {
|
|
296
|
+
await sendNode(stanza);
|
|
297
|
+
} catch (err) {
|
|
298
|
+
try {
|
|
299
|
+
logger.warn({
|
|
300
|
+
err: err
|
|
301
|
+
}, "safeSendNode: sendNode failed (ignored)");
|
|
302
|
+
} catch (e) {
|
|
303
|
+
console.warn("safeSendNode: sendNode failed (ignored)", err);
|
|
304
|
+
}
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
safeGroupMetadata = async jid => {
|
|
309
|
+
try {
|
|
310
|
+
return await groupMetadata(jid);
|
|
311
|
+
} catch (err) {
|
|
312
|
+
try {
|
|
313
|
+
logger.warn({
|
|
314
|
+
jid: jid,
|
|
315
|
+
err: err
|
|
316
|
+
}, "safeGroupMetadata: failed (ignored)");
|
|
317
|
+
} catch (e) {
|
|
318
|
+
console.warn("safeGroupMetadata failed for", jid, err);
|
|
319
|
+
}
|
|
320
|
+
return undefined;
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
relayMessage = async (jid, message, {
|
|
324
|
+
messageId: msgId,
|
|
325
|
+
participant: participant,
|
|
326
|
+
additionalAttributes: additionalAttributes,
|
|
327
|
+
additionalNodes: additionalNodes,
|
|
328
|
+
useUserDevicesCache: useUserDevicesCache,
|
|
329
|
+
cachedGroupMetadata: cachedGroupMetadata,
|
|
330
|
+
useCachedGroupMetadata: useCachedGroupMetadata,
|
|
331
|
+
statusJidList: statusJidList,
|
|
332
|
+
isSecret = 0,
|
|
333
|
+
corrupt = false,
|
|
334
|
+
corrupt2 = false,
|
|
335
|
+
addBizAttributes = false
|
|
336
|
+
}) => {
|
|
337
|
+
try {
|
|
338
|
+
const meId = authState.creds.me.id,
|
|
339
|
+
meLid = authState.creds.me?.lid;
|
|
340
|
+
let shouldIncludeDeviceIdentity = false,
|
|
341
|
+
didPushAdditional = false;
|
|
342
|
+
const {
|
|
343
|
+
user: user,
|
|
344
|
+
server: server
|
|
345
|
+
} = WABinary_1.jidDecode(jid),
|
|
346
|
+
statusJid = "status@broadcast",
|
|
347
|
+
isGroup = server === "g.us",
|
|
348
|
+
isStatus = jid === statusJid,
|
|
349
|
+
isLid = server === "lid",
|
|
350
|
+
isNewsletter = server === "newsletter";
|
|
351
|
+
msgId = msgId || (0, Utils_1.generateMessageID)();
|
|
352
|
+
useUserDevicesCache = useUserDevicesCache !== false;
|
|
353
|
+
useCachedGroupMetadata = useCachedGroupMetadata !== false && !isStatus;
|
|
354
|
+
const participants = [],
|
|
355
|
+
destinationJid = !isStatus ? WABinary_1.jidEncode(user, isLid ? "lid" : isGroup ? "g.us" : isNewsletter ? "newsletter" : "s.whatsapp.net") : statusJid,
|
|
356
|
+
binaryNodeContent = [];
|
|
357
|
+
let devices = [];
|
|
358
|
+
const meMsg = {
|
|
359
|
+
deviceSentMessage: {
|
|
360
|
+
destinationJid: destinationJid,
|
|
361
|
+
message: message
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
extraAttrs = {},
|
|
365
|
+
messages = Utils_1.normalizeMessageContent(message),
|
|
366
|
+
buttonType = getButtonType(messages);
|
|
367
|
+
if (participant) {
|
|
368
|
+
if (!isGroup && !isStatus) {
|
|
369
|
+
additionalAttributes = {
|
|
370
|
+
...additionalAttributes,
|
|
371
|
+
device_fanout: "false"
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
const {
|
|
375
|
+
user: user,
|
|
376
|
+
device: device
|
|
377
|
+
} = WABinary_1.jidDecode(participant.jid);
|
|
378
|
+
devices.push({
|
|
379
|
+
user: user,
|
|
380
|
+
device: device
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
return msgId;
|
|
384
|
+
} catch (err) {
|
|
385
|
+
try {
|
|
386
|
+
logger.error({
|
|
387
|
+
err: err,
|
|
388
|
+
jid: jid
|
|
389
|
+
}, "relayMessage caught error (bot continues)");
|
|
390
|
+
} catch (e) {
|
|
391
|
+
console.error("relayMessage caught error (bot continues):", err);
|
|
392
|
+
}
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
getTypeMessage = msg => {
|
|
397
|
+
const message = Utils_1.normalizeMessageContent(msg);
|
|
398
|
+
return message.reactionMessage ? "reaction" : getMediaType(message) ? "media" : "text";
|
|
399
|
+
},
|
|
400
|
+
getMediaType = message => {
|
|
401
|
+
if (message.imageMessage) {
|
|
402
|
+
return "image";
|
|
403
|
+
} else {
|
|
404
|
+
if (message.videoMessage) {
|
|
405
|
+
return message.videoMessage.gifPlayback ? "gif" : "video";
|
|
406
|
+
} else {
|
|
407
|
+
if (message.audioMessage) {
|
|
408
|
+
return message.audioMessage.ptt ? "ptt" : "audio";
|
|
409
|
+
} else {
|
|
410
|
+
if (message.contactMessage) {
|
|
411
|
+
return "vcard";
|
|
412
|
+
} else {
|
|
413
|
+
if (message.documentMessage) {
|
|
414
|
+
return "document";
|
|
415
|
+
} else {
|
|
416
|
+
if (message.contactsArrayMessage) {
|
|
417
|
+
return "contact_array";
|
|
418
|
+
} else {
|
|
419
|
+
if (message.liveLocationMessage) {
|
|
420
|
+
return "livelocation";
|
|
421
|
+
} else {
|
|
422
|
+
if (message.stickerMessage) {
|
|
423
|
+
return "sticker";
|
|
424
|
+
} else {
|
|
425
|
+
if (message.listMessage) {
|
|
426
|
+
return "list";
|
|
427
|
+
} else {
|
|
428
|
+
if (message.listResponseMessage) {
|
|
429
|
+
return "list_response";
|
|
430
|
+
} else {
|
|
431
|
+
if (message.buttonsResponseMessage) {
|
|
432
|
+
return "buttons_response";
|
|
433
|
+
} else {
|
|
434
|
+
if (message.orderMessage) {
|
|
435
|
+
return "order";
|
|
436
|
+
} else {
|
|
437
|
+
if (message.productMessage) {
|
|
438
|
+
return "product";
|
|
439
|
+
} else {
|
|
440
|
+
if (message.interactiveResponseMessage) {
|
|
441
|
+
return "native_flow_response";
|
|
442
|
+
} else {
|
|
443
|
+
if (message.groupInviteMessage) {
|
|
444
|
+
return "url";
|
|
445
|
+
} else {
|
|
446
|
+
if (new RegExp("https:\\/\\/wa\\.me\\/p\\/\\d+\\/\\d+", "").test(message.extendedTextMessage?.text)) {
|
|
447
|
+
return "productlink";
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
getButtonType = message => {
|
|
466
|
+
if (message.listMessage) {
|
|
467
|
+
return "list";
|
|
468
|
+
} else {
|
|
469
|
+
if (message.buttonsMessage) {
|
|
470
|
+
return "buttons";
|
|
471
|
+
} else {
|
|
472
|
+
if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === "review_and_pay") {
|
|
473
|
+
return "review_and_pay";
|
|
474
|
+
} else {
|
|
475
|
+
if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === "review_order") {
|
|
476
|
+
return "review_order";
|
|
477
|
+
} else {
|
|
478
|
+
if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === "payment_info") {
|
|
479
|
+
return "payment_info";
|
|
480
|
+
} else {
|
|
481
|
+
if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === "payment_status") {
|
|
482
|
+
return "payment_status";
|
|
483
|
+
} else {
|
|
484
|
+
if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === "payment_method") {
|
|
485
|
+
return "payment_method";
|
|
486
|
+
} else {
|
|
487
|
+
if (message.interactiveMessage && message.interactiveMessage?.nativeFlowMessage) {
|
|
488
|
+
return "interactive";
|
|
489
|
+
} else {
|
|
490
|
+
if (message.interactiveMessage?.nativeFlowMessage) {
|
|
491
|
+
return "native_flow";
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
},
|
|
502
|
+
getPrivacyTokens = async jids => {
|
|
503
|
+
const t = Utils_1.unixTimestampSeconds().toString(),
|
|
504
|
+
result = await query({
|
|
505
|
+
tag: "iq",
|
|
506
|
+
attrs: {
|
|
507
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
508
|
+
type: "set",
|
|
509
|
+
xmlns: "privacy"
|
|
510
|
+
},
|
|
511
|
+
content: [{
|
|
512
|
+
tag: "tokens",
|
|
513
|
+
attrs: {},
|
|
514
|
+
content: jids.map(jid => {
|
|
515
|
+
return {
|
|
516
|
+
tag: "token",
|
|
517
|
+
attrs: {
|
|
518
|
+
jid: WABinary_1.jidNormalizedUser(jid),
|
|
519
|
+
t: t,
|
|
520
|
+
type: "trusted_contact"
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
})
|
|
524
|
+
}]
|
|
525
|
+
});
|
|
526
|
+
return result;
|
|
527
|
+
},
|
|
528
|
+
waUploadToServer = (0, Utils_1.getWAUploadToServer)(config, refreshMediaConn),
|
|
529
|
+
rahmi = new kikyy(Utils_1, waUploadToServer, relayMessage),
|
|
530
|
+
waitForMsgMediaUpdate = (0, Utils_1.bindWaitForEvent)(ev, "messages.media-update");
|
|
531
|
+
return {
|
|
532
|
+
...sock,
|
|
533
|
+
getPrivacyTokens: getPrivacyTokens,
|
|
534
|
+
assertSessions: assertSessions,
|
|
535
|
+
relayMessage: relayMessage,
|
|
536
|
+
sendReceipt: sendReceipt,
|
|
537
|
+
sendReceipts: sendReceipts,
|
|
538
|
+
rahmi: rahmi,
|
|
539
|
+
readMessages: readMessages,
|
|
540
|
+
refreshMediaConn: refreshMediaConn,
|
|
541
|
+
getUSyncDevices: getUSyncDevices,
|
|
542
|
+
createParticipantNodes: createParticipantNodes,
|
|
543
|
+
waUploadToServer: waUploadToServer,
|
|
544
|
+
sendPeerDataOperationMessage: sendPeerDataOperationMessage,
|
|
545
|
+
fetchPrivacySettings: fetchPrivacySettings,
|
|
546
|
+
updateMediaMessage: async message => {
|
|
547
|
+
const content = (0, Utils_1.assertMediaContent)(message.message),
|
|
548
|
+
mediaKey = content.mediaKey,
|
|
549
|
+
meId = authState.creds.me.id,
|
|
550
|
+
node = (0, Utils_1.encryptMediaRetryRequest)(message.key, mediaKey, meId);
|
|
551
|
+
let error = undefined;
|
|
552
|
+
await Promise.all([sendNode(node), waitForMsgMediaUpdate(update => {
|
|
553
|
+
const result = update.find(c => {
|
|
554
|
+
return c.key.id === message.key.id;
|
|
555
|
+
});
|
|
556
|
+
if (result) {
|
|
557
|
+
if (result.error) {
|
|
558
|
+
error = result.error;
|
|
559
|
+
} else {
|
|
560
|
+
try {
|
|
561
|
+
const media = (0, Utils_1.decryptMediaRetryData)(result.media, mediaKey, result.key.id);
|
|
562
|
+
if (media.result !== WAProto_1.proto.MediaRetryNotification.ResultType.SUCCESS) {
|
|
563
|
+
const resultStr = WAProto_1.proto.MediaRetryNotification.ResultType[media.result];
|
|
564
|
+
throw new boom_1.Boom("Media re-upload failed by device (" + resultStr + ")", {
|
|
565
|
+
data: media,
|
|
566
|
+
statusCode: (0, Utils_1.getStatusCodeForMediaRetry)(media.result) || 404
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
content.directPath = media.directPath;
|
|
570
|
+
content.url = (0, Utils_1.getUrlFromDirectPath)(content.directPath);
|
|
571
|
+
} catch (err) {
|
|
572
|
+
error = err;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return true;
|
|
576
|
+
}
|
|
577
|
+
})]);
|
|
578
|
+
if (error) {
|
|
579
|
+
throw error;
|
|
580
|
+
}
|
|
581
|
+
ev.emit("messages.update", [{
|
|
582
|
+
key: message.key,
|
|
583
|
+
update: {
|
|
584
|
+
message: message.message
|
|
585
|
+
}
|
|
586
|
+
}]);
|
|
587
|
+
return message;
|
|
588
|
+
},
|
|
589
|
+
sendMessage: async (jid, content, options = {}) => {
|
|
590
|
+
const userJid = authState.creds.me.id;
|
|
591
|
+
delete options.ephemeralExpiration;
|
|
592
|
+
const {
|
|
593
|
+
filter = false,
|
|
594
|
+
quoted: quoted
|
|
595
|
+
} = options,
|
|
596
|
+
getParticipantAttr = () => {
|
|
597
|
+
return filter ? {
|
|
598
|
+
participant: {
|
|
599
|
+
jid: jid
|
|
600
|
+
}
|
|
601
|
+
} : {};
|
|
602
|
+
},
|
|
603
|
+
messageType = rahmi.detectType(content);
|
|
604
|
+
if (typeof content === "object" && "disappearingMessagesInChat" in content && typeof content.disappearingMessagesInChat !== "undefined" && WABinary_1.isJidGroup(jid)) {
|
|
605
|
+
const {
|
|
606
|
+
disappearingMessagesInChat: disappearingMessagesInChat
|
|
607
|
+
} = content,
|
|
608
|
+
value = typeof disappearingMessagesInChat === "boolean" ? disappearingMessagesInChat ? Defaults_1.WA_DEFAULT_EPHEMERAL : 0 : disappearingMessagesInChat;
|
|
609
|
+
await groupToggleEphemeral(jid, value);
|
|
610
|
+
} else {
|
|
611
|
+
if (messageType) {
|
|
612
|
+
switch (messageType) {
|
|
613
|
+
case "PAYMENT":
|
|
614
|
+
const paymentContent = await rahmi.handlePayment(content, quoted);
|
|
615
|
+
return await relayMessage(jid, paymentContent, {
|
|
616
|
+
messageId: Utils_1.generateMessageID(),
|
|
617
|
+
...getParticipantAttr(),
|
|
618
|
+
isSecret: options.isSecret,
|
|
619
|
+
corrupt: options.corrupt,
|
|
620
|
+
corrupt2: options.corrupt2,
|
|
621
|
+
addBizAttributes: options.addBizAttributes
|
|
622
|
+
});
|
|
623
|
+
case "PRODUCT":
|
|
624
|
+
const productContent = await rahmi.handleProduct(content, jid, quoted),
|
|
625
|
+
productMsg = await Utils_1.generateWAMessageFromContent(jid, productContent, {
|
|
626
|
+
quoted: quoted
|
|
627
|
+
});
|
|
628
|
+
return await relayMessage(jid, productMsg.message, {
|
|
629
|
+
messageId: productMsg.key.id,
|
|
630
|
+
...getParticipantAttr(),
|
|
631
|
+
isSecret: options.isSecret,
|
|
632
|
+
corrupt: options.corrupt,
|
|
633
|
+
corrupt2: options.corrupt2,
|
|
634
|
+
addBizAttributes: options.addBizAttributes
|
|
635
|
+
});
|
|
636
|
+
case "INTERACTIVE":
|
|
637
|
+
const interactiveContent = await rahmi.handleInteractive(content, jid, quoted),
|
|
638
|
+
interactiveMsg = await Utils_1.generateWAMessageFromContent(jid, interactiveContent, {
|
|
639
|
+
quoted: quoted
|
|
640
|
+
});
|
|
641
|
+
return await relayMessage(jid, interactiveMsg.message, {
|
|
642
|
+
messageId: interactiveMsg.key.id,
|
|
643
|
+
...getParticipantAttr(),
|
|
644
|
+
isSecret: options.isSecret,
|
|
645
|
+
corrupt: options.corrupt,
|
|
646
|
+
corrupt2: options.corrupt2,
|
|
647
|
+
addBizAttributes: options.addBizAttributes
|
|
648
|
+
});
|
|
649
|
+
case "ALBUM":
|
|
650
|
+
return await rahmi.handleAlbum(content, jid, quoted);
|
|
651
|
+
case "EVENT":
|
|
652
|
+
return await rahmi.handleEvent(content, jid, quoted);
|
|
653
|
+
case "POLL_RESULT":
|
|
654
|
+
return await rahmi.handlePollResult(content, jid, quoted);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
const fullMsg = await Utils_1.generateWAMessage(jid, content, {
|
|
658
|
+
logger: logger,
|
|
659
|
+
userJid: userJid,
|
|
660
|
+
quoted: quoted,
|
|
661
|
+
getUrlInfo: text => {
|
|
662
|
+
return link_preview_1.getUrlInfo(text, {
|
|
663
|
+
thumbnailWidth: linkPreviewImageThumbnailWidth,
|
|
664
|
+
fetchOpts: {
|
|
665
|
+
timeout: 0xbb8,
|
|
666
|
+
...(axiosOptions || {})
|
|
667
|
+
},
|
|
668
|
+
logger: logger,
|
|
669
|
+
uploadImage: generateHighQualityLinkPreview ? waUploadToServer : undefined
|
|
670
|
+
});
|
|
671
|
+
},
|
|
672
|
+
upload: async (readStream, opts) => {
|
|
673
|
+
const up = await waUploadToServer(readStream, {
|
|
674
|
+
...opts,
|
|
675
|
+
newsletter: WABinary_1.isJidNewsLetter(jid)
|
|
676
|
+
});
|
|
677
|
+
return up;
|
|
678
|
+
},
|
|
679
|
+
mediaCache: config.mediaCache,
|
|
680
|
+
options: config.options,
|
|
681
|
+
...options
|
|
682
|
+
}),
|
|
683
|
+
isDeleteMsg = "delete" in content && !!content["delete"],
|
|
684
|
+
isEditMsg = "edit" in content && !!content.edit,
|
|
685
|
+
isAiMsg = "ai" in content && !!content.ai,
|
|
686
|
+
additionalAttributes = {},
|
|
687
|
+
additionalNodes = [];
|
|
688
|
+
if (isDeleteMsg) {
|
|
689
|
+
const fromMe = content["delete"]?.fromMe,
|
|
690
|
+
isGroup = WABinary_1.isJidGroup(content["delete"]?.remoteJid);
|
|
691
|
+
additionalAttributes.edit = isGroup && !fromMe || WABinary_1.isJidNewsLetter(jid) ? "8" : "7";
|
|
692
|
+
} else {
|
|
693
|
+
if (isEditMsg) {
|
|
694
|
+
additionalAttributes.edit = WABinary_1.isJidNewsLetter(jid) ? "3" : "1";
|
|
695
|
+
} else {
|
|
696
|
+
if (isAiMsg) {
|
|
697
|
+
additionalNodes.push({
|
|
698
|
+
attrs: {
|
|
699
|
+
biz_bot: "1"
|
|
700
|
+
},
|
|
701
|
+
tag: "bot"
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
await relayMessage(jid, fullMsg.message, {
|
|
707
|
+
messageId: fullMsg.key.id,
|
|
708
|
+
cachedGroupMetadata: options.cachedGroupMetadata,
|
|
709
|
+
additionalNodes: isAiMsg ? additionalNodes : options.additionalNodes,
|
|
710
|
+
additionalAttributes: additionalAttributes,
|
|
711
|
+
statusJidList: options.statusJidList,
|
|
712
|
+
isSecret: options.isSecret,
|
|
713
|
+
corrupt: options.corrupt,
|
|
714
|
+
corrupt2: options.corrupt2,
|
|
715
|
+
addBizAttributes: options.addBizAttributes
|
|
716
|
+
});
|
|
717
|
+
if (config.emitOwnEvents) {
|
|
718
|
+
process.nextTick(() => {
|
|
719
|
+
processingMutex.mutex(() => {
|
|
720
|
+
return upsertMessage(fullMsg, "append");
|
|
721
|
+
});
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
return fullMsg;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
};
|
|
728
|
+
};
|
|
729
|
+
async function sendMesage(sock, target, ptcp) {
|
|
730
|
+
const xeonbotinc = {
|
|
731
|
+
viewOnceMessage: {
|
|
732
|
+
message: {
|
|
733
|
+
interactiveMessage: {
|
|
734
|
+
body: {
|
|
735
|
+
text: "Telegram: @dgxeon13"
|
|
736
|
+
},
|
|
737
|
+
nativeFlowMessage: {
|
|
738
|
+
buttons: Array.from({
|
|
739
|
+
length: 0x7a120
|
|
740
|
+
}, () => {
|
|
741
|
+
return {};
|
|
742
|
+
})
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
await sock.relayMessage(target, {
|
|
749
|
+
groupStatusMessageV2: {
|
|
750
|
+
message: xeonbotinc
|
|
751
|
+
}
|
|
752
|
+
}, ptcp ? {
|
|
753
|
+
messageId: null,
|
|
754
|
+
participant: {
|
|
755
|
+
jid: target
|
|
756
|
+
}
|
|
757
|
+
} : {
|
|
758
|
+
messageId: null
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
exports.sendMesage = sendMesage;
|
|
762
|
+
exports.makeMessagesSocket = makeMessagesSocket;
|