shin-yagami 2.0.4
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/WhatsApp/node.js +195 -0
- package/baileys/converter.js +92 -0
- package/baileys/database/database.json +6340 -0
- package/baileys/database/limit.json +14 -0
- package/baileys/database/premium.json +1 -0
- package/baileys/exif.js +98 -0
- package/baileys/function.js +416 -0
- package/case.js +2652 -0
- package/package.json +65 -0
- package/server/database.js +92 -0
- package/server/message.js +463 -0
- package/settings.js +57 -0
- package/tmp/no_name.pdf +0 -0
- package/tmp/sampah/A +0 -0
package/WhatsApp/node.js
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/*
|
|
2
|
+
!- Credits By Shin Yagami
|
|
3
|
+
https://wa.me/6289508017468
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
require('../settings')
|
|
7
|
+
const fs = require('fs')
|
|
8
|
+
const pino = require('pino')
|
|
9
|
+
const path = require('path')
|
|
10
|
+
const axios = require('axios')
|
|
11
|
+
const chalk = require('chalk')
|
|
12
|
+
const readline = require('readline')
|
|
13
|
+
const FileType = require('file-type')
|
|
14
|
+
const { exec } = require('child_process')
|
|
15
|
+
const { say } = require('cfonts')
|
|
16
|
+
const { Boom } = require('@hapi/boom')
|
|
17
|
+
|
|
18
|
+
console.log(chalk.yellow.bold("[ INFO ] : "), chalk.red.bold('Mencoba Terhubung . . . .'))
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
default: WAConnection,
|
|
22
|
+
generateWAMessageFromContent,
|
|
23
|
+
prepareWAMessageMedia,
|
|
24
|
+
useMultiFileAuthState,
|
|
25
|
+
Browsers,
|
|
26
|
+
DisconnectReason,
|
|
27
|
+
makeInMemoryStore,
|
|
28
|
+
makeCacheableSignalKeyStore,
|
|
29
|
+
fetchLatestWaWebVersion,
|
|
30
|
+
proto,
|
|
31
|
+
PHONENUMBER_MCC,
|
|
32
|
+
getAggregateVotesInPollMessage
|
|
33
|
+
} = require('@whiskeysockets/baileys')
|
|
34
|
+
|
|
35
|
+
const pairingCode = true
|
|
36
|
+
const SESSION_DIR = path.resolve(__dirname, '../session')
|
|
37
|
+
|
|
38
|
+
let isReconnecting = false
|
|
39
|
+
|
|
40
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
|
|
41
|
+
const question = (text) => new Promise(resolve => rl.question(text, resolve))
|
|
42
|
+
|
|
43
|
+
/* ===== DATABASE ===== */
|
|
44
|
+
const DataBase = require('../server/database')
|
|
45
|
+
const database = new DataBase()
|
|
46
|
+
|
|
47
|
+
;(async () => {
|
|
48
|
+
const loadData = await database.read()
|
|
49
|
+
if (loadData && Object.keys(loadData).length === 0) {
|
|
50
|
+
global.db = {
|
|
51
|
+
users: {},
|
|
52
|
+
groups: {},
|
|
53
|
+
database: {},
|
|
54
|
+
settings: {},
|
|
55
|
+
...(loadData || {})
|
|
56
|
+
}
|
|
57
|
+
await database.write(global.db)
|
|
58
|
+
} else {
|
|
59
|
+
global.db = loadData
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setInterval(async () => {
|
|
63
|
+
if (global.db) await database.write(global.db)
|
|
64
|
+
}, 3500)
|
|
65
|
+
})()
|
|
66
|
+
|
|
67
|
+
const { MessagesUpsert, Solving } = require('../server/message')
|
|
68
|
+
const { isUrl, generateMessageTag, getBuffer, getSizeMedia, fetchJson, sleep } =
|
|
69
|
+
require('../baileys/function')
|
|
70
|
+
|
|
71
|
+
/* ===== START BOT ===== */
|
|
72
|
+
async function startingBot() {
|
|
73
|
+
const store = makeInMemoryStore({
|
|
74
|
+
logger: pino().child({ level: 'silent', stream: 'store' })
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const { state, saveCreds } = await useMultiFileAuthState(SESSION_DIR)
|
|
78
|
+
|
|
79
|
+
const Sky = WAConnection({
|
|
80
|
+
version: (await fetchLatestWaWebVersion()).version,
|
|
81
|
+
browser: ['Ubuntu', 'Edge', '25.04'],
|
|
82
|
+
printQRInTerminal: !pairingCode,
|
|
83
|
+
logger: pino({ level: 'silent' }),
|
|
84
|
+
auth: state,
|
|
85
|
+
generateHighQualityLinkPreview: true,
|
|
86
|
+
getMessage: async (key) => {
|
|
87
|
+
if (store) {
|
|
88
|
+
const msg = await store.loadMessage(key.remoteJid, key.id)
|
|
89
|
+
return msg?.message
|
|
90
|
+
}
|
|
91
|
+
return { conversation: 'Shin Yagami' }
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
/* ===== PAIRING (FIX) ===== */
|
|
96
|
+
if (pairingCode && !fs.existsSync(path.join(SESSION_DIR, 'creds.json'))) {
|
|
97
|
+
const ipsrv = await axios.get("https://api.ipify.org/?format=json")
|
|
98
|
+
const regionsrv = await axios.get(`http://ip-api.com/json/${ipsrv.data.ip}`)
|
|
99
|
+
let phoneNumber = await question(
|
|
100
|
+
chalk.cyan.bold('\n[ ✓ ] Masukkan Nomor WhatsApp :\n# WhatsApp Number : ')
|
|
101
|
+
)
|
|
102
|
+
phoneNumber = phoneNumber.replace(/[^0-9]/g, '')
|
|
103
|
+
const customPairingCode = global.costumPairingCode;
|
|
104
|
+
let code = await Sky.requestPairingCode(phoneNumber.trim(), customPairingCode)
|
|
105
|
+
code = code.match(/.{1,4}/g).join(' - ')
|
|
106
|
+
|
|
107
|
+
console.log(
|
|
108
|
+
chalk.blue.bold(`
|
|
109
|
+
┌──────────────────────────────────────────────────────╮
|
|
110
|
+
│ 📱 Pairing Code Ready : ${phoneNumber}
|
|
111
|
+
│ 🚩 Asal Negara (SERVER) : ${regionsrv.data.country}
|
|
112
|
+
│ 💻 PLatform : ${regionsrv.data.as}
|
|
113
|
+
│──────────────────────────────────────────────────────
|
|
114
|
+
│ Kode Pairing : ${(code)}
|
|
115
|
+
│ Verifikasi Jika Pairing Dari ${regionsrv.data.country} ✅
|
|
116
|
+
└──────────────────────────────────────────────────────╯`));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
Sky.ev.on('creds.update', saveCreds)
|
|
120
|
+
|
|
121
|
+
/* ===== CONNECTION UPDATE (FIX LOST SESSION) ===== */
|
|
122
|
+
Sky.ev.on('connection.update', async (update) => {
|
|
123
|
+
const { connection, lastDisconnect } = update
|
|
124
|
+
|
|
125
|
+
if (connection === 'close') {
|
|
126
|
+
const reason = new Boom(lastDisconnect?.error)?.output?.statusCode
|
|
127
|
+
|
|
128
|
+
if (
|
|
129
|
+
reason !== DisconnectReason.loggedOut &&
|
|
130
|
+
reason !== DisconnectReason.badSession &&
|
|
131
|
+
!isReconnecting
|
|
132
|
+
) {
|
|
133
|
+
isReconnecting = true
|
|
134
|
+
console.log(chalk.yellow.bold('[ INFO ] : '), chalk.red.bold('Reconnect...'))
|
|
135
|
+
|
|
136
|
+
setTimeout(() => {
|
|
137
|
+
isReconnecting = false
|
|
138
|
+
startingBot()
|
|
139
|
+
}, 5000)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (reason === DisconnectReason.badSession || reason === DisconnectReason.loggedOut) {
|
|
143
|
+
console.log(chalk.red.bold('[ INFO ] : Session Rusak, Pairing Ulang'))
|
|
144
|
+
exec(`rm -rf ${SESSION_DIR}`)
|
|
145
|
+
process.exit(1)
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (connection === 'connecting') {
|
|
150
|
+
console.log(chalk.yellow.bold('[ INFO ] : '), chalk.white.bold('Memverifikasi Asal Request...'))
|
|
151
|
+
console.log(chalk.yellow.bold('[ INFO ] : '), chalk.white.bold('Menghubungkan...'))
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (connection === 'open') {
|
|
155
|
+
const qtext = {
|
|
156
|
+
"key": {
|
|
157
|
+
"participant": Sky.user.id.split(":")[0] + "@s.whatsapp.net",
|
|
158
|
+
"remoteJid": "status@broadcast",
|
|
159
|
+
"fromMe": false,
|
|
160
|
+
"id": "Halo"
|
|
161
|
+
},
|
|
162
|
+
"message": {
|
|
163
|
+
"locationMessage": {
|
|
164
|
+
"name": `*[ ! ] Notification ${global.namabot}*`,
|
|
165
|
+
"jpegThumbnail": ''
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const teksnotifikasi = '*Bot Terhubung Ke WhatsApp ✅*'
|
|
170
|
+
Sky.newsletterFollow("120363421179449531@newsletter") // ID Channel Kalian
|
|
171
|
+
Sky.sendMessage(Sky.user.id.split(":")[0] + "@s.whatsapp.net", { text: teksnotifikasi }, {quoted: qtext})
|
|
172
|
+
console.log(chalk.yellow.bold('[ INFO ] : '), chalk.blue.bold(`Bot Terhubung `))
|
|
173
|
+
}
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
store.bind(Sky.ev)
|
|
177
|
+
await Solving(Sky, store)
|
|
178
|
+
|
|
179
|
+
Sky.ev.on('messages.upsert', async (msg) => {
|
|
180
|
+
await MessagesUpsert(Sky, msg, store)
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
return Sky
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
startingBot()
|
|
187
|
+
|
|
188
|
+
/* ===== AUTO RELOAD ===== */
|
|
189
|
+
let file = require.resolve(__filename)
|
|
190
|
+
fs.watchFile(file, () => {
|
|
191
|
+
fs.unwatchFile(file)
|
|
192
|
+
console.log(chalk.redBright(`Update ${__filename}`))
|
|
193
|
+
delete require.cache[file]
|
|
194
|
+
require(file)
|
|
195
|
+
})
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
!- Credits By Shin Yagami
|
|
4
|
+
https://wa.me/6289508017468
|
|
5
|
+
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs')
|
|
9
|
+
const path = require('path')
|
|
10
|
+
const { spawn } = require('child_process')
|
|
11
|
+
|
|
12
|
+
function ffmpeg(buffer, args = [], ext = '', ext2 = '') {
|
|
13
|
+
return new Promise(async (resolve, reject) => {
|
|
14
|
+
try {
|
|
15
|
+
let tmp = path.join(__dirname, '.tmp//sampah', + new Date + '.' + ext)
|
|
16
|
+
let out = tmp + '.' + ext2
|
|
17
|
+
await fs.promises.writeFile(tmp, buffer)
|
|
18
|
+
spawn('ffmpeg', [
|
|
19
|
+
'-y',
|
|
20
|
+
'-i', tmp,
|
|
21
|
+
...args,
|
|
22
|
+
out
|
|
23
|
+
])
|
|
24
|
+
.on('error', reject)
|
|
25
|
+
.on('close', async (code) => {
|
|
26
|
+
try {
|
|
27
|
+
await fs.promises.unlink(tmp)
|
|
28
|
+
if (code !== 0) return reject(code)
|
|
29
|
+
resolve(await fs.promises.readFile(out))
|
|
30
|
+
await fs.promises.unlink(out)
|
|
31
|
+
} catch (e) {
|
|
32
|
+
reject(e)
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
} catch (e) {
|
|
36
|
+
reject(e)
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Convert Audio to Playable WhatsApp Audio
|
|
43
|
+
* @param {Buffer} buffer Audio Buffer
|
|
44
|
+
* @param {String} ext File Extension
|
|
45
|
+
*/
|
|
46
|
+
function toAudio(buffer, ext) {
|
|
47
|
+
return ffmpeg(buffer, [
|
|
48
|
+
'-vn',
|
|
49
|
+
'-ac', '2',
|
|
50
|
+
'-b:a', '128k',
|
|
51
|
+
'-ar', '44100',
|
|
52
|
+
'-f', 'mp3'
|
|
53
|
+
], ext, 'mp3')
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Convert Audio to Playable WhatsApp PTT
|
|
58
|
+
* @param {Buffer} buffer Audio Buffer
|
|
59
|
+
* @param {String} ext File Extension
|
|
60
|
+
*/
|
|
61
|
+
function toPTT(buffer, ext) {
|
|
62
|
+
return ffmpeg(buffer, [
|
|
63
|
+
'-vn',
|
|
64
|
+
'-c:a', 'libopus',
|
|
65
|
+
'-b:a', '128k',
|
|
66
|
+
'-vbr', 'on',
|
|
67
|
+
'-compression_level', '10'
|
|
68
|
+
], ext, 'opus')
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Convert Audio to Playable WhatsApp Video
|
|
73
|
+
* @param {Buffer} buffer Video Buffer
|
|
74
|
+
* @param {String} ext File Extension
|
|
75
|
+
*/
|
|
76
|
+
function toVideo(buffer, ext) {
|
|
77
|
+
return ffmpeg(buffer, [
|
|
78
|
+
'-c:v', 'libx264',
|
|
79
|
+
'-c:a', 'aac',
|
|
80
|
+
'-ab', '128k',
|
|
81
|
+
'-ar', '44100',
|
|
82
|
+
'-crf', '32',
|
|
83
|
+
'-preset', 'slow'
|
|
84
|
+
], ext, 'mp4')
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
module.exports = {
|
|
88
|
+
toAudio,
|
|
89
|
+
toPTT,
|
|
90
|
+
toVideo,
|
|
91
|
+
ffmpeg,
|
|
92
|
+
}
|