-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.js
2482 lines (2352 loc) · 125 KB
/
index.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// WEB SERVER
const express = require('express')
const server = express()
const axios = require('axios');
const https = require("https");
const ud = require('urban-dictionary')
const inshorts = require('inshorts-api');
const fs = require('fs');
const deepai = require('deepai');
const ytdl = require('ytdl-core');
// const yahooStockPrices = require('yahoo-stock-prices');
const deepAI = process.env.DEEPAI_KEY;
const port = process.env.PORT || 8000;
server.get('/', (req, res) => { res.send('V-Bot server running...') })
server.listen(port, () => {
// console.clear()
console.log('\nWeb-server running!\n')
})
//loading plugins
const { getGender } = require('./plugins/gender') //gender module
const { getAnimeRandom } = require('./plugins/anime') //anime module
const { getFact } = require('./plugins/fact') //fact module
const { downloadAll, downloadholly, downloadbolly } = require('./plugins/movie') //movie module
const { setCountWarning, getCountWarning, removeWarnCount } = require('./DB/warningDB') // warning module
const { getBlockWarning, setBlockWarning, removeBlockWarning } = require('./DB/blockDB') //block module
const { userHelp, StockList, adminList } = require('./plugins/help') //help module
const { getRemoveBg } = require('./plugins/removebg'); // removebg module
const { downloadmeme } = require('./plugins/meme') // meme module
// const bothelp = '[email protected]';
const { getCricketScore } = require("./plugins/cricket");
const { getScoreCard } = require("./plugins/cricketScoreCard");
const more = String.fromCharCode(8206);
const readMore = more.repeat(4001);
const {
setCountMember,
getCountGroups,
getCountGroupMembers,
getCountIndividual,
getCountIndividualAllGroup,
getCountIndividualAllGroupWithName,
getCountTop,
} = require("./DB/countMessDB");
// LOAD Baileys
const {
WAConnection,
MessageType,
Presence,
Mimetype,
GroupSettingChange,
MessageOptions,
WALocationMessage,
WA_MESSAGE_STUB_TYPES,
ReconnectMode,
ProxyAgent,
waChatKey,
mentionedJid,
processTime,
} = require('@adiwajshing/baileys')
// LOAD DB CONNECTION
const db = require('./database');
// LOAD ADDITIONAL NPM PACKAGES
//const fs = require('fs')//file module
const ffmpeg = require('fluent-ffmpeg')//sticker module
const WSF = require('wa-sticker-formatter');//sticker module
async function fetchauth() {
try {
auth_result = await db.query('select * from auth;');//checking auth table
console.log('Fetching login data...')
auth_row_count = await auth_result.rowCount;
if (auth_row_count == 0) {
console.log('No login data found!')
} else {
console.log('Login data found!')
auth_obj = {
clientID: auth_result.rows[0].clientid,
serverToken: auth_result.rows[0].servertoken,
clientToken: auth_result.rows[0].clienttoken,
encKey: auth_result.rows[0].enckey,
macKey: auth_result.rows[0].mackey
}
}
} catch {
console.log('Creating database...')//if login fail create a db
await db.query('CREATE TABLE auth(clientID text, serverToken text, clientToken text, encKey text, macKey text);');
await fetchauth();
}
}
/*****************|SONG|*****************/
const findSong = async (sname) => {
const yts = require('yt-search')
const r = await yts(`${sname}`)
const videos = r.videos.slice(0, 3)
let st = videos[0].url;
return st;
}
// BASIC SETTINGS
prefix = '-';
const OwnerNumb = process.env.myNumber + '@s.whatsapp.net';
source_link = '```Base Link => https://github.com/crysosancher/Blender2.0```';
source_link_mod = '```Updated Link => https://github.com/jacktheboss220/Blender2.0```';
// LOAD CUSTOM FUNCTIONS
const getGroupAdmins = (participants) => {
admins = []
for (let i of participants) {
i.isAdmin ? admins.push(i.jid) : ''
}
return admins
}
let allowedNumbs = ["917070224546", "918318585418", "916353553554"];//enter your own no. for having all the super user previlage
const getRandom = (ext) => { return `${Math.floor(Math.random() * 10000)}${ext}` }
// TECH NEWS ---------------------------
const url = "https://news-pvx.herokuapp.com/";
let latestNews = "TECH NEWS--------";
const getNews = async () => {
const { data } = await axios.get(url);
console.log(typeof data);
let count = 0;
let news = "☆☆☆☆☆💥 Tech News 💥☆☆☆☆☆ \n\n";
data["inshorts"].forEach((headline) => {
count += 1
if (count > 13) return;
news = news + "🌐 " + headline + "\n\n";
});
return news;
};
const postNews = async (categry) => {
console.log(categry)
let n = '';
let z = categry;
let arr = ['national', 'business', 'sports', 'world', 'politics', 'technology', 'startup', 'entertainment', 'miscellaneous', 'hatke', 'science', 'automobile'];
if (!arr.includes(z)) {
return "Enter a valid category:) or use -category for more info:)";
}
var options = {
lang: 'en',
category: z,
numOfResults: 13
}
n = `☆☆☆☆☆💥 ${z.toUpperCase()} News 💥☆☆☆☆☆ \n\n`
await inshorts.get(options, function (result) {
for (let i = 0; i < result.length; i++) {
temp = "🌐 " + result[i].title + "\n";
n = n + temp + "\n";
}
}).catch((er) => "");
return n;
}
//mmi pic
const scrapeProduct = async (url) => {
console.log("Aa gaya hoon toh kya")
const browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox'],
});
const page = await browser.newPage();
await page.goto(url);
const [el] = await page.$x('//*[@id="main"]/section/div/div[3]/div[1]/div/a/img')
const src = await el.getProperty('src');
const srcTxt = await src.jsonValue();
browser.close();
return srcTxt;
}
const fi = async () => {
var confiq = {
method: 'GET',
url: 'https://api.alternative.me/fng/?limit=1'
}
console.log("Puppi")
let puppi;
await axios.request(confiq).then((res) => {
puppi = res.data.data[0].value
}).catch((err) => {
return false;
})
return puppi;
}
async function getPrice() {
var mainconfig = {
method: 'get',
url: 'https://public.coindcx.com/market_data/current_prices'
}
return axios(mainconfig)
}
module.exports = {
getPrice
}
//Hroroscope function
async function gethoro(sunsign) {
var mainconfig = {
method: 'POST',
url: `https://aztro.sameerkumar.website/?sign=${sunsign}&day=today`
}
let horo
await axios.request(mainconfig).then((res) => {
horo = res.data
}).catch((error) => {
return false;
})
return horo;
}
//classic Dictionary
async function dictionary(word) {
var config = {
method: 'GET',
url: `https://api.dictionaryapi.dev/api/v2/entries/en/${word}`
}
let classic;
await axios.request(config).then((res) => {
classic = res.data[0];
}).catch((error) => {
return;
})
return classic;
}
// const cric = async (Mid) => {
// var confiq = {
// method: 'GET',
// url: `https://cricket-api.vercel.app/cri.php?url=https://www.cricbuzz.com/live-cricket-scores/${Mid}/33rd-match-indian-premier-league-2021`
// }
// let ms;
// await axios.request(confiq).then((res) => {
// ms = res.data.livescore;
// }).catch((err) => {
// return;
// })
// return ms;
// }
// const daaa = async (sto) => {
// var s = '';
// await yahooStockPrices.getCurrentData(`${sto}`).then((res) => {
// console.log(res);
// s = `*STOCK* :- _${sto}_
// *Currency* :- _${res.currency}_
// *Price*:- _${res.price}_`;
// }).catch((err) => {
// s = 'Not Found';
// });
// return s;
// };
// MAIN FUNCTION
async function main() {
// LOADING SESSION
const conn = new WAConnection()
conn.logger.level = 'warn'
conn.on('qr', () => { console.log('SCAN THE ABOVE QR CODE TO LOGIN!') })
await fetchauth(); //GET LOGIN DATA
if (auth_row_count == 1) { conn.loadAuthInfo(auth_obj) }
conn.on('connecting', () => { console.log('Connecting...') })
conn.on('open', () => {
console.clear()
console.log('Connected!')
});
conn.connectOptions.alwaysUseTakeover = true;
//conn.setMaxListeners(50);
await conn.connect({ timeoutMs: 30 * 1000 })
const authInfo = conn.base64EncodedAuthInfo() // UPDATED LOGIN DATA
load_clientID = authInfo.clientID;
load_serverToken = authInfo.serverToken;
load_clientToken = authInfo.clientToken;
load_encKey = authInfo.encKey;
load_macKey = authInfo.macKey;
// INSERT / UPDATE LOGIN DATA
if (auth_row_count == 0) {
console.log('Inserting login data...')
db.query('INSERT INTO auth VALUES($1,$2,$3,$4,$5);', [load_clientID, load_serverToken, load_clientToken, load_encKey, load_macKey])
db.query('commit;')
console.log('New login data inserted!')
} else {
console.log('Updating login data....')
db.query('UPDATE auth SET clientid = $1, servertoken = $2, clienttoken = $3, enckey = $4, mackey = $5;', [load_clientID, load_serverToken, load_clientToken, load_encKey, load_macKey])
db.query('commit;')
console.log('Login data updated!')
}
const OwnerSend = (teks) => {
conn.sendMessage(
OwnerNumb,
teks,
MessageType.text
)
}
conn.on('group-participants-update', (anu) => {
try {
conn.groupMetadata(anu.jid).then((res) => {
OwnerSend(`*Action:* ${anu.action} \n*Group:* ${anu.jid} \n*Grp Name:* ${res.subject} \n*Participants:* ${anu.participants[0]}`);
})
console.log(anu);
// if (anu.action == 'add') {
// OwnerSend(`*Group:* ${anu.jid} \n*Grp Name:* ${mdata.subject} \n*Participants:* ${anu.participants[0]}`);
// }
// if (anu.action == 'remove') {
// OwnerSend(`*Group:* ${anu.jid} \n*Grp Name:* ${mdata.subject} \n*Participants:* ${anu.participants[0]}`);
// }
} catch (e) {
console.log(e)
}
})
conn.on('chat-update', async (mek) => {
try {
if (!mek.hasNewMessage) return
mek = JSON.parse(JSON.stringify(mek)).messages[0]
if (!mek.message) return
if (mek.key && mek.key.remoteJid == 'status@broadcast') return
if (mek.key.fromMe) return
const content = JSON.stringify(mek.message)
global.prefix
const from = mek.key.remoteJid
const type = Object.keys(mek.message)[0]
const {
text,
extendedText,
contact,
location,
liveLocation,
image,
video,
sticker,
document,
audio,
product,
listMessage,
buttonsMessage,
buttonsResponseMessage,
listResponseMessage,
} = MessageType
body = (type === 'conversation' && mek.message.conversation.startsWith(prefix)) ? mek.message.conversation : (type == 'imageMessage') && mek.message.imageMessage.caption.startsWith(prefix) ? mek.message.imageMessage.caption : (type == 'videoMessage') && mek.message.videoMessage.caption.startsWith(prefix) ? mek.message.videoMessage.caption : (type == 'extendedTextMessage') && mek.message.extendedTextMessage.text.startsWith(prefix) ? mek.message.extendedTextMessage.text : (type == 'buttonsResponseMessage') && mek.message.buttonsResponseMessage.selectedDisplayText.startsWith(prefix) ? mek.message.buttonsResponseMessage.selectedDisplayText : (type == 'listResponseMessage') && mek.message.listResponseMessage.title.startsWith(prefix) ? mek.message.listResponseMessage.title : ''
const birthday = new Date().toLocaleTimeString();
let hou = parseInt(birthday.split(":")[0]) + 5;// birthday.getHours();
let minu = parseInt(birthday.split(":")[1]) + 30;// birthday.getMinutes();
let sec = parseInt(birthday.split(":")[2]); //birthday.getSeconds()
if (minu > 59) {
hou = hou + parseInt(minu / 60);
minu = parseInt(minu % 60);
}
const command = body.slice(1).trim().split(/ +/).shift().toLowerCase()
const args = body.trim().split(/ +/).slice(1)
const ev = body.trim().split(/ +/).slice(1).join(' ')
const isCmd = body.startsWith(prefix)
errors = {
admin_error: '_❌ ERROR: Bot need Admin privilege❌_'//_
}
const botNumber = conn.user.jid
const isGroup = from.endsWith('@g.us')
const sender = isGroup ? mek.participant : mek.key.remoteJid
const groupMetadata = isGroup ? await conn.groupMetadata(from) : ''
const groupName = isGroup ? groupMetadata.subject : ''
const groupMembers = isGroup ? groupMetadata.participants : ''
const groupAdmins = isGroup ? getGroupAdmins(groupMembers) : ''
const isBotGroupAdmins = groupAdmins.includes(botNumber)
const isGroupAdmins = groupAdmins.includes(sender)
const reply = (teks) => {
conn.sendMessage(from, teks, text, {
quoted: mek
})
}
const costum = async (pesan, tipe, target, target2) => {
await conn.sendMessage(from, pesan, tipe, {
quoted: {
key: {
fromMe: false,
participant: `${target}`,
...(from ? {
remoteJid: from
} : {})
},
message: {
conversation: `${target2}`
}
}
})
}
const sendText = (message) => {
conn.sendMessage(from, message, MessageType.text);
};
let matchIdGroups = {}; //to store every group name with its match ID
let cricSetIntervalGroups = {}; //to store every group name with its setInterval value so that it can be stopped
let cricStartedGroups = {}; //to store every group name with boolean value to know if cricket score is already started or not
/* -------------------------- CRICKET HELPING FUNCTIONS ------------------------- */
const stopcHelper = () => {
reply("✔️ Stopping Cricket scores for this group !");
console.log("Stopping Cricket scores for " + groupName);
clearInterval(cricSetIntervalGroups[groupName]);
cricStartedGroups[groupName] = false;
};
//return false when stopped in middle. return true when run fully
const startcHelper = async (commandName, isFromSetInterval = false) => {
if (!groupDesc) {
conn.sendMessage(
from,
`❌
- Group description is empty.
- Put match ID in starting of group description.
- Get match ID from cricbuzz today match url.
- example: https://www.cricbuzz.com/live-cricket-scores/37572/mi-vs-kkr-34th-match-indian-premier-league-2021
- so match ID is 37572 !
# If you've put correct match ID in description starting and still facing this error then contact developer by !dev`,
MessageType.text,
{
quoted: mek,
detectLinks: false,
}
);
return false;
}
matchIdGroups[groupName] = groupDesc.slice(0, 5);
if (commandName === "startc" && !isFromSetInterval) {
reply(
"✔️ Starting Cricket scores for matchID: " +
matchIdGroups[groupName] +
" (taken from description)"
);
}
let response = await getCricketScore(
matchIdGroups[groupName],
commandName
);
//response.info have "MO" only when command is startc
if (commandName === "startc" && response.info === "MO") {
sendText(response.message);
reply("✔️ Match over! Stopping Cricket scores for this group !");
console.log("Match over! Stopping Cricket scores for " + groupName);
clearInterval(cricSetIntervalGroups[groupName]);
cricStartedGroups[groupName] = false;
return false;
} else if (commandName === "startc" && response.info === "IO") {
sendText(response.message);
reply(
"✔️ Inning over! Open again live scores later when 2nd inning will start by !startc"
);
stopcHelper();
return false;
} else if (response.info === "ER") {
conn.sendMessage(
from,
`❌
- Group description starting is "${matchIdGroups[groupName]}"
- Put match ID in starting of group description.
- Get match ID from cricbuzz today match url.
- example: https://www.cricbuzz.com/live-cricket-scores/37572/mi-vs-kkr-34th-match-indian-premier-league-2021
- so match ID is 37572 !
# If you've put correct match ID in description starting and still facing this error then contact developer by !dev`,
MessageType.text,
{
quoted: mek,
detectLinks: false,
}
);
return false;
}
sendText(response.message);
return true;
};
//------------------------JOKE--------------------//
/*********************************JOKE ******************/
async function jokeFun(take) {
const baseURL = "https://v2.jokeapi.dev";
const categories = (!take) ? "Any" : take;
const cate = ["Programming", "Misc", "Dark", "Pun", "Spooky", "Chrimstmas"]
if (categories != "Any" && !(cate.includes(take))) return reply(`*Wrong Categories*\n *_Type any one_* : *${cate}*`);
const params = "blacklistFlags=religious,racist";
https.get(`${baseURL}/joke/${categories}?${params}`, res => {
res.on("data", chunk => {
// On data received, convert it to a JSON object
let randomJoke = JSON.parse(chunk.toString());
if (randomJoke.type == "single") {
// If type == "single", the joke only has the "joke" property
mess = 'Category => ' + randomJoke.category + '\n\n' + randomJoke.joke;
reply(mess);
}
else {
// If type == "twopart", the joke has the "setup" and "delivery" properties
mess = 'Category => ' + randomJoke.category + '\n\n' + randomJoke.setup + '\n' + randomJoke.delivery;
reply(mess);
}
console.log("Categories => ", categories);
});
res.on("error", err => {
// On error, log to console
replay("Error!! Try again Later");
console.error(`Error: ${err}`);
});
});
}
//-------------------------ADVICE--------------//
async function getRandomAD() {
await axios(`https://api.adviceslip.com/advice`).then((res) => {
reply(`_*-Advice-*_ \n` + res.data.slip.advice);
}).catch((error) => {
console.log('error', error);
reply(`Error`);
})
}
//------------------------NSFW----------------//
async function getcall() {
await deepai.callStandardApi("nsfw-detector", {
image: fs.createReadStream(`${media}`),
}).then((res) => {
let mess = `*Nsfw Score* : ${res.output.nsfw_score}\n`;
console.log('NSFW Score : ', res.output.nsfw_score);
if (res.output.detections.length > 0) {
for (let i = 0; i < res.output.detections.length; i++) {
mess += `*Nsfw* : ${res.output.detections[i].name} : ${res.output.detections[i].confidence}%\n`;
}
reply(mess);
} else
reply(mess);
}).catch((res) => {
console.log("error ", res);
reply(`*Website error*`);
});
}
if (isGroup) {
let user = conn.contacts[sender];
let username = user
? user.notify ||
user.vname ||
user.name ||
sender.split("@")[0]
: sender.split("@")[0];
setCountMember(sender, from, username);
}
const isMedia = (type === 'imageMessage' || type === 'videoMessage')
const isQuotedImage = type === 'extendedTextMessage' && content.includes('imageMessage')
const isQuotedVideo = type === 'extendedTextMessage' && content.includes('videoMessage')
const isQuotedSticker = type === 'extendedTextMessage' && content.includes('stickerMessage')
let senderNumb = sender.split('@')[0];
//console.log("SENDER NUMB:", senderNumb);
let groupDesc = groupMetadata.desc;
let blockCommandsInDesc = []; //commands to be blocked
if (groupDesc) {
let firstLineDesc = groupDesc.split("\n")[0];
blockCommandsInDesc = firstLineDesc.split(",");
}
if (!isGroup) {
if (!allowedNumbs.includes(senderNumb))
reply(`❤️ Send by Bot => I don't work in direct message(dm). Pls Don't _Spam_ here. *Thanks ❤️*`);
}
if (isCmd) {
console.log('[COMMAND]', command, '[FROM]', sender.split('@')[0], '[IN]', groupName, 'type=', typeof (args), hou, minu, sec)
OwnerSend(command + ' *in* ' + groupName + ' *by* ' + senderNumb + ' *Time :* ' + hou + ' ' + minu + ' ' + sec)
if (blockCommandsInDesc.includes(command)) {
reply("❌ Command blocked for this group!");
return;
}
let blockCount = await getBlockWarning(sender);
if (blockCount == 1) return reply(`You cann't use the bot as u are *blocked*.`);
/////////////// COMMANDS \\\\\\\\\\\\\\\
switch (command) {
/////////////// HELP \\\\\\\\\\\\\\\
case 'help':
case 'acmd':
if (!isGroup) return;
await costum(userHelp(prefix, groupName), text);
break
case 'admin':
if (!isGroup) return;
await costum(adminList(prefix, groupName), text);
break;
case 'removebg':
if (!isGroup) return;
if ((isMedia && !mek.message.videoMessage || isQuotedImage)) {
const encmedia = isQuotedImage ? JSON.parse(JSON.stringify(mek).replace('quotedM', 'm')).message.extendedTextMessage.contextInfo : mek
const media = await conn.downloadAndSaveMediaMessage(encmedia)
reply(`*Removing Backgroung....*`);
getRemoveBg(media).then(() => {
conn.sendMessage(
from,
fs.readFileSync("./bg.png"),
MessageType.image,
{
mimetype: Mimetype.png,
caption: `*Removed!!*`,
quoted: mek,
}
)
fs.unlinkSync("./bg.png");
}).catch((err) => {
OwnerSend('*RemoveBG ERROR :* ' + err)
console.log('Status : ', err.status);
reply(`Website Error, Tag Owner or Mod : \n Need to change api key.`)
});
}
else {
reply(`Reply to image only.`);
}
break;
case 'stock':
if (!isGroup) return;
await costum(StockList(prefix, groupName), text);
break
case 'a':
case 'alive':
if (!isGroup) return;
reply("```🤖 Yes Vro 🤖```\n(づ ̄3 ̄)づ╭❤️~\n*Zinda hu Bas Kaam bol*");
break
case 'link':
case 'getlink':
case 'grouplink':
if (!isGroup) return;
if (!isBotGroupAdmins) return reply(errors.admin_error);
gc_invite_code = await conn.groupInviteCode(from)
gc_link = `https://chat.whatsapp.com/${gc_invite_code}`
conn.sendMessage(from, gc_link, text, {
quoted: mek,
detectLinks: true
})
break;
case 'advice':
if (!isGroup) return;
getRandomAD();
break;
case 'tts':
if (!isGroup) return;
var take = args[0];
for (i = 1; i < args.length; i++) {
take += " " + args[i];
}
OwnerSend(take + " =tts message");
let uri = encodeURI(take);
async function getTTS() {
await axios.get(
"https://api.xteam.xyz/attp?file&text=" + uri,
{ responseType: "arraybuffer" }
).then((ttinullimage) => {
conn.sendMessage(
from,
Buffer.from(ttinullimage.data),
MessageType.sticker,
{ mimetype: Mimetype.webp }
);
}).catch(() => {
reply(`_Website is Down_\nWait for Sometime`);
});
}
getTTS();
break;
case 'meme':
if (!isGroup) return;
reply(`*Sending...*`);
const memeURL = 'https://meme-api.herokuapp.com/gimme';
axios.get(`${memeURL}`).then((res) => {
let url = res.data.url;
if (url.includes("jpg") || url.includes("jpeg") || url.includes("png")) {
conn.sendMessage(
from,
{ url: res.data.url },
MessageType.image,
{
mimetype: Mimetype.jpg,
caption: `${res.data.title}`,
quoted: mek,
}
);
}
else {
// downloadmeme(res.data.url).then(() => {
// const buffer = fs.readFileSync("./pic.mp4") // load some gif
// const options = {
// gifPlayback: true,
// mimetype: Mimetype.gif,
// caption: `${res.data.url}`
// } // some metadata & caption
conn.sendMessage(
from,
{ url: res.data.url },
MessageType.video,
{
mimetype: Mimetype.gif,
gifPlayback: true,
caption: `${res.data.url}`
}
)
// fs.unlinkSync("./pic.mp4");
// });
}
}).catch(() => {
console.log('Error');
reply(`Eror. Contect Dev.`);
});
break;
/* ------------------------------- CASE: TOIMG ------------------------------ */
case "toimg":
case "image":
if (!isGroup) {
reply("❌ Group command only!");
return;
}
if (!mek.message.extendedTextMessage.contextInfo.quotedMessage.stickerMessage.isAnimated) {
const mediaToImg = await conn.downloadAndSaveMediaMessage({
message:
mek.message.extendedTextMessage.contextInfo.quotedMessage,
});
ffmpeg(`./${mediaToImg}`)
.fromFormat("webp_pipe")
.save("result.png")
.on("error", (err) => {
console.log(err);
reply(
"❌ There is some problem!\nOnly non-animated stickers can be convert to image!"
);
})
.on("end", () => {
conn.sendMessage(
from,
fs.readFileSync("result.png"),
MessageType.image,
{
mimetype: Mimetype.png,
quoted: mek,
}
);
fs.unlinkSync("result.png");
});
} else {
reply(
"❌ There is some problem!\nOnly non-animated stickers can be convert to image!"
);
}
break;
case 'joke':
if (!isGroup) return;
jokeFun(args[0]);
break;
case 'anime':
if (!isGroup) return;
var name = ev;
OwnerSend("Args : " + name);
if (name.includes('name')) {
getAnimeRandom('quotes/character?name=' + name.toLowerCase().substring(4).trim().split(" ").join("+")).then((message) => {
reply(message);
}).catch((error) => {
reply(error);
});
} else if (name.includes('title')) {
mess = getAnimeRandom('quotes/anime?title=' + name.toLowerCase().substring(6).trim().split(" ").join("%20")).then((message) => {
reply(message);
}).catch((error) => {
reply(error);
});
} else {
getAnimeRandom('random').then((message) => {
reply(message);
}).catch((error) => {
reply(error);
})
}
break;
case 'fb':
if (!isGroup) return;
if (!args[0]) return reply(`Enter url after ${prefix}fb`);
var faceURL = args[0];
if (faceURL.includes("?app"))
faceURL = faceURL.split("?app")[0];
if (!faceURL.endsWith("/"))
faceURL += "/";
OwnerSend('Downloading : ' + faceURL);
axios(`https://api.neoxr.eu.org/api/fb?url=${faceURL}&apikey=jeKTkg7b`).then((res) => {
reply(`_Downloading.._\nIf video is more then 100Mb Bot will not send it.`);
let Url = res.data.data[1].url;
if (Url == null || Url == '')
Url = res.data.data[0].url;
conn.sendMessage(
from,
{ url: Url },
MessageType.video,
{
mimetype: Mimetype.mp4,
caption: "Here.",
quoted: mek
}
);
console.log('Sent');
}).catch(() => {
console.log("ERROR");
reply(`*_Error_* Enter valid url or Only Public post can be downloaded.`);
})
break;
case 'sticker':
case 's':
if (!isGroup) return;
// Format should be <prefix>sticker pack <pack_name> author <author_name>
var packName = ""
var authorName = ""
// Check if pack keyword is found in args!
if (args.includes('pack') == true) {
packNameDataCollection = false;
for (let i = 0; i < args.length; i++) {
// Enables data collection when keyword found in index!
if (args[i].includes('pack') == true) {
packNameDataCollection = true;
}
if (args[i].includes('author') == true) {
packNameDataCollection = false;
}
// If data collection is enabled and args length is more then one it will start appending!
if (packNameDataCollection == true) {
packName = packName + args[i] + ' '
}
}
// Check if variable contain unnecessary startup word!
if (packName.startsWith('pack ')) {
packName = `${packName.split('pack ')[1]}`
}
}
// Check if author keyword is found in args!
if (args.includes('author') == true) {
authorNameDataCollection = false;
for (let i = 0; i < args.length; i++) {
// Enables data collection when keyword found in index!
if (args[i].includes('author') == true) {
authorNameDataCollection = true;
}
// If data collection is enabled and args length is more then one it will start appending!
if (authorNameDataCollection == true) {
authorName = authorName + args[i] + ' '
}
// Check if variable contain unnecessary startup word!
if (authorName.startsWith('author ')) {
authorName = `${authorName.split('author ')[1]}`
}
}
}
// Check if packName and authorName is empty it will pass default values!
if (packName == "") {
packName = "Bit"
}
if (authorName == "") {
authorName = "Bot"
}
outputOptions = [`-vcodec`, `libwebp`, `-vf`, `scale='min(320,iw)':min'(320,ih)':force_original_aspect_ratio=decrease,fps=15, pad=320:320:-1:-1:[email protected], split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse`];
if ((args.includes('crop') == true) || (args.includes('c') == true)) {
outputOptions = [
`-vcodec`,
`libwebp`,
`-vf`,
`crop=w='min(min(iw\,ih)\,500)':h='min(min(iw\,ih)\,500)',scale=500:500,setsar=1,fps=15`,
`-loop`,
`0`,
`-ss`,
`00:00:00.0`,
`-t`,
`00:00:10.0`,
`-preset`,
`default`,
`-an`,
`-vsync`,
`0`,
`-s`,
`512:512`
];
}
if ((isMedia && !mek.message.videoMessage || isQuotedImage)) {
const encmedia = isQuotedImage ? JSON.parse(JSON.stringify(mek).replace('quotedM', 'm')).message.extendedTextMessage.contextInfo : mek
const media = await conn.downloadAndSaveMediaMessage(encmedia)
ran = getRandom('.webp')
reply('⌛Changing media to sticker⏳')//⌛Ruk Bhai..Kar raha ⏳
await ffmpeg(`./${media}`)
.input(media)
.on('error', function (err) {
fs.unlinkSync(media)
console.log(`Error : ${err}`)
reply('_❌ ERROR: Failed to convert image into sticker! ❌_')
})
.on('end', function () {
buildSticker()
})
.addOutputOptions(outputOptions)
.toFormat('webp')
.save(ran)
async function buildSticker() {
if (args.includes('nometadata') == true) {
conn.sendMessage(from, fs.readFileSync(ran), sticker, { quoted: mek })
fs.unlinkSync(media)
fs.unlinkSync(ran)
} else {
const webpWithMetadata = await WSF.setMetadata(packName, authorName, ran)
conn.sendMessage(from, webpWithMetadata, MessageType.sticker)
fs.unlinkSync(media)
fs.unlinkSync(ran)
}
}
} else if ((isMedia && mek.message.videoMessage.seconds < 11 || isQuotedVideo && mek.message.extendedTextMessage.contextInfo.quotedMessage.videoMessage.seconds < 11)) {
const encmedia = isQuotedVideo ? JSON.parse(JSON.stringify(mek).replace('quotedM', 'm')).message.extendedTextMessage.contextInfo : mek
const media = await conn.downloadAndSaveMediaMessage(encmedia)
ran = getRandom('.webp')
reply('⌛Changing media file to Sticker⏳')//⌛ Ho raha Thoda wait karle... ⏳
await ffmpeg(`./${media}`)
.inputFormat(media.split('.')[1])
.on('error', function (err) {
fs.unlinkSync(media)
mediaType = media.endsWith('.mp4') ? 'video' : 'gif'
reply(`_❌ ERROR: Failed to convert ${mediaType} to sticker! ❌_`)
})
.on('end', function () {
buildSticker()
})
.addOutputOptions(outputOptions)
.toFormat('webp')
.save(ran)
async function buildSticker() {
if (args.includes('nometadata') == true) {
conn.sendMessage(from, fs.readFileSync(ran), sticker, { quoted: mek })
fs.unlinkSync(media)
fs.unlinkSync(ran)
} else {
const webpWithMetadata = await WSF.setMetadata(packName, authorName, ran)
conn.sendMessage(from, webpWithMetadata, MessageType.sticker)
fs.unlinkSync(media)
fs.unlinkSync(ran)
}
}
}
else {
reply(`❌*Error reply to image or video only*\n*Send Again the Media*`);
console.log('error not replyed');
}
break;
case 'movie':
if (!isGroup) return;
if (!args[0]) return reply(`Provide Movie name.`);
let movie = body.trim().split(/ +/).slice(1).join('+');
OwnerSend("Movie : " + movie);
let MovieUrl = '';
await downloadAll('`' + movie).then((message) => {
MovieUrl += message + "\n\n";
}).catch(() => { });
await downloadbolly('`' + movie).then((message) => {
MovieUrl += message + "\n\n";
}).catch(() => { });
await downloadholly('`' + movie).then((message) => {
MovieUrl += message + "\n\n";
}).catch(() => { });
if (MovieUrl != '')
reply(`*Direct link for*😊 ${movie.split("+").join(" ")}\n\n` + MovieUrl);
else {
console.log("Not Found!!");
reply(`*Sorry* No Movie Found\nCheck your _spelling or try another movie_.`);
}
break;
case 'nsfw':
if (!isGroup) return;