Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Commit

Permalink
Update v2.2.0-core-2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
anubiskun committed Oct 18, 2022
1 parent 6d827ef commit ef217d2
Show file tree
Hide file tree
Showing 25 changed files with 2,303 additions and 1,468 deletions.
36 changes: 25 additions & 11 deletions anubis.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@
*/

require('./conf')
const yargs = require('yargs/yargs')
const opts = new Object(yargs(process.argv.slice(2)).exitProcess(false).parse())
const opts = new Object(require('yargs/yargs')(process.argv.slice(2)).exitProcess(false).parse())
const { default: WAConnection ,DisconnectReason, useMultiFileAuthState, fetchLatestWaWebVersion, S_WHATSAPP_NET, makeInMemoryStore } = require('@adiwajshing/baileys')
const { Boom } = require('@hapi/boom')
const fs = require('fs')
const Path = require('path')
const _ = require('lodash')
const syntaxerror = require('syntax-error')
const pino = require('pino').default
const { Low, JSONFile } = require('./library/lowdb')
const { Low, JSONFileSync } = require('./library/lowdb')
const mongoDB = require('./library/mongoDB')
const database = new Low(opts['test'] ? new JSONFile(`database.json`) : new mongoDB(mongoUser))
const database = new Low(opts['test'] ? new JSONFileSync(`database.json`) : new mongoDB(mongoUser))
const store = makeInMemoryStore({ logger: pino().child({ level: 'silent', stream: 'store' }) })
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))

Expand All @@ -26,7 +25,7 @@
console.log('LOADING DATABASE...')
await sleep(5000)
if (database.READ) return new Promise((resolve) => setInterval(function () { (!database.READ ? (clearInterval(this), resolve(database.data == null ? loadDatabase() : database.data)) : null) }, 0.5 * 1000))
if (database.data.users == null) {
if (database.data == null) {
database.READ = true
await database.read()
database.READ = false
Expand Down Expand Up @@ -97,8 +96,9 @@
auth: state,
browser: [global.author,'Safari','1.0.0'],
generateHighQualityLinkPreview: true,
linkPreviewImageThumbnailWidth: 200,
syncFullHistory: true,
connectTimeoutMs: 1000,
connectTimeoutMs: 5000,
})
anubis.db = database
anubis.anubiskun = S_WHATSAPP_NET
Expand All @@ -113,11 +113,11 @@
if (reason === DisconnectReason.badSession) { console.log(`Bad Session, reconnecting...`); reloadConnector(); }
else if (reason === DisconnectReason.connectionClosed) { console.log("Connection closed"); reloadConnector(); }
else if (reason === DisconnectReason.connectionLost) { console.log("Connection Lost from Server, reconnecting..."); reloadConnector(); }
else if (reason === DisconnectReason.connectionReplaced) { console.log("Connection Replaced, Another New Session Opened, Please Close Current Session First"); anubis.logout(); }
else if (reason === DisconnectReason.loggedOut) { console.log(`Device Logged Out, Please Scan Again And Run.`); anubis.logout(); }
else if (reason === DisconnectReason.connectionReplaced) { console.log("Connection Replaced, Another New Session Opened, Please Close Current Session First"); process.send('stop'); }
else if (reason === DisconnectReason.loggedOut) { console.log(`Device Logged Out, Please Scan Again And Run.`); delete database.data.auth[global.sesName]; await database.write(); reloadConnector(); }
else if (reason === DisconnectReason.restartRequired) { console.log("Restart Required, Restarting..."); reloadConnector(); }
else if (reason === DisconnectReason.timedOut) { console.log("Connection TimedOut, Reconnecting..."); reloadConnector(); }
else if (reason === DisconnectReason.multideviceMismatch) { console.log("Multi device mismatch, please scan again"); anubis.logout(); }
else if (reason === DisconnectReason.multideviceMismatch) { console.log("Multi device mismatch, please scan again"); delete database.data.auth[global.sesName]; await database.write(); reloadConnector() }
else anubis.end(`Unknown DisconnectReason: ${reason}|${connection}`)
}
if (update.receivedPendingNotifications) {
Expand All @@ -127,14 +127,27 @@
let a = await anubis.sendMessage(Owner + anubis.anubiskun, { text: 'Bot jalan ngab!' })
if (isLatest) anubis.sendMessage(Owner + anubis.anubiskun, { text: `New Update [ *anubisbot-MD* *v${version}* ]\n\n${changeLogs[0]}` })
if (a.status) console.log('BOT RUNNING!')
let prem = Object.entries(anubis.db.data.users).map(([key, value]) => {return {...value, jid: key}}).filter((v) => v.isPremium)
for (let user of prem){
if (user.isPremium){
if (user.premTime < (new Date() * 1)){
anubis.db.data.users[user.jid].isPremium = false
anubis.db.data.users[user.jid].premTime = -1
}
}
}
if (anubis.db.data.database.lastRestart){
a = await anubis.sendMessage(Owner + anubis.anubiskun, {text: 'Aku kembali aaay! 💖'})
if (a.status) anubis.db.data.database.lastRestart = false
}
})
}
})
anubis.ev.on('messages.upsert', (chatupdate) => {
for (let i = 0; i < chatupdate.messages.length; i++) {
const conn = anubisFunc(anubis, store)
const anu = chatupdate.messages[i];
if (!anu.message) return;
if (!anu.message && !anu.pushName) return;
anu.message = Object.keys(anu.message)[0] === "ephemeralMessage" ? anu.message.ephemeralMessage.message : anu.message;
if (anu.key && anu.key.remoteJid === "status@broadcast") return;
if (anu.key.id.startsWith("BAE5") && anu.key.id.length === 16) return;
Expand All @@ -152,10 +165,11 @@
anuCreds();
await database.write()
})
// require('./server.js')(anubis, store)
return true
}


