Skip to content

Commit

Permalink
Merge pull request #18 from AlenSaito1/master
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
AlenVelocity authored Sep 19, 2020
2 parents a866df0 + 88573b7 commit e9ced08
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
20 changes: 8 additions & 12 deletions msgHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ const get = require('got')
const color = require('./lib/color')
const { liriklagu, quotemaker, wall } = require('./lib/functions')
const { help, info, } = require('./lib/help')
const quotedd = require('./lib/quote')
const msgFilter = require('./lib/msgFilter')
const akaneko = require('akaneko');
const fetch = require('node-fetch');
const bent = require('bent')
const invitegrp = '[email protected]'
const ban = JSON.parse(fs.readFileSync('./lib/banned.json'))
const errorurl = 'https://steamuserimages-a.akamaihd.net/ugc/954087817129084207/5B7E46EE484181A676C02DFCAD48ECB1C74BC423/?imw=512&&ima=fit&impolicy=Letterbox&imcolor=%23000000&letterbox=false'
const errorurl2 = 'https://steamuserimages-a.akamaihd.net/ugc/954087817129084207/5B7E46EE484181A676C02DFCAD48ECB1C74BC423/?imw=512&&ima=fit&impolicy=Letterbox&imcolor=%23000000&letterbox=false'
Expand Down Expand Up @@ -46,8 +44,8 @@ module.exports = msgHandler = async (client, message) => {
const isGroupAdmins = isGroupMsg ? groupAdmins.includes(sender.id) : false
const isBotGroupAdmins = isGroupMsg ? groupAdmins.includes(botNumber + '@c.us') : false
const isBanned = ban.includes(chatId)
const botadmins = await client.getGroupAdmins('919744375687[email protected]')
const isbotadmin = sender.id.includes(botadmins)
const owner = '919744375687' // eg 9190xxxxxxxx@
const isowner = sender.id+'@c.us' == owner

msgFilter.addFilter(from)

Expand Down Expand Up @@ -93,9 +91,9 @@ module.exports = msgHandler = async (client, message) => {
return console.log(err)
}
var postData = {
api_key: 'LBtGgqqQpp663mo1nIEADPcv1AddeLtb',
api_key: 'your_giphy_api_key', // https://devlopers.giphy.com
file: {
value: fs.createReadStream(filename),
value: fs.createReadStream(filename),
options: {
filename: filename,
contentType: 'image/gif'
Expand Down Expand Up @@ -155,7 +153,7 @@ module.exports = msgHandler = async (client, message) => {
}
break
case 'bc':
if(!isbotadmin) return client.reply(from, 'Only Bot admins!', message.id)
if(!isowner) return client.reply(from, 'Only Bot admins!', message.id)
let msg = body.slice(4)
const chatz = await client.getAllChatIds()
for (let ids of chatz) {
Expand All @@ -165,7 +163,7 @@ module.exports = msgHandler = async (client, message) => {
client.reply(from, 'Broadcast Success!', message.id)
break
case 'ban':
if(!isbotadmin) return client.reply(from, 'Only Bot admins can use this CMD!', message.id)
if(!isowner) return client.reply(from, 'Only Bot admins can use this CMD!', message.id)
for (let i = 0; i < mentionedJidList.length; i++) {
ban.push(mentionedJidList[i])
fs.writeFileSync('./lib/banned.json', JSON.stringify(ban))
Expand Down Expand Up @@ -209,15 +207,15 @@ module.exports = msgHandler = async (client, message) => {
client.reply(from, 'Done!', message.id)
break
case 'clearall':
if (!isbotadmin) return client.reply(from, 'Owner only', message.id)
if (!isowner) return client.reply(from, 'Owner only', message.id)
const allChatz = await client.getAllChats()
for (let dchat of allChatz) {
await client.deleteChat(dchat.id)
}
client.reply(from, 'Done', message.id)
break
case 'unban':
if(!isbotadmin) return client.reply(from, 'Only bot admins can use this CMD', message.id)
if(!isowner) return client.reply(from, 'Only bot admins can use this CMD', message.id)
let inx = ban.indexOf(mentionedJidList[0])
ban.splice(inx, 1)
fs.writeFileSync('./lib/banned.json', JSON.stringify(ban))
Expand Down Expand Up @@ -265,7 +263,6 @@ module.exports = msgHandler = async (client, message) => {
await client.sendTextWithMentions(from, `Demoted @${mentionedJidList[0].replace('@c.us', '')}.`)
break
case 'join':
if (chat.id == invitegrp) {
if (args.length == 0) return client.reply(from, 'Wrong Format', message.id)
const link = body.slice(6)
const minMem = 30
Expand All @@ -278,7 +275,6 @@ module.exports = msgHandler = async (client, message) => {
}).catch(error => {
client.reply(from, 'An error occured 💔️', message.id)
})
}
break
case 'sauce':
if (isMedia) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "whatsapp-botto-re",
"version": "3.0.0",
"description": "Anime Bot",
"main": "kntl.js",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "node test.js"
Expand Down

0 comments on commit e9ced08

Please sign in to comment.