// code from goatstore // api: https://store.agi.bd const { getStreamsFromAttachment, log } = global.utils; const mediaTypes = ["photo", "png", "animated_image", "video", "audio"]; module.exports = { config: { name: "callad", aliases: ["call", "called"], version: "2.1", author: "NTKhang | fixed by nabin", countDown: 5, role: 0, category: "contacts admin", description: { en: "Send a message or report directly to bot admins" }, guide: { en: "{pn} " } }, langs: { en: { missingMessage: "โ— Please write a message to send.", noAdmin: "โš ๏ธ No admin found. Please configure adminBot.", sentFromGroup: "\n๐Ÿ‘ฅ Group: %1\n๐Ÿงต Thread ID: %2", sentFromUser: "\n๐Ÿ‘ค Sent from private chat", userContent: "\n\n๐Ÿ“ฉ Message:\n%1\n\nโ†ฉ๏ธ Reply to respond", success: "โœ… Message sent to %1 admin(s).", failed: "โŒ Failed to send your message to any admin.", adminReply: "๐Ÿ“ Admin Reply\n\n๐Ÿ‘ค %1:\n%2", replySuccess: "โœ… Reply sent successfully.", replyFailed: "โŒ Failed to send reply." } }, onStart: async function ({ args, message, event, usersData, threadsData, api, commandName, getLang }) { try { const text = args.join(" ").trim(); const attachments = [ ...(event.attachments || []), ...((event.messageReply && event.messageReply.attachments) || []) ].filter(item => mediaTypes.includes(item.type)); if (!text && attachments.length === 0) { return message.reply(getLang("missingMessage")); } const adminBot = global.GoatBot?.config?.adminBot; if (!Array.isArray(adminBot) || adminBot.length === 0) { return message.reply(getLang("noAdmin")); } const { senderID, threadID, isGroup } = event; const senderName = await usersData.getName(senderID); let body = "๐Ÿ“ž CALL ADMIN\n\n" + `๐Ÿ‘ค User: ${senderName}\n` + `๐Ÿ†” ID: ${senderID}`; if (isGroup) { const threadInfo = await threadsData.get(threadID); body += getLang( "sentFromGroup", threadInfo?.threadName || "Unknown group", threadID ); } else { body += getLang("sentFromUser"); } body += getLang( "userContent", text || "(Attachment only)" ); const formMessage = { body, mentions: [{ id: senderID, tag: senderName }] }; if (attachments.length > 0) { formMessage.attachment = await getStreamsFromAttachment(attachments); } let success = 0; for (const uid of adminBot) { try { const info = await api.sendMessage(formMessage, uid); if (info?.messageID) { success++; global.GoatBot.onReply.set(info.messageID, { commandName, type: "userCallAdmin", threadID, messageIDSender: event.messageID }); } } catch (error) { log.err("CALL ADMIN", error); } } if (success === 0) { return message.reply(getLang("failed")); } return message.reply(getLang("success", success)); } catch (error) { log.err("CALL ADMIN COMMAND", error); return message.reply("โŒ An error occurred while sending your message."); } }, onReply: async function ({ args, event, api, message, Reply, usersData, getLang }) { if (!Reply || Reply.type !== "userCallAdmin") { return; } try { const text = args.join(" ").trim(); if (!text) { return message.reply(getLang("missingMessage")); } const senderName = await usersData.getName(event.senderID); const body = getLang( "adminReply", senderName, text ); await api.sendMessage( { body }, Reply.threadID, (error) => { if (error) { log.err("CALL ADMIN REPLY", error); return message.reply(getLang("replyFailed")); } message.reply(getLang("replySuccess")); }, Reply.messageIDSender ); } catch (error) { log.err("CALL ADMIN REPLY", error); return message.reply(getLang("replyFailed")); } } };