forked from Fortunatusmokaya/dreaded-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdreaded.js
120 lines (99 loc) · 4.98 KB
/
dreaded.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
const { BufferJSON, WA_DEFAULT_EPHEMERAL, generateWAMessageFromContent, proto, generateWAMessageContent, generateWAMessage, prepareWAMessageMedia, areJidsSameUser, getContentType } = require("@whiskeysockets/baileys");
const fs = require("fs");
const util = require("util");
const chalk = require("chalk");
const speed = require("performance-now");
const { smsg, formatp, tanggal, formatDate, getTime, sleep, clockString, fetchJson, getBuffer, jsonformat, generateProfilePicture, parseMention, getRandom, fetchBuffer } = require('./lib/botFunctions.js');
const { exec, spawn, execSync } = require("child_process");
const { TelegraPh, UploadFileUgu } = require("./lib/toUrl");
const path = require('path');
const { commands, totalCommands } = require('./commandHandler');
const blocked_users = require('./Functions/blocked_users');
const status_saver = require('./Functions/status_saver');
const eval2 = require('./Functions/eval2');
const eval = require('./Functions/eval');
const antiviewonce = require('./Functions/antiviewonce');
const gcPresence = require('./Functions/gcPresence');
const antilink = require('./Functions/antilink');
const {
presence, autoread, botname,
mode, prefix, mycode, author, packname,
dev, gcpresence, antionce
} = require('./settings');
module.exports = dreaded = async (client, m, chatUpdate, store) => {
try {
var body =
m.mtype === "conversation"
? m.message.conversation
: m.mtype === "imageMessage"
? m.message.imageMessage.caption
: m.mtype === "extendedTextMessage"
? m.message.extendedTextMessage.text
: "";
const Tag =
m.mtype == "extendedTextMessage" &&
m.message.extendedTextMessage.contextInfo != null
? m.message.extendedTextMessage.contextInfo.mentionedJid
: [];
var msgDreaded = m.message.extendedTextMessage?.contextInfo?.quotedMessage;
var budy = typeof m.text == "string" ? m.text : "";
const timestamp = speed();
const dreadedspeed = speed() - timestamp
const cmd = body.startsWith(prefix);
const args = body.trim().split(/ +/).slice(1);
const pushname = m.pushName || "No Name";
const botNumber = await client.decodeJid(client.user.id);
const itsMe = m.sender == botNumber ? true : false;
let text = (q = args.join(" "));
const arg = budy.trim().substring(budy.indexOf(" ") + 1);
const arg1 = arg.trim().substring(arg.indexOf(" ") + 1);
const getGroupAdmins = (participants) => {
let admins = [];
for (let i of participants) {
i.admin === "superadmin" ? admins.push(i.id) : i.admin === "admin" ? admins.push(i.id) : "";
}
return admins || [];
};
const fortu = (m.quoted || m);
const quoted = (fortu.mtype == 'buttonsMessage') ? fortu[Object.keys(fortu)[1]] : (fortu.mtype == 'templateMessage') ? fortu.hydratedTemplate[Object.keys(fortu.hydratedTemplate)[1]] : (fortu.mtype == 'product') ? fortu[Object.keys(fortu)[0]] : m.quoted ? m.quoted : m;
const color = (text, color) => {
return !color ? chalk.green(text) : chalk.keyword(color)(text);
};
const mime = (quoted.msg || quoted).mimetype || "";
const qmsg = (quoted.msg || quoted);
const DevDreaded = dev.split(",");
const Owner = DevDreaded.map((v) => v.replace(/[^0-9]/g, "") + "@s.whatsapp.net").includes(m.sender)
const groupMetadata = m.isGroup ? await client.groupMetadata(m.chat).catch((e) => {}) : "";
const groupName = m.isGroup && groupMetadata ? await groupMetadata.subject : "";
const participants = m.isGroup && groupMetadata ? await groupMetadata.participants : "";
const groupAdmin = m.isGroup ? await getGroupAdmins(participants) : "";
const isBotAdmin = m.isGroup ? groupAdmin.includes(botNumber) : false;
const isAdmin = m.isGroup ? groupAdmin.includes(m.sender) : false;
const IsGroup = m.chat?.endsWith("@g.us");
const context = {
client, m, text, Owner, chatUpdate, store, isBotAdmin, isAdmin, IsGroup, participants,
pushname, body, budy, totalCommands, args, mime, qmsg, msgDreaded, botNumber, itsMe,
packname, author, generateProfilePicture, groupMetadata, dreadedspeed, mycode,
fetchJson, exec, getRandom, UploadFileUgu, TelegraPh, prefix, cmd, botname, mode, gcpresence, antionce, fetchBuffer, Tag
};
if (cmd && mode === 'private' && !itsMe && !Owner) {
return;
}
if (await blocked_users(client, m, cmd)) {
await m.reply("You are blocked from using bot commands.");
return;
}
await status_saver(client, m, Owner, prefix)
await eval2(client, m, Owner, budy, fetchJson)
await eval(client, m, Owner, budy, fetchJson)
await antilink(client, m, isBotAdmin, isAdmin, Owner, body);
await antiviewonce(client, m, antionce);
await gcPresence(client, m, gcpresence);
const command = cmd ? body.replace(prefix, "").trim().split(/ +/).shift().toLowerCase() : null;
if (commands[command]) {
await commands[command](context);
}
} catch (err) {
m.reply(util.format(err));
}
};