Skip to content

Commit

Permalink
Premium Features
Browse files Browse the repository at this point in the history
  • Loading branch information
AlenVelocity authored Sep 23, 2020
1 parent 6c1f836 commit 97b1075
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 54 deletions.
13 changes: 3 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { create } = require('@open-wa/wa-automate')
const msgHandler = require('./msgHandler')
const fs = require('fs-extra')
const serverOption = {
headless: true,
cacheEnabled: false,
Expand All @@ -17,7 +18,7 @@ const serverOption = {

const opsys = process.platform
if (opsys === 'win32' || opsys === 'win64') {
serverOption.executablePath = 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
serverOption.executablePath = 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'
} else if (opsys === 'linux') {
serverOption.browserRevision = '737027'
} else if (opsys === 'darwin') {
Expand All @@ -36,15 +37,7 @@ const startServer = async (client) => {
msgHandler(client, message)
})

client.onGlobalParicipantsChanged((x) => {
const { action, who , chat} = x
const groupPic = client.getProfilePicFromServer(chat.id)
const { desc } = chat.groupMetadata
console.log(x)
console.log(chat.id)
console.log(chat.groupMetadata)
if (action === 'add') return client.sendFileFromUrl(chat, groupPic, 'groupPic.jpg', `Hello New Member!, Welcome to *${chat.name}* Group description ✨️ \n ${desc}`)
})


client.onAddedToGroup((chat) => {
let totalMem = chat.groupMetadata.participants.length
Expand Down
1 change: 1 addition & 0 deletions lib/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,4 @@ function info() {
}
exports.info = info()


1 change: 1 addition & 0 deletions lib/nsfw.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions lib/welcome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["[email protected]","[email protected]"]
65 changes: 21 additions & 44 deletions msgHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ 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 owner = '919744375687' // eg 9190xxxxxxxx@
const owner = 'Your-phone-number' // eg 9190xxxxxxxx
const isowner = owner+'@c.us' == sender.id

msgFilter.addFilter(from)
Expand Down Expand Up @@ -79,12 +79,6 @@ module.exports = msgHandler = async (client, message) => {
}
}
break
/* case 'tsticker' :
Paid Feature
*/

case 'gsticker':
if (isMedia && type == 'video') {
if (mimetype === 'video/mp4' && message.duration < 30) {
Expand All @@ -97,7 +91,7 @@ module.exports = msgHandler = async (client, message) => {
return console.log(err)
}
var postData = {
api_key: 'your_giphy_api_key', // https://devlopers.giphy.com
api_key: 'giphy key', // paid
file: {
value: fs.createReadStream(filename),
options: {
Expand Down Expand Up @@ -159,23 +153,6 @@ module.exports = msgHandler = async (client, message) => {
client.reply(from, 'Usage: \n!quotemaker |text|watermark|theme\n\nEx :\n!quotemaker |...|...|random', message.id)
}
break
case 'bc':
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) {
var cvk = await client.getChatById(ids)
if (!cvk.isReadOnly) client.sendText(ids, `[ EWH BOT Broadcast ]\n\n${msg}`)
}
client.reply(from, 'Broadcast Success!', message.id)
break
case 'ban':
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))
client.reply(from, 'Succes ban target!', message.id)
}
break
case 'covid':
arg = body.trim().split(' ')
Expand Down Expand Up @@ -221,6 +198,24 @@ module.exports = msgHandler = async (client, message) => {
}
client.reply(from, 'Done', message.id)
break

case 'sr':
arg = body.trim().split(' ')
const sr = arg[1]
try {
const response1 = await axios.get('https://meme-api.herokuapp.com/gimme/' + sr + '/');
const {
postLink,
title,
subreddit,
url,
nsfw,
spoiler
} = response1.data

await client.sendFileFromUrl(from, `${url}`, 'Reddit.jpg', `${title}` + '\n\nPostlink:' + `${postLink}`)

break
case 'unban':
if(!isowner) return client.reply(from, 'Only bot admins can use this CMD', message.id)
let inx = ban.indexOf(mentionedJidList[0])
Expand Down Expand Up @@ -321,24 +316,6 @@ module.exports = msgHandler = async (client, message) => {
}
}
break
case 'sr':
arg = body.trim().split(' ')
const sr = arg[1]
try {
const response1 = await axios.get('https://meme-api.herokuapp.com/gimme/' + sr + '/');
const {
postLink,
title,
subreddit,
url,
nsfw,
spoiler
} = response1.data
await client.sendFileFromUrl(from, `${url}`, 'Reddit.jpg', `${title}` + '\n\nPostlink:' + `${postLink}`)
} catch(err) {
await client.reply(from, 'There is no such subreddit, Baka!', id)
}
break
case 'lyrics':
if (args.length == 0) return client.reply(from, 'Wrong Format', message.id)
const lagu = body.slice(7)
Expand Down Expand Up @@ -443,7 +420,7 @@ module.exports = msgHandler = async (client, message) => {
client.reply(from, help.replace(undefined, pushname), message.id)
break
case 'info':
client.sendLinkWithAutoPreview(from, 'https://github.com/SomnathDas/whatsapp-botto-re', info)
client.reply(from, info, id)
break
case 'profile':
var role = 'None'
Expand Down

0 comments on commit 97b1075

Please sign in to comment.