Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
izo committed Jul 2, 2021
0 parents commit bf5b2a3
Show file tree
Hide file tree
Showing 30 changed files with 1,697 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM node:lts

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install
RUN npm install --only=dev --ignore-scripts

COPY . .

RUN set -x \
&& apt-get update \
&& apt-get install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget --yes --fix-missing \
&& wget --no-check-certificate https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
&& dpkg -i google-chrome-stable_current_amd64.deb || apt -y -f install \
&& rm google-chrome-stable_current_amd64.deb \
&& apt autoremove --yes

EXPOSE 8080

CMD ["npm", "start"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 izo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Tesy-bot

## How to run the project.

* Download And Install Git [`Click Here`](https://git-scm.com/downloads)
* Download And Install NodeJS [`Click Here`](https://nodejs.org/en/download)

###### Download & Install Module
```bash
> git clone https://github.com/mrijoo/Tesy-bot.git
> cd Tesy-bot
> yarn install
```
###### Run
```bash
> yarn start [sesion name]
```
| Feature ||
| ------------- | ------------- |
| Text To Stiker ||
| Gif To Stiker||
| Image To Stiker||
| Video To Stiker ||
| SimSimi ||
| Google Text to Speech ||
| Info Gempa ||
| Screenshot Website ||
| Info Covid ||
| Kalkulator ||
| Teks Alay ||
| Arti Nama ||
| Arti Mimpi ||
| Ramal Jodoh ||
77 changes: 77 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
const {
create,
Client
} = require('@open-wa/wa-automate')
const {
color,
nocache
} = require('./util')
const updateJson = require('update-json-file');
const argsS = process.argv.slice(2)

const start = (client = new Client()) => {
console.log('[DEV]', color('mrijoo', 'green'))
console.log('[CLIENT] CLIENT Started!')

client.onAnyMessage((fn) => messageLog(fn.fromMe, fn.type))
var messageLog = function messageLog(fromMe, type) {
return updateJson('./util/stat.json', function (data) {
fromMe ? data.sent[type] ? data.sent[type] += 1 : data.sent[type] = 1 : data.receive[type] ? data.receive[type] += 1 : data.receive[type] = 1;
return data;
});
};

client.onStateChanged((state) => {
console.log('[Client State]', state)
if (state === 'CONFLICT' || state === 'DISCONNECTED') client.forceRefocus()
})

client.onMessage((message) => {
client.getAmountOfLoadedMessages().then((msg) => (msg >= 1000) && client.cutMsgCache())
require('./msgHandler')(client, message)
})

client.onAddedToGroup((chat) => {
client.sendText(chat.groupMetadata.id, `Halo member grup *${chat.contact.name}* terimakasih sudah menginvite bot`)
})

client.onIncomingCall((call) => {
client.sendText(call.peerJid, 'Maaf, bot tidak bisa menerima panggilan. Bot otomatis memblokir apabila menerima panggilan')
.then(() => client.contactBlock(call.peerJid))
})
.catch((err) => {
console.error(err)
})
}
let session
if (argsS === undefined) {
session = 'session'
nocache(session)
} else {
session = argsS
}
nocache(session)
const options = {
sessionId: `${session}`,
headless: true,
qrTimeout: 0,
authTimeout: 0,
restartOnCrash: start,
cacheEnabled: false,
useChrome: true,
killProcessOnBrowserClose: true,
throwErrorOnTosBlock: false,
chromiumArgs: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--aggressive-cache-discard',
'--disable-cache',
'--disable-application-cache',
'--disable-offline-load-stale-cache',
'--disk-cache-size=0'
]
}

create(options)
.then((client) => start(client))
.catch((err) => new Error(err))
139 changes: 139 additions & 0 deletions lib/chatAI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
const fs = require('fs')
const axios = require('axios')
let { general, apikey } = JSON.parse(fs.readFileSync('./settings.json'))

const chatAI = async (chat, isCmd, prefix) => new Promise(async (resolve) => {
var regex = /(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/g;
chat = chat.replace(regex, "");
chat = chat.toLowerCase();
let isiChat = [{
pesan: "hello",
jawaban: "Hi"
},
{
pesan: "%menu",
jawaban: `${prefix}menu untuk melihat menu`
},
{
pesan: "#menu",
jawaban: `${prefix}menu untuk melihat menu`
},
{
pesan: "/menu",
jawaban: `${prefix}menu untuk melihat menu`
},
{
pesan: "assalamualaikum",
jawaban: "Waalaikumsalam"
},
{
pesan: "apa kabar",
jawaban: "alhamdulillah baik kamu?"
},
{
pesan: "gimana kabar mu",
jawaban: "alhamdulillah baik kamu?"
},
{
pesan: "aku baik",
jawaban: "alhamdulillah kalau baik ada apa ni?"
},
{
pesan: "aku juga baik",
jawaban: "alhamdulillah kalau baik ada apa ni?"
},
{
pesan: "makasih",
jawaban: "Sama - sama"
},
{
pesan: "terima kasih",
jawaban: "Sama - sama"
},
{
pesan: "mau curhat",
jawaban: "Silakan tapi maaf kalau ga nyambung dan jangan disingkat nanti aku ga ngerti"
},
{
pesan: "boleh curhat",
jawaban: "Boleh tapi maaf kalau ga nyambung dan jangan disingkat nanti aku ga ngerti"
},
{
pesan: "bisa buatin stiker",
jawaban: "Bisa kamu kirim aja gambar dengan caption .stiker atau reply .stiker gambar yang sudah ada nanti ku buatin"
},
{
pesan: "bisa bikinin stiker",
jawaban: "Bisa kamu kirim aja gambar dengan caption .stiker atau reply .stiker gambar yang sudah ada nanti ku buatin"
},
{
pesan: "buatin stiker",
jawaban: "Kamu kirim aja gambar dengan caption .stiker atau reply .stiker gambar yang sudah ada nanti ku buatin"
},
{
pesan: "bikinin stiker",
jawaban: "Kamu kirim aja gambar dengan caption .stiker atau reply .stiker gambar yang sudah ada nanti ku buatin"
},
{
pesan: "ok",
jawaban: "Ok"
},
{
pesan: "hmm",
jawaban: "Kenapa?"
},
{
pesan: "cobaa",
jawaban: "Simply count all typed entries and divide by five to get the number of words typed. To give an example, if you typed 200 characters in 1 minute, your net wpm typing speed would be (200 characters / 5) / 1 min = 40 WPM. If you typed 200 characters in 30 seconds your net speed would be (200/5) / 0.5 = 80 WPM."
}
]

for (let i = 0; i < isiChat.length; i++) {
if (chat == "") return
if (!isCmd) {
if (chat.match(isiChat[i].pesan)) {
resolve(isiChat[i].jawaban)
break;
} else {
if (i == isiChat.length - 1) {
if (general.simsimi) {
resolve(simsimi(chat))
} else {
resolve(simi(chat))
}
break;
}
}
}
}
})

async function simi(chat) {
const respon = await axios.get(`https://api.izo.my.id/sim?text=${chat}`)
return (respon.data.result)
}

const simsimi = async (chat) => new Promise(async (resolve, reject) => {
const headers = {
"Content-Type": "application/json",
"x-api-key": apikey.simsimi,
};
const options = {
utext: chat,
lang: "id",
country: ["ID"],
atext_bad_prob_max: 0.5,
}
await axios.post("https://wsapi.simsimi.com/190410/talk", options, {
headers: headers,
})
.then(re => {
resolve(re.data.atext);
})
.catch(error => {
console.log(error)
resolve(`Simsimi Error`);
});
})

module.exports = chatAI;
Binary file added lib/font/Indie-Flower.ttf
Binary file not shown.
Binary file added lib/font/ObelixProBIt-cyr.ttf
Binary file not shown.
4 changes: 4 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exports.chatAI = require('./chatAI')
exports.removebg = require('./removebg')
exports.tsc = require('./tsc')
exports.scraper = require('./scraper')
3 changes: 3 additions & 0 deletions lib/json/bot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
""
]
4 changes: 4 additions & 0 deletions lib/json/simi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"private": [],
"grup": []
}
24 changes: 24 additions & 0 deletions lib/removebg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const fs = require('fs')
let { apikey } = JSON.parse(fs.readFileSync('./settings.json'))
const { RemoveBgResult, removeBackgroundFromImageBase64 } = require('remove.bg')

/**
* Remove Image Background
*
* @param {String} base64img
*/

const removebg = async (base64img) => new Promise(async (resolve, reject) => {
await removeBackgroundFromImageBase64({
base64img,
apiKey: apikey.removebg,
size: 'auto',
type: 'auto',
}).then((result) => {
resolve(result.base64img)
}).catch((err) => {
reject(err)
});
})

module.exports = removebg;
42 changes: 42 additions & 0 deletions lib/scraper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const fs = require('fs')
const axios = require('axios')
const {
fetchBase64
} = require('../util/fetcher')
let {
apikey
} = JSON.parse(fs.readFileSync('./settings.json'))

exports.apiflash = async (url) => new Promise((resolve, reject) => {
fetchBase64(`https://api.apiflash.com/v1/urltoimage?access_key=${apikey.apiflash}&url=${url}`)
.then((res) => {
resolve(res)
})
.catch((err) => {
reject(err)
})
})

exports.covid = (negera) => new Promise(async (resolve, reject) => {
const covid = `https://coronavirus-19-api.herokuapp.com/countries/${negera}`
axios.get(covid, {
headers: {
'Content-Type': 'application/json'
}
})
.then(res => {
const data = res.data
const judul = (`*Update Data Covid-19 ${data.country}*`)
const positif = ('\n\n😷 *Positif :* ' + data.cases)
const todaypositif = ('\n😷 *Hari ini :* ' + data.todayCases)
const meninggal = ('\n☠ *Meninggal :* ' + data.deaths)
const todaymeninggal = ('\n☠ *Hari ini :* ' + data.todayDeaths)
const sembuh = ('\n☺ *Sembuh :* ' + data.recovered)
const kata = ('\n\nTetap jaga kesehatan dan ikuti protokol kesehatan\n_#STAYATHOME #PAKAIMASKER_')
const hasil = judul + positif + todaypositif + meninggal + todaymeninggal + sembuh + kata
resolve(hasil)
})
.catch(err => {
reject(err)
})
})
Loading

0 comments on commit bf5b2a3

Please sign in to comment.