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

Commit

Permalink
add encodeURIComponent to all api query
Browse files Browse the repository at this point in the history
  • Loading branch information
dngda committed Mar 22, 2021
1 parent 287ee08 commit 0d964df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion HandleMsg.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ module.exports = HandleMsg = async (client, message) => {
case 'nulis':
if (args.length == 0 && !isQuotedChat) return client.reply(from, `Membuat bot menulis teks yang dikirim menjadi gambar\nPemakaian: ${prefix}nulis [teks]\n\ncontoh: ${prefix}nulis i love you 3000`, id)
const nulisq = isQuotedChat ? quotedMsgObj.content.toString() : body.slice(7)
const nulisp = await api.tulis(encodeURIComponent(nulisq))
const nulisp = await api.tulis(nulisq)
await client.sendImage(from, `${nulisp}`, '', 'Nih...', id)
.catch(() => {
client.reply(from, resMsg.error.norm, id)
Expand Down
10 changes: 5 additions & 5 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const quote = async () => new Promise((resolve, reject) => {
})

const ytsearch = async (query) => new Promise((resolve, reject) => {
axios.get(`http://youtube-scrape.herokuapp.com/api/search?q=${query}`)
axios.get(`http://youtube-scrape.herokuapp.com/api/search?q=${encodeURIComponent(query)}`)
.then((res) => {
const result = res.data.results[0].video
resolve(result)
Expand All @@ -25,7 +25,7 @@ const ytsearch = async (query) => new Promise((resolve, reject) => {
})

const artinama = async (nama) => new Promise((resolve, reject) => {
axios.get(`https://arugaz.herokuapp.com/api/artinama?nama=${nama}`)
axios.get(`https://arugaz.herokuapp.com/api/artinama?nama=${encodeURIComponent(nama)}`)
.then((res) => {
resolve(res.data.result)
})
Expand All @@ -34,8 +34,8 @@ const artinama = async (nama) => new Promise((resolve, reject) => {
})
})

const cuaca = async (url) => new Promise((resolve, reject) => {
axios.get(`https://rest.farzain.com/api/cuaca.php?id=${url}&apikey=${apiFarzain}`)
const cuaca = async (daerah) => new Promise((resolve, reject) => {
axios.get(`https://rest.farzain.com/api/cuaca.php?id=${encodeURIComponent(daerah)}&apikey=${apiFarzain}`)
.then((res) => {
if (res.data.respon.cuaca == null) resolve('Maaf daerah kamu tidak tersedia')
const text = `Cuaca di: ${res.data.respon.tempat}\n\nCuaca: ${res.data.respon.cuaca}\nAngin: ${res.data.respon.angin}\nDesk: ${res.data.respon.deskripsi}\nKelembapan: ${res.data.respon.kelembapan}\nSuhu: ${res.data.respon.suhu}\nUdara: ${res.data.respon.udara}`
Expand All @@ -47,7 +47,7 @@ const cuaca = async (url) => new Promise((resolve, reject) => {
})

const tulis = async (teks) => new Promise((resolve, reject) => {
axios.get(`https://alfians-api.herokuapp.com/nulis?text=${teks}`)
axios.get(`https://alfians-api.herokuapp.com/nulis?text=${encodeURIComponent(teks)}`)
.then((res) => {
resolve(`${res.data.result}`)
})
Expand Down

0 comments on commit 0d964df

Please sign in to comment.