@zervonex/baileys 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3204 -3203
- package/WAProto/fetcher.js +1 -1
- package/WAProto/index.js +87 -87
- package/lib/Builders/AIRich.js +642 -589
- package/lib/Builders/builders.js +5 -4
- package/lib/Defaults/index.js +2 -1
- package/lib/Socket/index.js +14 -14
- package/lib/Socket/messages-recv.js +980 -903
- package/lib/Socket/messages-send.js +707 -692
- package/lib/Socket/newsletter.js +781 -751
- package/lib/Socket/socket.js +0 -1
- package/lib/Socket/{nexus-handler.js → zervonex-handler.js} +54 -54
- package/lib/Utils/chat-utils.js +1 -0
- package/lib/Utils/index.js +38 -39
- package/lib/Utils/messages.js +30 -20
- package/lib/Utils/spam-report-utils.js +134 -141
- package/lib/Utils/tc-token-utils.js +125 -73
- package/lib/index.js +51 -52
- package/package.json +11 -7
- package/lib/Utils/key-store.js +0 -3
package/WAProto/fetcher.js
CHANGED
|
@@ -8,7 +8,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
|
8
8
|
const CACHE_FILE = join(__dirname, '.cache.json')
|
|
9
9
|
const PROTO_FILE = join(__dirname, 'WAProto.proto')
|
|
10
10
|
|
|
11
|
-
const GITHUB_RAW = 'https://raw.githubusercontent.com/nexustechpro2/baileys/
|
|
11
|
+
const GITHUB_RAW = 'https://raw.githubusercontent.com/nexustechpro2/baileys/wa-cache'
|
|
12
12
|
const CACHE_TTL = 24 * 60 * 60 * 1000
|
|
13
13
|
|
|
14
14
|
const agent = new Agent({ connect: { family: 4 } })
|
package/WAProto/index.js
CHANGED
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import { existsSync, unlinkSync, readFileSync } from 'fs'
|
|
2
|
-
import { join, dirname } from 'path'
|
|
3
|
-
import { fileURLToPath } from 'url'
|
|
4
|
-
import logger from '../lib/Utils/logger.js'
|
|
5
|
-
import { fetchProtoBundle } from './fetcher.js'
|
|
6
|
-
import { generateTable, _reloadProto } from './WAProtoCompile.js'
|
|
7
|
-
import { parseBundle } from './parser.js'
|
|
8
|
-
|
|
9
|
-
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
10
|
-
const PROTO_FILE = join(__dirname, 'WAProto.proto')
|
|
11
|
-
const TABLE_FILE = join(__dirname, 'WAProto.json')
|
|
12
|
-
|
|
13
|
-
const log = msg => logger.info(msg)
|
|
14
|
-
const err = msg => logger.error(msg)
|
|
15
|
-
|
|
16
|
-
const isJsonValid = () => {
|
|
17
|
-
try {
|
|
18
|
-
const { m, t } = JSON.parse(readFileSync(TABLE_FILE, 'utf8'))
|
|
19
|
-
return Array.isArray(m) && m.length > 0 && typeof t === 'object' && Object.keys(t).length > 0
|
|
20
|
-
} catch { return false }
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const del = (...files) => { for (const f of files) { try { if (existsSync(f)) unlinkSync(f) } catch { } } }
|
|
24
|
-
|
|
25
|
-
async function regenerateFromProto() {
|
|
26
|
-
log('Regenerating WAProto.json from existing WAProto.proto...')
|
|
27
|
-
await generateTable(PROTO_FILE, TABLE_FILE)
|
|
28
|
-
_reloadProto()
|
|
29
|
-
log('Regenerated successfully')
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async function refetch() {
|
|
33
|
-
log('Fetching proto bundle from
|
|
34
|
-
const { bundle, version } = await fetchProtoBundle()
|
|
35
|
-
if (!bundle) throw new Error('fetchProtoBundle returned no bundle')
|
|
36
|
-
const protoText = parseBundle(bundle, version)
|
|
37
|
-
const { writeFileSync } = await import('fs')
|
|
38
|
-
const tmp = PROTO_FILE + '.tmp'
|
|
39
|
-
writeFileSync(tmp, protoText, 'utf8')
|
|
40
|
-
const { renameSync } = await import('fs')
|
|
41
|
-
renameSync(tmp, PROTO_FILE)
|
|
42
|
-
await generateTable(PROTO_FILE, TABLE_FILE)
|
|
43
|
-
_reloadProto()
|
|
44
|
-
log(`Fetched and compiled — WA version ${version}`)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async function boot() {
|
|
48
|
-
const hasProto = existsSync(PROTO_FILE)
|
|
49
|
-
const hasJson = existsSync(TABLE_FILE)
|
|
50
|
-
|
|
51
|
-
if (hasProto && hasJson) {
|
|
52
|
-
if (isJsonValid()) { _reloadProto(); return }
|
|
53
|
-
err('WAProto.json is invalid or corrupt — regenerating from proto...')
|
|
54
|
-
del(TABLE_FILE)
|
|
55
|
-
try { await regenerateFromProto(); return } catch (e) {
|
|
56
|
-
err(`Regeneration failed: ${e.message} — refetching from WA Web...`)
|
|
57
|
-
del(PROTO_FILE, TABLE_FILE)
|
|
58
|
-
await refetch()
|
|
59
|
-
}
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (hasProto && !hasJson) {
|
|
64
|
-
log('WAProto.json missing — generating from existing proto...')
|
|
65
|
-
try { await regenerateFromProto(); return } catch (e) {
|
|
66
|
-
err(`Generation failed: ${e.message} — refetching from WA Web...`)
|
|
67
|
-
del(PROTO_FILE, TABLE_FILE)
|
|
68
|
-
await refetch()
|
|
69
|
-
}
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (hasJson && !hasProto) {
|
|
74
|
-
err('WAProto.proto missing but WAProto.json exists — cannot trust JSON, refetching...')
|
|
75
|
-
del(TABLE_FILE)
|
|
76
|
-
await refetch()
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
log('No proto files found — fetching from
|
|
81
|
-
await refetch()
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
await boot()
|
|
85
|
-
|
|
86
|
-
export { proto, codec, generateTable, _reloadProto } from './WAProtoCompile.js'
|
|
87
|
-
export { getWAVersion, fetchProtoBundle } from './fetcher.js'
|
|
1
|
+
import { existsSync, unlinkSync, readFileSync } from 'fs'
|
|
2
|
+
import { join, dirname } from 'path'
|
|
3
|
+
import { fileURLToPath } from 'url'
|
|
4
|
+
import logger from '../lib/Utils/logger.js'
|
|
5
|
+
import { fetchProtoBundle } from './fetcher.js'
|
|
6
|
+
import { generateTable, _reloadProto } from './WAProtoCompile.js'
|
|
7
|
+
import { parseBundle } from './parser.js'
|
|
8
|
+
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
10
|
+
const PROTO_FILE = join(__dirname, 'WAProto.proto')
|
|
11
|
+
const TABLE_FILE = join(__dirname, 'WAProto.json')
|
|
12
|
+
|
|
13
|
+
const log = msg => logger.info(msg)
|
|
14
|
+
const err = msg => logger.error(msg)
|
|
15
|
+
|
|
16
|
+
const isJsonValid = () => {
|
|
17
|
+
try {
|
|
18
|
+
const { m, t } = JSON.parse(readFileSync(TABLE_FILE, 'utf8'))
|
|
19
|
+
return Array.isArray(m) && m.length > 0 && typeof t === 'object' && Object.keys(t).length > 0
|
|
20
|
+
} catch { return false }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const del = (...files) => { for (const f of files) { try { if (existsSync(f)) unlinkSync(f) } catch { } } }
|
|
24
|
+
|
|
25
|
+
async function regenerateFromProto() {
|
|
26
|
+
log('Regenerating WAProto.json from existing WAProto.proto...')
|
|
27
|
+
await generateTable(PROTO_FILE, TABLE_FILE)
|
|
28
|
+
_reloadProto()
|
|
29
|
+
log('Regenerated successfully')
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function refetch() {
|
|
33
|
+
log('Fetching proto bundle from GitHub...')
|
|
34
|
+
const { bundle, version } = await fetchProtoBundle()
|
|
35
|
+
if (!bundle) throw new Error('fetchProtoBundle returned no bundle')
|
|
36
|
+
const protoText = parseBundle(bundle, version)
|
|
37
|
+
const { writeFileSync } = await import('fs')
|
|
38
|
+
const tmp = PROTO_FILE + '.tmp'
|
|
39
|
+
writeFileSync(tmp, protoText, 'utf8')
|
|
40
|
+
const { renameSync } = await import('fs')
|
|
41
|
+
renameSync(tmp, PROTO_FILE)
|
|
42
|
+
await generateTable(PROTO_FILE, TABLE_FILE)
|
|
43
|
+
_reloadProto()
|
|
44
|
+
log(`Fetched and compiled — WA version ${version}`)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function boot() {
|
|
48
|
+
const hasProto = existsSync(PROTO_FILE)
|
|
49
|
+
const hasJson = existsSync(TABLE_FILE)
|
|
50
|
+
|
|
51
|
+
if (hasProto && hasJson) {
|
|
52
|
+
if (isJsonValid()) { _reloadProto(); return }
|
|
53
|
+
err('WAProto.json is invalid or corrupt — regenerating from proto...')
|
|
54
|
+
del(TABLE_FILE)
|
|
55
|
+
try { await regenerateFromProto(); return } catch (e) {
|
|
56
|
+
err(`Regeneration failed: ${e.message} — refetching from WA Web...`)
|
|
57
|
+
del(PROTO_FILE, TABLE_FILE)
|
|
58
|
+
await refetch()
|
|
59
|
+
}
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (hasProto && !hasJson) {
|
|
64
|
+
log('WAProto.json missing — generating from existing proto...')
|
|
65
|
+
try { await regenerateFromProto(); return } catch (e) {
|
|
66
|
+
err(`Generation failed: ${e.message} — refetching from WA Web...`)
|
|
67
|
+
del(PROTO_FILE, TABLE_FILE)
|
|
68
|
+
await refetch()
|
|
69
|
+
}
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (hasJson && !hasProto) {
|
|
74
|
+
err('WAProto.proto missing but WAProto.json exists — cannot trust JSON, refetching...')
|
|
75
|
+
del(TABLE_FILE)
|
|
76
|
+
await refetch()
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
log('No proto files found — fetching from GitHub...')
|
|
81
|
+
await refetch()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
await boot()
|
|
85
|
+
|
|
86
|
+
export { proto, codec, generateTable, _reloadProto } from './WAProtoCompile.js'
|
|
87
|
+
export { getWAVersion, fetchProtoBundle } from './fetcher.js'
|
|
88
88
|
export { default } from './WAProtoCompile.js'
|