Skip to content

Commit

Permalink
New Ver.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlenVelocity authored Sep 17, 2020
1 parent 634e040 commit a0ca4b2
Show file tree
Hide file tree
Showing 18 changed files with 2,822 additions and 1,022 deletions.
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down Expand Up @@ -186,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [2020] [Whatsapp-Botto-Re]
Copyright [2020] [MhankBarBar]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
978 changes: 40 additions & 938 deletions index.js

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions lib/ban.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const fs = require('fs-extra')

exports.ban = async function (message) {
numBan = message.body.substring(message.body.indexOf('@') + 1)
fs.appendFileSync('./lib/ban.txt', `${message.from} ${numBan}@c.us\n`)
console.log(numBan)
}

exports.unban = async function (message) {
numUnBan = message.body.substring(message.body.indexOf('@') + 1)
fs.readFile('./lib/ban.txt', { encoding: 'utf-8'}, function (err, data) {
if (err) throw err

let dataArray = data.split('\n')
const key = `${message.from} ${numUnBan}@c.us`
let lastI = -1

for (let i = 0; i < dataArray.length; i++) {
if (dataArray[i].includes(key)) {
lastI = i
break
}
}
dataArray.splice(lastI, 1)
const dataUpdate = dataArray.join('\n')
fs.writeFile('./lib/ban.txt', dataUpdate, function(err) {
if (err) throw err
})
})
}
2 changes: 1 addition & 1 deletion lib/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ module.exports = color = (text, color) => {
case 'yellow': return '\x1b[33m' + text + '\x1b[0m'
default: return '\x1b[32m' + text + '\x1b[0m' // default is green
}
}
}
63 changes: 12 additions & 51 deletions lib/fetcher.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,12 @@
const fetch = require('node-fetch')

exports.getBase64 = getBase64 = (url) => new Promise((resolve, reject) => {
fetch(url, { headers: { 'User-Agent': 'okhttp/4.5.0' } })
.then((response) => response.buffer())
.then((result) => {
const videoBase64 = `data:${result.headers.get('content-type')};base64,` + result.toString('base64')
if (result) resolve(videoBase64)
}).catch((err) => {
console.error(err)
reject(err)
})
})

exports.fetchJson = fetchJson = (url, options) => new Promise((resolve, reject) => {
fetch(url, options)
.then(response => response.json())
.then(json => {
resolve(json)
})
.catch((err) => {
console.error(err)
reject(err)
})
})

exports.fetchText = fetchText = (url, options) => new Promise((resolve, reject) => {
fetch(url, options)
.then(response => response.text())
.then(text => {
resolve(text)
})
.catch((err) => {
console.error(err)
reject(err)
})
})

exports.fetchMeme = fetchMeme = () => new Promise((resolve, reject) => {
const subreddit = ['dankmemes', 'wholesomeanimemes', 'wholesomememes', 'AdviceAnimals', 'MemeEconomy', 'memes', 'terriblefacebookmemes', 'teenagers', 'historymemes']
const randSub = subreddit[Math.random() * subreddit.length | 0]
console.log('looking for memes on ' + randSub)
fetch('https://meme-api.herokuapp.com/gimme/' + randSub)
.then(response => response.json())
.then((result) => {
resolve(result)
}).catch((err) => {
console.error(err)
reject(err)
})
})
const fetch = require('node-fetch');

const getBase64 = async (url) => {
const response = await fetch(url, { headers: { 'User-Agent': 'okhttp/4.5.0' } });
if (!response.ok) throw new Error(`unexpected response ${response.statusText}`);
const buffer = await response.buffer();
const videoBase64 = `data:${response.headers.get('content-type')};base64,` + buffer.toString('base64');
if (buffer)
return videoBase64;
};

exports.getBase64 = getBase64;
46 changes: 46 additions & 0 deletions lib/functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const fetch = require('node-fetch')
const { getBase64 } = require("./fetcher");

const liriklagu = async (lagu) => {
const response = await fetch('http://scrap.terhambar.com/lirik?word='+lagu)
if (!response.ok) throw new Error(`unexpected response ${response.statusText}`);
const json = await response.json()
if (json.status) return `Lyrics - ${lagu}\n\n${json.result.lirik}`
}

const cerpen = async () => {
const response = await fetch('http://api.fdci.se/cerpen')
if (!response.ok) throw new Error(`nexpected response ${response.status}`)
const text = await response.text()
if (text.status) return text
}

const quotemaker = async (quotes, author = 'Zelda', type = 'random') => {
var q = quotes.replace(/ /g, '%20').replace('\n','%5Cn')
const response = await fetch(`https://terhambar.com/aw/qts/?kata=${q}&author=${author}&tipe=${type}`)
if (!response.ok) throw new Error(`unexpected response ${response.statusText}`);
const json = await response.json()
if (json.status) {
if (json.result !== '') {
const base64 = await getBase64(json.result)
return base64
}
}
}
const wall = async(query) => {
var q = query.replace(/ /g, '+')
const response = await fetch(`https://wall.alphacoders.com/api2.0/get.php?auth=3e7756c85df54b78f934a284c11abe4e&method=search&term=${q}`)
if (!response.ok) throw new Error(`unexpected response ${response.statusText}`)
const json = await response.json()
console.log(json)
if (json.success === true) {
return json.wallpapers[0].url_image
} else {
return `https://c4.wallpaperflare.com/wallpaper/976/117/318/anime-girls-404-not-found-glowing-eyes-girls-frontline-wallpaper-preview.jpg`
}
}

