Created
July 9, 2025 13:52
-
-
Save dipto-008/94a57a741ac0f01141a5228c22bd2003 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 axios = require("axios"); | |
module.exports = { | |
config: { | |
name: "album", | |
version: "1.0", | |
role: 0, | |
author: "Bokkor", | |
category: "media", | |
guide: { en: "" } | |
}, | |
onStart: async function ({ api, event, args }) { | |
const base = "https://album-bokkor-x69.onrender.com/api/album"; | |
async function uploadToDrive(fileUrl) { | |
try { | |
const res = await axios.get(`https://noobs-api.top/dipto/drive?url=${encodeURIComponent(fileUrl)}`); | |
if (!res.data?.url) throw new Error("Upload failed"); | |
return res.data.url; | |
} catch (err) { | |
console.error("โ Drive Upload Error:", err.message); | |
throw err; | |
} | |
} | |
if (args[0] === "add") { | |
const category = args[1]; | |
let videoUrl = event.messageReply?.attachments?.[0]?.url || args[2]; | |
if (!category || !videoUrl) | |
return api.sendMessage( | |
"โ Provide category and video URL or reply with a video", | |
event.threadID, | |
event.messageID | |
); | |
if (event.messageReply?.attachments?.[0]) { | |
try { | |
api.sendMessage("โณ Uploading please wait...", event.threadID); | |
videoUrl = await uploadToDrive(videoUrl); | |
} catch (err) { | |
return api.sendMessage("โ Failed to upload video to Drive", event.threadID, event.messageID); | |
} | |
} | |
const res = await axios.get(`${base}/add/${category}?url=${encodeURIComponent(videoUrl)}`); | |
if (res.data?.error) | |
return api.sendMessage(res.data.error, event.threadID, event.messageID); | |
return api.sendMessage( | |
`โ Video successfully added to category: ${category}`, | |
event.threadID, | |
event.messageID | |
); | |
} | |
if (!args[0] || args[0] === "list") { | |
try { | |
const res = await axios.get(`${base}/list`); | |
const data = res.data?.data || {}; | |
if (Object.keys(data).length === 0) | |
return api.sendMessage("โ No categories found", event.threadID, event.messageID); | |
let msg = "๐ค ๐๐๐'๐ ๐จ๐๐๐๐ ๐ช๐๐๐๐๐๐๐๐๐ ๐ค\n\n"; | |
let index = 1; | |
function toFancy(str) { | |
const normal = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |
const fancy = "๐จ๐ฉ๐ช๐ซ๐ฌ๐ญ๐ฎ๐ฏ๐ฐ๐ฑ๐ฒ๐ณ๐ด๐ต๐ถ๐ท๐ธ๐น๐บ๐ป๐ผ๐ฝ๐พ๐ฟ๐๐๐๐๐๐ ๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐ข๐ฃ๐ค๐ฅ๐ฆ๐ง๐จ๐ฉ๐ช๐ซ"; | |
return str.split("").map(c => { | |
const i = normal.indexOf(c); | |
return i === -1 ? c : fancy[i]; | |
}).join(""); | |
} | |
function capitalize(str) { | |
return str.charAt(0).toUpperCase() + str.slice(1); | |
} | |
for (const [cat, count] of Object.entries(data)) { | |
msg += `๐ค ${toFancy(index.toString())}. ${toFancy(capitalize(cat))}\n ๐ ๐ฝ๐๐ ๐๐๐: ${toFancy(count.toString())}\n\n`; | |
index++; | |
} | |
const time = new Date().toLocaleString("en-US", { | |
timeZone: "Asia/Dhaka", | |
hour12: true, | |
year: "numeric", | |
month: "2-digit", | |
day: "2-digit", | |
hour: "2-digit", | |
minute: "2-digit", | |
}); | |
msg += `๐ ๐ผ๐๐ ๐๐๐๐ : ${toFancy(time)}`; | |
return api.sendMessage(msg.trim(), event.threadID, event.messageID); | |
} catch { | |
return api.sendMessage("โ Error fetching list", event.threadID, event.messageID); | |
} | |
} | |
// Get video from category | |
try { | |
const res = await axios.get(`${base}/${args[0]}`); | |
if (!res?.data?.video) | |
return api.sendMessage("โ Not found", event.threadID, event.messageID); | |
const msg = `๐๐ฆ๐ณ๐ฆ ๐ ๐ฐ๐ถ๐ณ ${res.data.category} ๐๐ช๐ฅ๐ฆ๐ฐ ๐ฃ๐ฃ๐บ ๐`; | |
const videoStream = await global.utils.getStreamFromURL(res.data.video); | |
return api.sendMessage( | |
{ body: msg, attachment: videoStream }, | |
event.threadID, | |
event.messageID | |
); | |
} catch { | |
return api.sendMessage("โ Error fetching video", event.threadID, event.messageID); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment