Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Abuzzpoet authored Nov 26, 2024
1 parent 7146370 commit 733a758
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
12 changes: 12 additions & 0 deletions system/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,18 @@ export async function getFile(PATH, save) {
}
}

/* profile picture size*/
export async function generateProfilePicture(buffer) {
const jimp = await Jimp.read(buffer)
const min = jimp.getWidth()
const max = jimp.getHeight()
const cropped = jimp.crop(0, 0, min, max)
return {
img: await cropped.scaleToFit(720, 720).getBufferAsync(Jimp.MIME_JPEG),
preview: await cropped.scaleToFit(720, 720).getBufferAsync(Jimp.MIME_JPEG)
}
}

/* fetch json */
export async function fetchJson(url, options = {}) {
let { data } = await axios(url, {
Expand Down
35 changes: 35 additions & 0 deletions system/serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,41 @@ export function Client(db, ...args) {
}
)
}

/* adreply thumbnail */
sock.sendAdT = async (jid, capt, quoted, opt = {}) => {
const buff = await func.fetchBuffer(db.setting.logo)
return sock.sendMessage(
jid,
{
text: capt || `${sock.user.name} Here`,
contextInfo: {
forwardingScore: 1,
isForwarded: true,
mentionedJid: sock.parseMention(capt),
forwardedNewsletterMessageInfo: {
newsletterJid: opt?.idch || db.setting.ch_id,
serverMessageId: 100,
newsletterName: opt?.nch || db.setting.ch_name
},
externalAdReply: {
title: opt?.title || sock.user.name,
body: opt?.body || db.setting.dev,
mediaType: 1,
renderLargerThumbnail: true,
thumbnail: buff,
mediaUrl: opt?.mediaUrl || "https://chat.whatsapp.com",
sourceUrl: opt?.sourceUrl || db.setting.url_web
}
}
},
{
quoted: quoted || null,
ephemeralExpiration: quoted ? quoted.expiration : undefined,
messageId: rand(32)
}
)
}

/* send button */
sock.sendBtn = (jid, capt, foot, quoted, btn) => {
Expand Down

0 comments on commit 733a758

Please sign in to comment.