exports.liriklagu = liriklagu;
exports.quotemaker = quotemaker;
exports.cerpen = cerpen;
exports.wall = wall;
16 changes: 16 additions & 0 deletions lib/giphy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const request = require('request')

module.exports = uploadToGiphy = (postData) => {
var opt = {
url: 'https://upload.giphy.com/v1/gifs?api_key=' + postData.api_key,
formData: postData,
json: true
}
const p = new Promise((resolve, reject) => {
request.post(opt, function (e, resp, body) {
if(e || resp.statusCode !== 200) console.log('Upload giphy failed!')
resolve('https://media.giphy.com/media/' + body.data.id + '/giphy.gif')
})
})
return p
}
116 changes: 116 additions & 0 deletions lib/help.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
function help( pushname ) {
return `πŸ‘‹οΈHi ${pushname}, I'm Emilia!
Prefix - #
🌟️ Command List 🌟️
*_CMD: #profile_*
*Description: Displays the information of the user*
*_CMD: #info_*
*Description: Displays the information about the bot* 🌐️
*_CMD: #sticker_*
*Description: Turns images into stickers* πŸ”–οΈ
Usage: #sticker as caption of picture
*_CMD: #gsticker <giphy URL>_*
*Description: Turns gifs into stickers* 🌠️
*_CMD: #sauce_*
*Description: Give's the title of the picture specified* ❀️
Usage: #sauce as the caption or reply of any picture
*_CMD: #pokemon_*
*Description: Returns picture of a random Pokemon* 😺️
*_CMD: #waifu_*
*Description: Returns picture of a random waifu* πŸ’ŒοΈ
*_CMD: #anime <anime name>_*
Description: Returns the information of the given anime* πŸ“ΊοΈ
Usage: #anime sakura trick
*_#tts <language-code> <text>_* [Disabled due to ban-risk]
*Description: Converts text to speech* πŸ—£οΈ
Usage: #tts en I love Emilia
*_#quotemaker | quote | author |_*
*Description: Convert the given quote to an image*
Usage: #qm | Courage need not to be remembered, for it is never forgotten | Emilia 🌌️
*_#lyrics <song name>_*
*Description: Displays the lyricsof the given song* 🎢️
Usage: #lyrics Shinzou wo sasageyo
*_CMD: #neko_*
*Description: Displays picture of a random cat* 🐈️
*_CMD: #animeneko_*
Description: Displays picture of an anime cat ;)* πŸ’šοΈ
*_CMD: #wallpaper <keyword>_*
*Description: Returns a random anime wallpaper based on the keyword* πŸ“±οΈ
Usage: #wallpaper Black Butler
*_CMD: #covid <country>_*
*Description: Displays the live stats of Covid-19 of the given country* 🌍️
Usage: #covid Japan
*_CMD: #meme_*
*Description: Returns a random meme 🎷️
*_CMD: #sr <subreddit_title>_*
*Description: Displays a post from the given subreddit* πŸ’»οΈ
Usage: #sr Emilia
*_CMD: #quotes_* [Disabled]
*Description: Returns a quote that will either give you existential crises or wisdom* 🌠️
*_CMD: #groupinfo_*
*Description: Displays the information of the group* ⛱️
*_CMD: #roll_*
*Description: Rolls a dice* 🎲
*_CMD: #flip_*
*Description: Flips a coin* 🟑
Admin Commands πŸ“™οΈ
Only group admins can execute this command
*_CMD: #ping <text>_*
*Description: Tags all members in the group* πŸ”ŠοΈ
Usage: #ping Well, in that case
*_CMD: #delete_*
Description: Deletes the Bot's message* πŸ’”οΈ
Usage: Send #delete as reply to the bot's message
To execute the following commands the bot and the author needs to be admin
*_CMD: #seticon_*
*Description: Sets the quoted image as the group icon* πŸŽ†οΈ
*_CMD: #kick @user_*
*Description: Kicks the mentioned person from the group* 🏌️
*_CMD: #promote @user_*
*Description: Makes the metioned user admin* πŸ‘‘οΈ
*_CMD: #demote @user_*
*Description: Demotes the mentioned user from adminship* πŸ’”οΈ
There are many hidden and fun keywords ;)
Hope you have a great day!`
}
exports.help = help()
function info() {
return 'πŸ‘‹οΈHi there, I\'m Emilia\nThis project is open source, built using Javascript || Node.js and is available at GitHub https:\/\/bit.ly\/39Ld2L8 (Updated).\n\n *Creators*πŸ‘‘οΈ\n\n_Emilia Yohannan (Ban Takahiro)_ \n _Somnath Das (Takeshi Stark)_ \n\n*Developers*✨\n \n _Emilia Yohannan_ \n_Somnath Das_\n_Dominik Heiing_\n\n*Contributors*πŸ’«\n\n_Miliana Blue_\n_Aman Sakuya_\n_Mystery_\n_ShellTear_'
}
exports.info = info()

21 changes: 21 additions & 0 deletions lib/msgFilter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const usedCommandRecently = new Set()

/**
* Check is number filtered
* @param {String} from
*/
const isFiltered = (from) => !!usedCommandRecently.has(from)

/**
* Add number to filter
* @param {String} from
*/
const addFilter = (from) => {
usedCommandRecently.add(from)
setTimeout(() => usedCommandRecently.delete(from), 5000) // 5sec is delay before processing next command
}

module.exports = {
isFiltered,
addFilter
}
Loading

0 comments on commit a0ca4b2

Please sign in to comment.