-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
634e040
commit a0ca4b2
Showing
18 changed files
with
2,822 additions
and
1,022 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.