goat
command
notification2
Send stylish notification to all groups and forward replies to admin
0
views
0
likes
0
installs
Aliases: notify2, noti2
raw source
const { getStreamsFromAttachment } = global.utils;
module.exports = {
config: {
name: "notification2",
aliases: ["notify2", "noti2"],
version: "2.4",
author: "Rasel Mahmud",
countDown: 5,
role: 2,
description: "Send stylish notification to all groups and forward replies to admin",
category: "owner",
envConfig: {
delayPerGroup: 250,
adminID: "ADMIN_USER_ID" // <-- Replace with MAMUN id
}
},
langs: {
en: {
missingMessage: "Please enter the message you want to send",
autoReplyMessage: "π Thanks for your reply! Admin δΊπ
Όπ
°α₯«α©£π
Όα₯«α©£ππ
½ΓΝΓ will be notified.",
sentNotification: "β
Sent notification to %1 groups",
errorNotification: "β Failed to send to %1 groups"
}
},
onStart: async function ({ message, api, event, args, envCommands, threadsData, getLang }) {
if (!args[0]) return message.reply(getLang("missingMessage"));
const adminID = envCommands[this.config.name].adminID;
const senderName = "δΊπ
Όπ
°α₯«α©£π
Όα₯«α©£ππ
½ΓΝΓ";
const allThreads = (await threadsData.getAll()).filter(t => t.isGroup);
// notification body (Front font + English only)
const textMessage = `βββββ° β¨π°π»π» π²π·π°π π±πΎππ΄πβ¨ β±βββ
π’ π½πππππ from π°π³πΌπΈπ½ ${senderName} π’
βββββββββββββββββββββββ
${args.join(" ")}
βββββββββββββββββββββββ
π Sent with love by β‘β ππππππ α₯«α‘ππ
βββββββββββββββββββββ`;
const sentThreads = [];
for (const thread of allThreads) {
try {
const sentMsg = await api.sendMessage({ body: textMessage }, thread.threadID);
sentThreads.push({ threadID: thread.threadID, messageID: sentMsg.messageID, replied: false });
// listen for reply
api.listenMqtt(async (evt) => {
if (
evt.type === "message" &&
evt.threadID === thread.threadID &&
evt.messageID !== sentMsg.messageID &&
!sentThreads.find(s => s.threadID === thread.threadID).replied
) {
// mark as replied
sentThreads.find(s => s.threadID === thread.threadID).replied = true;
// forward to admin
const userInfo = await api.getUserInfo(evt.senderID);
const userName = userInfo[evt.senderID]?.name || "Unknown";
const forwardText = `π© Reply from ${userName} in group "${thread.name || thread.threadID}":\n${evt.body}`;
await api.sendMessage(forwardText, adminID);
// auto-reply to member
await api.sendMessage(getLang("autoReplyMessage"), thread.threadID);
}
});
} catch (e) {
console.error(`Failed to send to thread ${thread.threadID}:`, e);
}
await new Promise(resolve => setTimeout(resolve, envCommands[this.config.name].delayPerGroup));
}
message.reply(getLang("sentNotification", sentThreads.length));
}
};