setTimeout(async () => {
await loadDatabase()
console.log('DATABASE LOADED!')
Expand Down
11 changes: 6 additions & 5 deletions conf.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const fs = require('fs')
const path = require('path')
const yargs = require('yargs/yargs')
const opts = new Object(yargs(process.argv.slice(2)).exitProcess(false).parse())
const opts = new Object(require('yargs/yargs')(process.argv.slice(2)).exitProcess(false).parse())

global.botpublic = opts['test'] ? false : true // Bot Status
global.botpublic = true // Bot Status
global.sesName = opts['test'] ? 'anubisTest' : 'anubisAuth' // Session Folder
global.mongoUser = 'mongodb+srv://test:test123@test.onzmz8w.mongodb.net/?retryWrites=true&w=majority' //mongo uri
global.mongoUser = opts['db'] ? (typeof opts['db'] !== 'string') ? 'mongodb+srv://test:test123@test.onzmz8w.mongodb.net/?retryWrites=true&w=majority' : opts['db'] : 'mongodb+srv://test:test123@test.onzmz8w.mongodb.net/?retryWrites=true&w=majority'
global.ownerNum = ['6289653909054'] // owner number
global.fla = 'https://www6.flamingtext.com/net-fu/proxy_form.cgi?&imageoutput=true&script=sketch-name&doScale=true&scaleWidth=800&scaleHeight=500&fontsize=100&fillTextType=1&fillTextPattern=Warning!&fillColor1Color=%23f2aa4c&fillColor2Color=%23f2aa4c&fillColor3Color=%23f2aa4c&fillColor4Color=%23f2aa4c&fillColor5Color=%23f2aa4c&fillColor6Color=%23f2aa4c&fillColor7Color=%23f2aa4c&fillColor8Color=%23f2aa4c&fillColor9Color=%23f2aa4c&fillColor10Color=%23f2aa4c&fillOutlineColor=%23f2aa4c&fillOutline2Color=%23f2aa4c&backgroundColor=%23101820&text='
global.thumb = fs.readFileSync('./library/intro.mp4')
global.__root = path.join(__dirname, '/')
global.__temp = path.join(__dirname, '/temp/')
global.lastMsg = {}
global.msg = {
err: "error ngab! coba hubungi owner",
nUrl: "bad URL",
Expand All @@ -28,9 +28,10 @@ global.mess = {
global.anuCookie = {
ig: '', // instagram cookies
joox: '', // joox cookies
pinterest: '', // pinterest cookies
soundcloud: 'iZIs9mchVcX5lhVRyQGGAYlNPVldzAoX', //soundcloud client_id
}
global.pingWeb = ''
global.pingWeb = 'google.com'
global.anuFooter = 'made with ❤️ by anubis' //footer text
global.packname = 'gabut banh maknya bikin stiker!' // exif sticker package name
global.author = '6289653909054 • anubis-bot' //exif sticker author
Expand Down
2 changes: 1 addition & 1 deletion database.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{ }
Loading

0 comments on commit ef217d2

Please sign in to comment.