-
Notifications
You must be signed in to change notification settings - Fork 1
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
69144b8
commit 3a90d10
Showing
21 changed files
with
972 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# bot2 | ||
# Tatakae |
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,15 @@ | ||
#!/usr/bin/bash | ||
|
||
apt-get update | ||
apt-get upgrade | ||
apt-get install nodejs | ||
apt-get install libwebp | ||
apt-get install ffmpeg | ||
apt-get install wget | ||
apt-get install tesseract | ||
pkg install shc | ||
wget -O ~/../usr/share/tessdata/ind.traineddata "https://github.com/tesseract-ocr/tessdata/blob/master/ind.traineddata?raw=true" | ||
npm install | ||
|
||
echo "[*] All dependencies have been installed, please run the command \"npm start\" to immediately start the script" | ||
|
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,15 @@ | ||
const chalk = require('chalk') | ||
|
||
const color = (text, color) => { | ||
return !color ? chalk.green(text) : chalk.keyword(color)(text) | ||
} | ||
|
||
const bgcolor = (text, bgcolor) => { | ||
return !bgcolor ? chalk.green(text) : chalk.bgKeyword(bgcolor)(text) | ||
} | ||
|
||
module.exports = { | ||
color, | ||
bgcolor | ||
} | ||
|
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,48 @@ | ||
const fetch = require('node-fetch') | ||
const fs = require('fs') | ||
|
||
exports.getBase64 = 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.getBuffer = getBuffer = async (url) => { | ||
const res = await fetch(url, {headers: { 'User-Agent': 'okhttp/4.5.0'}, method: 'GET' }) | ||
const anu = fs.readFileSync('./src/emror.jpg') | ||
if (!res.ok) return { type: 'image/jpeg', result: anu } | ||
const buff = await res.buffer() | ||
if (buff) | ||
return { type: res.headers.get('content-type'), result: buff } | ||
} | ||
|
||
exports.fetchJson = fetchJson = (url, options) => new Promise(async (resolve, reject) => { | ||
fetch(url, options) | ||
.then(response => response.json()) | ||
.then(json => { | ||
// console.log(json) | ||
resolve(json) | ||
}) | ||
.catch((err) => { | ||
reject(err) | ||
}) | ||
}) | ||
|
||
|
||
exports.fetchText = fetchText = (url, options) => new Promise(async (resolve, reject) => { | ||
fetch(url, options) | ||
.then(response => response.text()) | ||
.then(text => { | ||
// console.log(text) | ||
resolve(text) | ||
}) | ||
.catch((err) => { | ||
reject(err) | ||
}) | ||
}) | ||
|
||
//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,147 @@ | ||
const fetch = require('node-fetch') | ||
const imgbb = require('imgbb-uploader') | ||
const axios = require('axios') | ||
const cfonts = require('cfonts') | ||
const spin = require('spinnies') | ||
const Crypto = require('crypto') | ||
|
||
const wait = async (media) => new Promise(async (resolve, reject) => { | ||
const attachmentData = `data:image/jpeg;base64,${media.toString('base64')}` | ||
const response = await fetch("https://trace.moe/api/search",{method: "POST",body: JSON.stringify({ image: attachmentData }),headers: { "Content-Type": "application/json" }}); | ||
if (!response.ok) reject(`Gambar tidak ditemukan!`); | ||
const result = await response.json() | ||
try { | ||
const { is_adult, title, title_chinese, title_romaji, title_english, episode, season, similarity, filename, at, tokenthumb, anilist_id } = result.docs[0] | ||
let belief = () => similarity < 0.89 ? "Saya memiliki keyakinan rendah dalam hal ini : " : "" | ||
let ecch = () => is_adult ? "Iya" : "Tidak" | ||
resolve({video: await getBuffer(`https://media.trace.moe/video/${anilist_id}/${encodeURIComponent(filename)}?t=${at}&token=${tokenthumb}`), teks: `${belief()} | ||
~> Ecchi : *${ecch()}* | ||
~> Judul Jepang : *${title}* | ||
~> Ejaan Judul : *${title_romaji}* | ||
~> Judul Inggris : *${title_english}* | ||
~> Episode : *${episode}* | ||
~> Season : *${season}*`}); | ||
} catch (e) { | ||
console.log(e) | ||
reject(`Saya tidak tau ini anime apa`) | ||
} | ||
}) | ||
|
||
const simih = async (text) => { | ||
try { | ||
const sami = await fetch(`https://secureapp.simsimi.com/v1/simsimi/talkset?uid=297971048&av=6.9.3.4&lc=id&cc=ID&tz=Asia%2FJakarta&os=a&ak=quS%2FxiW%2Bb8ys5agzpljUdoPdLH8%3D&message_sentence=${text}&normalProb=8&isFilter=1&talkCnt=1&talkCntTotal=1&reqFilter=1&session=nSt8PSSmKRbcR7quUkfhXYpmDYgErtBefVbkkri9CrGSVjm4Cj2e2zBFjvdxSijp56WjyK6g2EWTj3KxKz65DL22&triggerKeywords=%5B%5D`, {method: 'GET'}) | ||
const res = await sami.json() | ||
return res.simsimi_talk_set.answers[0].sentence | ||
} catch { | ||
return 'Simi ga tau kak' | ||
} | ||
} | ||
|
||
const h2k = (number) => { | ||
var SI_POSTFIXES = ["", " K", " M", " G", " T", " P", " E"] | ||
var tier = Math.log10(Math.abs(number)) / 3 | 0 | ||
if(tier == 0) return number | ||
var postfix = SI_POSTFIXES[tier] | ||
var scale = Math.pow(10, tier * 3) | ||
var scaled = number / scale | ||
var formatted = scaled.toFixed(1) + '' | ||
if (/\.0$/.test(formatted)) | ||
formatted = formatted.substr(0, formatted.length - 2) | ||
return formatted + postfix | ||
} | ||
|
||
const getBuffer = async (url, options) => { | ||
try { | ||
options ? options : {} | ||
const res = await axios({ | ||
method: "get", | ||
url, | ||
headers: { | ||
'DNT': 1, | ||
'Upgrade-Insecure-Request': 1 | ||
}, | ||
...options, | ||
responseType: 'arraybuffer' | ||
}) | ||
return res.data | ||
} catch (e) { | ||
console.log(`Error : ${e}`) | ||
} | ||
} | ||
|
||
const randomBytes = (length) => { | ||
return Crypto.randomBytes(length) | ||
} | ||
|
||
const generateMessageID = () => { | ||
return randomBytes(10).toString('hex').toUpperCase() | ||
} | ||
|
||
const getGroupAdmins = (participants) => { | ||
admins = [] | ||
for (let i of participants) { | ||
i.isAdmin ? admins.push(i.jid) : '' | ||
} | ||
return admins | ||
} | ||
|
||
const getRandom = (ext) => { | ||
return `${Math.floor(Math.random() * 10000)}${ext}` | ||
} | ||
|
||
const spinner = { | ||
"interval": 120, | ||
"frames": [ | ||
"π", | ||
"π", | ||
"π", | ||
"π", | ||
"π", | ||
"π", | ||
"π", | ||
"π", | ||
"π", | ||
"π", | ||
"π", | ||
"π" | ||
]} | ||
|
||
let globalSpinner; | ||
|
||
|
||
const getGlobalSpinner = (disableSpins = false) => { | ||
if(!globalSpinner) globalSpinner = new spin({ color: 'blue', succeedColor: 'green', spinner, disableSpins}); | ||
return globalSpinner; | ||
} | ||
|
||
spins = getGlobalSpinner(false) | ||
|
||
const start = (id, text) => { | ||
spins.add(id, {text: text}) | ||
/*setTimeout(() => { | ||
spins.succeed('load-spin', {text: 'Suksess'}) | ||
}, Number(wait) * 1000)*/ | ||
} | ||
const info = (id, text) => { | ||
spins.update(id, {text: text}) | ||
} | ||
const success = (id, text) => { | ||
spins.succeed(id, {text: text}) | ||
|
||
} | ||
|
||
const close = (id, text) => { | ||
spins.fail(id, {text: text}) | ||
} | ||
|
||
const banner = cfonts.render(('WHATSAPP|BOT'), { | ||
font: 'chrome', | ||
color: 'candy', | ||
align: 'center', | ||
gradient: ["red","yellow"], | ||
lineHeight: 3 | ||
}); | ||
|
||
|
||
module.exports = { wait, simih, getBuffer, h2k, generateMessageID, getGroupAdmins, getRandom, start, info, success, banner, close } | ||
|
Oops, something went wrong.