From 97b10757ba70aa8cbb3adbb99eb5b5123f9bbc9f Mon Sep 17 00:00:00 2001 From: Alen Yohannan <66544823+AlenSaito1@users.noreply.github.com> Date: Wed, 23 Sep 2020 17:22:35 +0530 Subject: [PATCH] Premium Features --- index.js | 13 +++------- lib/help.js | 1 + lib/nsfw.json | 1 + lib/welcome.json | 1 + msgHandler.js | 65 ++++++++++++++++-------------------------------- 5 files changed, 27 insertions(+), 54 deletions(-) create mode 100644 lib/nsfw.json create mode 100644 lib/welcome.json diff --git a/index.js b/index.js index f9af3fb..85bfe37 100644 --- a/index.js +++ b/index.js @@ -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, @@ -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') { @@ -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 diff --git a/lib/help.js b/lib/help.js index 36fe514..ff24796 100644 --- a/lib/help.js +++ b/lib/help.js @@ -117,3 +117,4 @@ function info() { } exports.info = info() + diff --git a/lib/nsfw.json b/lib/nsfw.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/lib/nsfw.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/lib/welcome.json b/lib/welcome.json new file mode 100644 index 0000000..03128ce --- /dev/null +++ b/lib/welcome.json @@ -0,0 +1 @@ +["919744375687-1600492924@g.us","919744375687-1600492924@g.us"] \ No newline at end of file diff --git a/msgHandler.js b/msgHandler.js index 1aaffee..5d09b24 100644 --- a/msgHandler.js +++ b/msgHandler.js @@ -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) @@ -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) { @@ -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: { @@ -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(' ') @@ -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]) @@ -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) @@ -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'