Created
July 9, 2025 17:37
-
-
Save dipto-008/c55359f4045482c8d29d7b1e78edf2f0 to your computer and use it in GitHub Desktop.
Hey noob ๐๐
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
const { createCanvas, loadImage } = require("canvas"); | |
const axios = require("axios"); | |
const fs = require("fs-extra"); | |
const path = require("path"); | |
module.exports = { | |
config: { | |
name: "pair4", | |
version: "3.6", | |
author: "Ew'r Saim", | |
role: 0, | |
shortDescription: "Pair 2 random users or pair mention user", | |
category: "love", | |
guide: "{pn} [@mention (optional)]" | |
}, | |
onStart: async function ({ api, event, usersData }) { | |
const W = 760, H = 400; | |
const canvas = createCanvas(W, H); | |
const ctx = canvas.getContext("2d"); | |
const userID1 = event.senderID; | |
const name1 = await usersData.getName(userID1); | |
const mentionID = event.mentions && Object.keys(event.mentions)[0]; | |
const threadInfo = await api.getThreadInfo(event.threadID); | |
const allUsers = threadInfo.userInfo; | |
const botID = api.getCurrentUserID(); | |
let userID2 = mentionID; | |
if (!userID2) { | |
const gender1 = allUsers.find(u => u.id == userID1)?.gender || "UNKNOWN"; | |
let candidates = allUsers.filter(u => u.id !== userID1 && u.id !== botID); | |
if (gender1 === "MALE") | |
candidates = candidates.filter(u => u.gender === "FEMALE"); | |
else if (gender1 === "FEMALE") | |
candidates = candidates.filter(u => u.gender === "MALE"); | |
userID2 = candidates[Math.floor(Math.random() * candidates.length)]?.id; | |
} | |
if (!userID2 || userID2 === userID1) | |
return api.sendMessage("โ No valid match found. Mention someone or try again.", event.threadID); | |
const name2 = await usersData.getName(userID2); | |
const lovePercent = Math.floor(Math.random() * 31) + 70; | |
// Avatar fetching | |
const getAvatar = async (id, outPath) => { | |
const url = `https://graph.facebook.com/${id}/picture?width=720&height=720&access_token=6628568379%7Cc1e620fa708a1d5696fb991c1bde5662`; | |
const res = await axios.get(url, { responseType: "arraybuffer" }); | |
fs.writeFileSync(outPath, res.data); | |
}; | |
const tmpDir = path.join(__dirname, "cache"); | |
fs.ensureDirSync(tmpDir); | |
const avt1Path = path.join(tmpDir, "avt1.png"); | |
const avt2Path = path.join(tmpDir, "avt2.png"); | |
await getAvatar(userID1, avt1Path); | |
await getAvatar(userID2, avt2Path); | |
const avt1 = await loadImage(avt1Path); | |
const avt2 = await loadImage(avt2Path); | |
// Background gradient | |
const gradient = ctx.createLinearGradient(0, 0, 0, H); | |
gradient.addColorStop(0, "#1f0036"); | |
gradient.addColorStop(0.5, "#360060"); | |
gradient.addColorStop(1, "#1b002e"); | |
ctx.fillStyle = gradient; | |
ctx.fillRect(0, 0, W, H); | |
// Sparkles | |
for (let i = 0; i < 30; i++) { | |
const x = Math.random() * W; | |
const y = Math.random() * H; | |
const r = Math.random() * 2 + 1; | |
ctx.beginPath(); | |
ctx.arc(x, y, r, 0, 2 * Math.PI); | |
ctx.fillStyle = `rgba(255,255,255,${Math.random()})`; | |
ctx.fill(); | |
} | |
// Avatar draw | |
const drawGlowingAvatar = (img, x, y, size, glowColor) => { | |
const r = size / 2; | |
ctx.save(); | |
ctx.beginPath(); | |
ctx.arc(x + r, y + r, r + 3, 0, Math.PI * 2); | |
ctx.shadowColor = glowColor; | |
ctx.shadowBlur = 30; | |
ctx.fill(); | |
ctx.clip(); | |
ctx.drawImage(img, x, y, size, size); | |
ctx.restore(); | |
}; | |
drawGlowingAvatar(avt1, 90, 80, 160, "#ff66cc"); | |
drawGlowingAvatar(avt2, 510, 80, 160, "#66ffff"); | |
// ๐ Heart | |
ctx.font = "bold 93px Arial"; | |
ctx.fillStyle = "#ff4da6"; | |
ctx.shadowColor = "#ff99cc"; | |
ctx.shadowBlur = 25; | |
ctx.textAlign = "center"; | |
ctx.fillText("๐", W / 2, 220); | |
// Names | |
ctx.font = "bold 26px Arial"; | |
ctx.fillStyle = "#ffffff"; | |
ctx.shadowColor = "#ffccff"; | |
ctx.shadowBlur = 12; | |
ctx.fillText(name1, 170, 270); | |
ctx.fillText(name2, 590, 270); | |
// Love % | |
ctx.font = "bold 30px Arial"; | |
ctx.fillStyle = "#00ffff"; | |
ctx.shadowColor = "#00ccff"; | |
ctx.shadowBlur = 20; | |
ctx.fillText(`๐ Love Percentage ${lovePercent}% ๐`, W / 2, 330); | |
// Footer | |
ctx.font = "20px monospace"; | |
ctx.fillStyle = "#999999"; | |
ctx.shadowBlur = 0; | |
ctx.fillText("โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ", W / 2, 365); | |
// Save image | |
const outputPath = path.join(tmpDir, `pair-${event.senderID}.png`); | |
fs.writeFileSync(outputPath, canvas.toBuffer("image/png")); | |
// Stylish message body with mentions | |
const messageBody = | |
`๐ [ ๐๐๐ข๐ซ ๐๐ฎ๐๐๐๐ฌ๐ฌ๐๐ฎ๐ฅ๐ฅ ] ๐ | |
ยป ${name1} โจ | |
ยป ${name2} โจ | |
๐ ๐ ๐จ๐ซ๐๐ฏ๐๐ซ ๐๐ง๐ญ๐ฐ๐ข๐ง๐๐ ๐ข๐ง ๐ก๐๐ฉ๐ฉ๐ข๐ง๐๐ฌ๐ฌ ๐๐ง๐ ๐๐ง๐๐ฅ๐๐ฌ๐ฌ ๐๐๐๐๐๐ญ๐ข๐จ๐ง. ๐โจ | |
๐ ๐๐จ๐ฏ๐ ๐๐๐ซ๐๐๐ง๐ญ๐๐ ๐: ${lovePercent}% โจ`; | |
return api.sendMessage( | |
{ | |
body: messageBody, | |
mentions: [{ tag: name2, id: userID2 }], | |
attachment: fs.createReadStream(outputPath), | |
}, | |
event.threadID, | |
() => fs.unlinkSync(outputPath) | |
); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment