-
Notifications
You must be signed in to change notification settings - Fork 18
/
body.js
154 lines (154 loc) Β· 5.45 KB
/
body.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import _0x2f665a from 'dotenv';
_0x2f665a.config();
import { makeWASocket, fetchLatestBaileysVersion, DisconnectReason, useMultiFileAuthState } from '@whiskeysockets/baileys';
import { Handler, Callupdate, GroupUpdate } from './scs/hans/index.js';
import _0x4ecc7b from 'express';
import _0x416691 from 'pino';
import _0x5687e2 from 'fs';
import 'node-cache';
import _0x374270 from 'path';
import _0x4b0fc4 from 'chalk';
import 'moment-timezone';
import _0x5a7360 from 'axios';
import _0xccedb8 from './config.cjs';
import _0x11fa72 from './lib/autoreact.cjs';
const {
emojis,
doReact
} = _0x11fa72;
const app = _0x4ecc7b();
let useQR = false;
let initialConnection = true;
const PORT = process.env.PORT || 0xbb8;
const MAIN_LOGGER = _0x416691({
'timestamp': () => ",\"time\":\"" + new Date().toJSON() + "\""
});
const logger = MAIN_LOGGER.child({});
logger.level = "trace";
const __filename = new URL(import.meta.url).pathname;
const __dirname = _0x374270.dirname(__filename);
const sessionDir = _0x374270.join(__dirname, "session");
const credsPath = _0x374270.join(sessionDir, 'creds.json');
if (!_0x5687e2.existsSync(sessionDir)) {
_0x5687e2.mkdirSync(sessionDir, {
'recursive': true
});
}
async function downloadSessionData() {
if (!_0xccedb8.SESSION_ID) {
console.error("Please add your session to SESSION_ID env !!");
return false;
}
const _0x331b8a = _0xccedb8.SESSION_ID.split("Joel-Md&")[0x1];
const _0x170b41 = 'https://pastebin.com/raw/' + _0x331b8a;
try {
const _0x5a3e5f = await _0x5a7360.get(_0x170b41);
const _0x7f614 = typeof _0x5a3e5f.data === 'string' ? _0x5a3e5f.data : JSON.stringify(_0x5a3e5f.data);
await _0x5687e2.promises.writeFile(credsPath, _0x7f614);
console.log("πHANS MD ONLINEβ‘");
return true;
} catch (_0x100795) {
return false;
}
}
async function start() {
try {
const {
state: _0x1fda07,
saveCreds: _0x356b55
} = await useMultiFileAuthState(sessionDir);
const {
version: _0x2f6d2f,
isLatest: _0x23f0a4
} = await fetchLatestBaileysVersion();
console.log("Hans is running on v" + _0x2f6d2f.join('.') + ", isLatest: " + _0x23f0a4);
const _0x76bf4 = makeWASocket({
'version': _0x2f6d2f,
'logger': _0x416691({
'level': 'silent'
}),
'printQRInTerminal': useQR,
'browser': ['Hans-MD', 'safari', '3.3'],
'auth': _0x1fda07,
'getMessage': async _0x53ca5a => {
if (store) {
const _0x406fd9 = await store.loadMessage(_0x53ca5a.remoteJid, _0x53ca5a.id);
return _0x406fd9.message || undefined;
}
return {
'conversation': "BEST WHATSAPP BOT MADE BY HANS TZ"
};
}
});
_0x76bf4.ev.on("connection.update", _0x4eb449 => {
const {
connection: _0x237ed1,
lastDisconnect: _0x1b5c1d
} = _0x4eb449;
if (_0x237ed1 === "close") {
if (_0x1b5c1d.error?.["output"]?.["statusCode"] !== DisconnectReason.loggedOut) {
start();
}
} else if (_0x237ed1 === 'open') {
if (initialConnection) {
console.log(_0x4b0fc4.green("HANS MD CONNECTED SUCCESSFULLY β
"));
_0x76bf4.sendMessage(_0x76bf4.user.id, {
'text': "βββββββββββββββββ·\nβ *Κα΄Ι΄s Ιͺs α΄α΄Ι΄Ι΄α΄α΄α΄α΄α΄
*\nβ°ββββββββββββββββ·\n\nβββββββββββββββββ·\nβπ€ Κα΄α΄ Ι΄α΄α΄α΄: *Κα΄Ι΄s α΄α΄
*\nβπ¨βπ» α΄α΄‘Ι΄α΄Κ : *Κα΄Ι΄s α΄α΄’*\nβ°ββββββββββββββββ·\n\n*Join Whatsapp Channel For Updates*\n_https://whatsapp.com/channel/0029VasiOoR3bbUw5aV4qB31_"
});
initialConnection = false;
} else {
console.log(_0x4b0fc4.blue("Restarted Successfully...!."));
}
}
});
_0x76bf4.ev.on('creds.update', _0x356b55);
_0x76bf4.ev.on("messages.upsert", async _0x2d963c => await Handler(_0x2d963c, _0x76bf4, logger));
_0x76bf4.ev.on("call", async _0x516b51 => await Callupdate(_0x516b51, _0x76bf4));
_0x76bf4.ev.on("group-participants.update", async _0x128e02 => await GroupUpdate(_0x76bf4, _0x128e02));
if (_0xccedb8.MODE === "public") {
_0x76bf4['public'] = true;
} else if (_0xccedb8.MODE === "private") {
_0x76bf4["public"] = false;
}
_0x76bf4.ev.on("messages.upsert", async _0x2e7a5a => {
try {
const _0x4282ef = _0x2e7a5a.messages[0x0];
if (!_0x4282ef.key.fromMe && _0xccedb8.AUTO_REACT) {
console.log(_0x4282ef);
if (_0x4282ef.message) {
const _0x4d275d = emojis[Math.floor(Math.random() * emojis.length)];
await doReact(_0x4d275d, _0x4282ef, _0x76bf4);
}
}
} catch (_0x3beab8) {
console.error("Error during auto reaction:", _0x3beab8);
}
});
} catch (_0x324507) {
console.error("Critical Error:", _0x324507);
process.exit(0x1);
}
}
async function init() {
if (_0x5687e2.existsSync(credsPath)) {
console.log("Session Connected Successfully β
.");
await start();
} else {
const _0x17d9d4 = await downloadSessionData();
if (_0x17d9d4) {
console.log("HANS MD RUNNING...β³");
await start();
} else {
console.log("Session id error β");
useQR = true;
await start();
}
}
}
init();
app.get('/', (_0x1ecf21, _0x282bcc) => {
_0x282bcc.send("HANS MD CONNECTED SUCCESSFULLY β
");
});
app.listen(PORT, () => {
console.log("Hans daily users " + PORT);
});