forked from ravindu01manoj/Sew-Queen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sew.js
105 lines (103 loc) · 5.34 KB
/
sew.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
/*Sew Queen Whatsapp Bot
Telegram: https://t.me/RavinduManoj
Facebook: https://www.facebook.com/ravindu.manoj.79
Licensed under the GPL-3.0 License
Coded By Ravindu Manoj
*/
let DataPack = require('sew-queen-pro/export/output');
let SewQueen = require('sew-queen-pro/sources/dc/handler');
let Details = require('sew-queen-pro/sources/dc/Details');
let GBLACK =require('blocked-s/grp')
let SOL =require('sew-queen-pro/console')
let {CheckUpdatesWeb, sendMessageownerMSG, sendMessageADSMSG, sendMessageBotOn, sendMessageGreetingMSG, sendMessageMSGMSG, sendMessageBlackListMSG, sendMessageBIOMSG} = require('sew-queen-pro/sources/dc/sew')
let fs = require('fs'); let os = require('os'); let got = require('got'); let path = require("path"); let chalk = require('chalk');
let SQQA = require('./SQ-QA')
let {WAConnection, MessageOptions, MessageType, Mimetype, Presence} = require('@ravindu01manoj/sew-queen-web');
let {Message, StringSession, Image, Video} = require('sew-queen-pro/sources/dc/Wa-Base/');
let { DataTypes } = require('sequelize'); let { getMessage } = require("./DataBase/greetings");
let Heroku = require('heroku-client'); let simpleGit = require('simple-git'); let git = simpleGit();
let heroku = new Heroku({ token: Details.HEROKU.API_KEY}); let baseURI = '/apps/' + Details.HEROKU.APP_NAME;
fs.readdirSync('./DataBase/').forEach(cmdall => { if (path.extname(cmdall).toLowerCase() == '.js') {
require('./DataBase/' + cmdall)
}})
let Commandsdb = require('./DataBase/cmd');
String.prototype.format = function () {
var i = 0,
args = arguments;
return this.replace(/{}/g, function () {
return typeof args[i] != 'undefined' ? args[i++] : '';
})
};
if (!Date.now) {
Date.now = function () {
return new Date().getTime();
}
}
Array.prototype.remove = function () {
var what, a = arguments,
L = a.length,
ax;
while (L && this.length) {
what = a[--L];
while ((ax = this.indexOf(what)) !== -1) {
this.splice(ax, 1);
}
}
return this;
};
async function sewQueen() {
const CheckWebUpdate = await CheckUpdatesWeb()
await Details.DATABASE.sync();
const DataKey = new WAConnection();
DataKey.version = CheckWebUpdate;
let Session = new StringSession();
await sendMessageownerMSG(DataKey); await sendMessageADSMSG(DataKey)
DataKey.logger.level = Details.DEBUG ? 'debug' : 'warn';
if (Details.SESSION) {DataKey.loadAuthInfo(Session.deCrypt(Details.SESSION));
} else { console.log('Need SEW_QUEEN_SESSION \n'.repeat(50));return;}
DataKey.on('credentials-updated', async () => {
let authInfo = DataKey.base64EncodedAuthInfo();
})
DataKey.on('connecting', async () => {
console.log(SOL.LOGING);
});
DataKey.on('open', async () => {
console.log(SOL.LOG); console.log(SOL.PASSC);
if (Details.SEWRR == 'raviya') {
console.log(SOL.PASSD)
} else if (Details.SEWRR !== 'raviya') {
throw new Error(SOL.PASSW); return;
}
console.log(SOL.INSTCL); console.log(SOL.INSTC); console.log(SOL.INSTL);
var Commands = await Commandsdb.PluginDB.findAll();
Commands.map(async (allcmd) => {
if (!fs.existsSync('./Commands/' + allcmd.dataValues.name + '.js')) {
console.log(allcmd.dataValues.name);
var response = await got(allcmd.dataValues.url);
if (response.statusCode == 200) {
fs.writeFileSync('./Commands/' + allcmd.dataValues.name + '.js', response.body);
require('./Commands/' + allcmd.dataValues.name + '.js');
}
}
});
fs.readdirSync('./Commands').forEach(allcmd => { if (path.extname(allcmd).toLowerCase() == '.js') {
require('./Commands/' + allcmd);
}});
console.log(SOL.COUNTY); console.log(SOL.TYPEW); // await sendMessageBIOMSG(DataKey);
await sendMessageBotOn(DataKey)})
DataKey.on('chat-update', async m => {
if (!m.hasNewMessage) return;
if (!m.messages && !m.count) return;
let msg = m.messages.all()[0];
if (msg.key && msg.key.remoteJid == 'status@broadcast') return;
if (Details.NO_ONLINE) { await DataKey.updatePresence(msg.key.remoteJid, Presence.unavailable)}
await sendMessageGreetingMSG(DataKey, getMessage, msg)
if (GBLACK.ALL_GROUP !== 'raviya') {
var grp = GBLACK.ALL_GROUP + ',' + Details.BLOCKCHAT;var sup = grp.split(',')
if(msg.key.remoteJid.includes('g.us') ? sup.includes(msg.key.remoteJid.split('@')[0]) : sup.includes(msg.participant ? msg.participant.split('@')[0] : msg.key.remoteJid.split('@')[0])) return}
await sendMessageMSGMSG(DataKey, msg, 'sew', SQQA)
});
try {
await DataKey.connect();
} catch {return;}};
sewQueen()