Created
May 1, 2026 07:51
-
-
Save ayashiiiyo/656a14a286d283a6c523e1c7f5ecb2c9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import * as cheerio from 'cheerio' | |
| let handler = async (m, { conn, args, command }) => { | |
| try { | |
| if (!args || !args[0]) return m.reply(`*Example :* .${command} arial`) | |
| m.reply(global.wait) | |
| let q = args.join(' ') | |
| let url = 'https://www.dafont.com/search.php?q=' + encodeURIComponent(q) | |
| let res = await fetch(url) | |
| let html = await res.text() | |
| let $ = cheerio.load(html) | |
| let result = [] | |
| $('.lv1left.dfbg').each((i, el) => { | |
| let base = $(el) | |
| let lv2 = base.nextAll('.lv2right').first() | |
| let dlbox = base.nextAll('.dlbox').first() | |
| let previewBox = base.nextAll('.preview').first() | |
| let raw = base.text().replace(/\s+/g, ' ').trim() | |
| let author = base.find('a').first().text().trim() | |
| let name = raw.replace(/\s*by\s*.+$/i, '').trim() | |
| let info = lv2.find('.light').text().trim() | |
| let downloads = info.match(/[\d,]+ downloads/)?.[0] || null | |
| let yesterday = info.match(/\((.*?)\)/)?.[1] || null | |
| let license = lv2.find('a.help').first().text().trim() | |
| let dl = dlbox.find('a.dl').attr('href') | |
| let download = dl ? 'https:' + dl : null | |
| let style = previewBox.attr('style') | |
| let preview = style | |
| ? 'https://www.dafont.com' + (style.match(/url\((.*?)\)/)?.[1] || '') | |
| : null | |
| result.push({ | |
| name, | |
| author, | |
| downloads, | |
| yesterday, | |
| license, | |
| download, | |
| preview | |
| }) | |
| }) | |
| if (!result.length) return m.reply('Font tidak ditemukan') | |
| let txt = `` | |
| result.forEach((v, i) => { | |
| txt += `${i + 1}. *${v.name}* | |
| *Author :* ${v.author} | |
| *Downloads :* ${v.downloads} | |
| *Yesterday :* ${v.yesterday} | |
| *License :* ${v.license} | |
| ` | |
| }) | |
| txt += `> Reply Nomor Font Untuk Di Download` | |
| let sent = await conn.sendMessage(m.chat, { text: txt }, { quoted: m }) | |
| conn.font = conn.font || {} | |
| conn.font[m.chat] = { | |
| id: sent.key.id, | |
| data: result | |
| } | |
| } catch (e) { | |
| m.reply(e.message) | |
| } | |
| } | |
| handler.before = async (m, { conn }) => { | |
| try { | |
| if (!m.quoted) return false | |
| if (!conn.font || !conn.font[m.chat]) return false | |
| if (m.quoted.id !== conn.font[m.chat].id) return false | |
| let data = conn.font[m.chat].data | |
| let index = parseInt(m.text) - 1 | |
| if (!data[index]) return false | |
| let v = data[index] | |
| let detail = `*${v.name}* | |
| *Author :* ${v.author} | |
| *Downloads :* ${v.downloads} | |
| *Yesterday :* ${v.yesterday} | |
| *License :* ${v.license}` | |
| if (v.preview) { | |
| await conn.sendMessage(m.chat, { image: { url: v.preview }, caption: detail }, { quoted: m }) | |
| } else { | |
| await m.reply(detail) | |
| } | |
| if (v.download) { | |
| await conn.sendMessage(m.chat, { | |
| document: { url: v.download }, | |
| fileName: v.name + '.zip', | |
| mimetype: 'application/zip' | |
| }, { quoted: m }) | |
| } | |
| delete conn.font[m.chat] | |
| return true | |
| } catch (e) { | |
| m.reply(e.message) | |
| return true | |
| } | |
| } | |
| handler.help = ['font <text>', 'daffont <text>'] | |
| handler.command = /^(font|daffont)$/i | |
| handler.tags = ['internet'] | |
| export default handler |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment