Skip to content

Commit

Permalink
[ Jessi-md 4.8.5 ⏱️ ]
Browse files Browse the repository at this point in the history
  • Loading branch information
whiteshadowofficial authored Mar 8, 2024
1 parent 7b1d74c commit b7d61f3
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions plugins/PDF-url-pdf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import fetch from "node-fetch"

let handler = async (m, {
conn,
usedPrefix,
args,
command
}) => {
let query = "Where is the link? The link you want to convert to pdf!\n Example :\n .urltopdf https://github.com/whiteshadowofficial/Jessi-md"
let text
if (args.length >= 1) {
text = args.slice(0).join(" ")
} else if (m.quoted && m.quoted.text) {
text = m.quoted.text
} else throw query
await m.reply(wait)

if (!isValidURL(text)) return m.reply("*The link is not available or is not transferable. Try again with another link*")
try {
let gas = "https://api.html2pdf.app/v1/generate?url=" + text + "&apiKey=DzhGk9fhdPope6j8PmVmbxoNDDiWbsFpdeKZfMMrrxtsl3pXCRbfYOd7N4HovaJ1"
await conn.sendFile(m.chat, gas, m.name, text, m)
} catch (e) {
await m.reply('error')
}
}
handler.tags = ["pdf"]
handler.command = handler.help = ["urltopdf"]
export default handler

function isValidURL(message) {
const urlPattern = /https?:\/\/[^\s/$.?#].[^\s]*/;
return urlPattern.test(message);
}

0 comments on commit b7d61f3

Please sign in to comment.