Skip to content

Instantly share code, notes, and snippets.

@dipto-008
Created July 9, 2025 13:52
Show Gist options
  • Save dipto-008/94a57a741ac0f01141a5228c22bd2003 to your computer and use it in GitHub Desktop.
Save dipto-008/94a57a741ac0f01141a5228c22bd2003 to your computer and use it in GitHub Desktop.
Hey noob ๐Ÿ‘‹๐Ÿ‘‹
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