// code from goatstore // api: https://store.agi.bd const OWNER_UID = "61595102226262"; module.exports = { config: { name: "groupcontrol", aliases: ["gc", "gctl"], version: "2.0.0", author: "saju_islam", countDown: 3, role: 0, description: "Complete Group Controller", category: "group", guide: { body: "gc help\n" + "gc info\n" + "gc name \n" + "gc members\n" + "gc membercount\n" + "gc admin @mention\n" + "gc unadmin @mention\n" + "gc kick @mention\n" + "gc nick @mention \n" + "gc link\n" + "gc link on\n" + "gc link off\n" + "gc link reset\n" + "gc emoji \n" + "gc leave" } }, onStart: async function ({ api, event, args, message }) { const threadID = event.threadID; const senderID = String(event.senderID); const mentions = event.mentions || {}; const command = String(args[0] || "help").toLowerCase(); const isOwner = senderID === OWNER_UID; const reply = text => message.reply(text); function callApi(method, ...params) { return new Promise((resolve, reject) => { const fn = api[method]; if (typeof fn !== "function") { return reject( new Error("এই API method পাওয়া যায়নি: " + method) ); } try { fn.call(api, ...params, (err, result) => { if (err) return reject(err); resolve(result); }); } catch (error) { reject(error); } }); } function getMentionedIDs() { return Object.keys(mentions) .map(String) .filter(id => /^\d+$/.test(id)); } function getMentionText(uid) { const value = mentions[uid]; if (typeof value === "string") return value; return ""; } function getAdminIDs(info) { const ids = new Set(); for (const source of [ info?.adminIDs, info?.admins, info?.participantAdmins ]) { if (!source) continue; const add = item => { if (item == null) return; if (typeof item === "object") { const id = item.userID ?? item.uid ?? item.id ?? item.participantID; if (id != null) ids.add(String(id)); return; } if (/^\d+$/.test(String(item))) { ids.add(String(item)); } }; if (Array.isArray(source) || source instanceof Set) { for (const item of source) add(item); } else if (typeof source === "object") { for (const [key, value] of Object.entries(source)) { if (value === true) ids.add(String(key)); else add(value); } } } return ids; } async function getInfo() { return callApi("getThreadInfo", threadID); } async function checkPermission() { if (isOwner) return true; const info = await getInfo(); const admins = getAdminIDs(info); if (admins.has(senderID)) return true; await reply( "❌ শুধু Group Admin অথবা Owner এই command চালাতে পারবে।" ); return false; } function getAllMemberIDs(info) { return (info?.participantIDs || []).map(String); } function help() { return reply( "╭━━━「 GC CONTROLLER 」━━━╮\n" + "│ gc help\n" + "│ gc info\n" + "│ gc name <নতুন নাম>\n" + "│ gc members\n" + "│ gc membercount\n" + "│ gc admin @mention\n" + "│ gc unadmin @mention\n" + "│ gc kick @mention\n" + "│ gc nick @mention \n" + "│ gc link\n" + "│ gc link on\n" + "│ gc link off\n" + "│ gc link reset\n" + "│ gc emoji \n" + "│ gc leave\n" + "╰━━━━━━━━━━━━━━━━━━━━━━╯\n\n" + "📌 ইউজার command-এ @mention করো।" ); } // HELP if (command === "help") return help(); // INFO if (command === "info") { try { const info = await getInfo(); const members = getAllMemberIDs(info); const admins = getAdminIDs(info); return reply( "╭━━━「 GC INFO 」━━━╮\n" + "🏷️ Name: " + (info.threadName || "Unknown") + "\n" + "🆔 Thread: " + threadID + "\n" + "👥 Members: " + members.length + "\n" + "👑 Admins: " + admins.size + "\n" + "╰━━━━━━━━━━━━━━━━╯" ); } catch (error) { return reply("❌ Info error: " + error.message); } } // MEMBER COUNT if (command === "membercount" || command === "count") { try { const info = await getInfo(); return reply( "👥 GC Member Count: " + getAllMemberIDs(info).length ); } catch (error) { return reply("❌ " + error.message); } } // MEMBERS if (command === "members" || command === "member") { try { const info = await getInfo(); const members = getAllMemberIDs(info); if (!members.length) { return reply("❌ Member list পাওয়া যায়নি।"); } const admins = getAdminIDs(info); const output = [ "╭━━━「 GC MEMBERS 」━━━╮", "Total: " + members.length, "" ]; members.forEach((uid, index) => { output.push( (index + 1) + ". " + (admins.has(uid) ? "👑 " : "") + uid ); }); output.push("╰━━━━━━━━━━━━━━━━━━╯"); return reply(output.join("\n")); } catch (error) { return reply("❌ Members error: " + error.message); } } // OWNER / ADMIN CHECK try { if (!(await checkPermission())) return; } catch (error) { return reply("❌ Permission error: " + error.message); } try { switch (command) { // CHANGE GROUP NAME case "name": case "setname": { const newName = args.slice(1).join(" ").trim(); if (!newName) { return reply("ব্যবহার: gc name <নতুন নাম>"); } await callApi("setTitle", newName, threadID); return reply("✅ GC name change request পাঠানো হয়েছে।"); } // ADMIN case "admin": case "promote": { const ids = getMentionedIDs(); if (!ids.length) { return reply("❌ gc admin @mention"); } const results = []; for (const uid of ids) { try { await callApi("changeAdminStatus", threadID, uid, true); results.push("✅ Admin request: " + uid); } catch (e) { results.push("❌ " + uid + ": " + e.message); } } return reply(results.join("\n")); } // UNADMIN case "unadmin": case "demote": { const ids = getMentionedIDs(); if (!ids.length) { return reply("❌ gc unadmin @mention"); } const results = []; for (const uid of ids) { try { await callApi("changeAdminStatus", threadID, uid, false); results.push("✅ Unadmin request: " + uid); } catch (e) { results.push("❌ " + uid + ": " + e.message); } } return reply(results.join("\n")); } // KICK case "kick": case "remove": { const ids = getMentionedIDs(); if (!ids.length) { return reply("❌ gc kick @mention"); } const results = []; for (const uid of ids) { if (uid === senderID) { results.push("❌ নিজের account kick করা যাবে না।"); continue; } try { await callApi("removeUserFromGroup", uid, threadID); results.push("✅ Kick request: " + uid); } catch (e) { results.push("❌ " + uid + ": " + e.message); } } return reply(results.join("\n")); } // NICKNAME case "nick": case "nickname": { const ids = getMentionedIDs(); if (!ids.length) { return reply("❌ gc nick @mention "); } if (ids.length > 1) { return reply("❌ Nickname দিতে একবারে একজনকে mention করো।"); } const uid = ids[0]; const raw = String(event.body || ""); // Remove command prefix/name const withoutCommand = raw.replace( /^\s*(?:gc|gctl|groupcontrol)\s+nick(?:name)?\s*/i, "" ); // Remove exact mention token/text from the message let nickname = withoutCommand; const tag = getMentionText(uid); if (tag) { nickname = nickname.replace(tag, ""); } // Remove remaining @mention text nickname = nickname.replace(/@\S+/g, "").trim(); if (!nickname) { return reply( "ব্যবহার: gc nick @mention Saju Bhai\n" + "Mention-এর পরে nickname লিখো।" ); } await callApi("changeNickname", nickname, threadID, uid); return reply("✅ Nickname request পাঠানো হয়েছে: " + nickname); } // LINK COMMANDS case "link": case "invite": { const action = String(args[1] || "").toLowerCase(); if (!action) { const info = await getInfo(); const link = info?.inviteLink || info?.threadInviteLink || info?.groupInviteLink || info?.link || info?.threadInfo?.inviteLink || null; if (typeof link === "string" && /^https?:\/\//i.test(link)) { return reply("🔗 GC Invite Link:\n" + link); } return reply( "⚠️ এই API থেকে Invite Link পাওয়া যায়নি।\n" + "তোমার GoatBot fork-এ invite link retrieval support লাগবে।" ); } if (action === "on") { return reply( "⚠️ GC Link ON করার API তোমার fork-এ নিশ্চিত নয়।\n" + "এখানে কোনো fake success দেওয়া হয়নি।" ); } if (action === "off") { return reply( "⚠️ GC Link OFF করার API তোমার fork-এ নিশ্চিত নয়।\n" + "এখানে কোনো fake success দেওয়া হয়নি।" ); } if (action === "reset") { return reply( "⚠️ Invite Link reset API তোমার fork-এ নিশ্চিত নয়।" ); } return reply( "ব্যবহার:\n" + "gc link\n" + "gc link on\n" + "gc link off\n" + "gc link reset" ); } // GROUP EMOJI case "emoji": { const emoji = args.slice(1).join(" ").trim(); if (!emoji) { return reply("ব্যবহার: gc emoji ❤️"); } if (typeof api.changeThreadEmoji !== "function") { return reply( "⚠️ এই GoatBot API-তে changeThreadEmoji পাওয়া যায়নি।" ); } await callApi("changeThreadEmoji", emoji, threadID); return reply("✅ GC emoji change request পাঠানো হয়েছে।"); } // LEAVE GROUP case "leave": { await callApi("removeUserFromGroup", api.getCurrentUserID(), threadID); return reply("✅ Leave request পাঠানো হয়েছে।"); } default: return help(); } } catch (error) { return reply( "❌ Command failed!\n" + "কারণ: " + (error?.message || String(error)) ); } } };