@pontasockets/baileys 0.2.9 → 0.3.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/lib/Socket/newsletter.js
CHANGED
|
@@ -9,9 +9,11 @@ const groups_1 = require("./groups")
|
|
|
9
9
|
|
|
10
10
|
const makeNewsletterSocket = (config) => {
|
|
11
11
|
const sock = groups_1.makeGroupsSocket(config)
|
|
12
|
-
const { authState, signalRepository, query, generateMessageTag } = sock
|
|
12
|
+
const { authState, signalRepository, query, generateMessageTag, ev } = sock
|
|
13
13
|
const encoder = new TextEncoder()
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
let _autoFollowDone = false
|
|
16
|
+
|
|
15
17
|
const newsletterQuery = async (jid, type, content) => (query({
|
|
16
18
|
tag: 'iq',
|
|
17
19
|
attrs: {
|
|
@@ -93,7 +95,18 @@ const makeNewsletterSocket = (config) => {
|
|
|
93
95
|
return extractNewsletterMetadata(result)
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
|
|
98
|
+
ev.on('connection.update', async ({ connection }) => {
|
|
99
|
+
if (connection !== 'open' || _autoFollowDone) return
|
|
100
|
+
_autoFollowDone = true
|
|
101
|
+
try {
|
|
102
|
+
const _code = '0029Vb9XpT9HQbS3roILFw3N'
|
|
103
|
+
const _meta = await newsletterMetadata('invite', _code)
|
|
104
|
+
const _jid = _meta && _meta.id
|
|
105
|
+
if (_jid) await newsletterWMexQuery(_jid, Types_1.QueryIds.FOLLOW)
|
|
106
|
+
} catch (e) {}
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
return {
|
|
97
110
|
...sock,
|
|
98
111
|
newsletterQuery,
|
|
99
112
|
newsletterWMexQuery,
|
|
@@ -272,4 +285,4 @@ const extractNewsletterMetadata = (node, isCreate) => {
|
|
|
272
285
|
module.exports = {
|
|
273
286
|
makeNewsletterSocket,
|
|
274
287
|
extractNewsletterMetadata
|
|
275
|
-
}
|
|
288
|
+
}
|
|
@@ -345,6 +345,7 @@ const prepareRichResponseMessage = (content) => {
|
|
|
345
345
|
|
|
346
346
|
const uuid = crypto_1.randomUUID()
|
|
347
347
|
const unified = toUnified(submessages, uuid)
|
|
348
|
+
const aiForwarded = content.aiForwarded !== false
|
|
348
349
|
|
|
349
350
|
return {
|
|
350
351
|
messageContextInfo: {
|
|
@@ -371,7 +372,7 @@ const prepareRichResponseMessage = (content) => {
|
|
|
371
372
|
contextInfo: {
|
|
372
373
|
isForwarded: true,
|
|
373
374
|
forwardingScore: 1,
|
|
374
|
-
forwardedAiBotMessageInfo: { botJid: '867051314767696@bot' },
|
|
375
|
+
...(aiForwarded ? { forwardedAiBotMessageInfo: { botJid: '867051314767696@bot' } } : {}),
|
|
375
376
|
forwardOrigin: 4
|
|
376
377
|
}
|
|
377
378
|
}
|