goat
command
salam
Auto reply to salam
0
views
0
likes
0
installs
raw source
const axios = require("axios");
const fs = require("fs-extra");
const path = require("path");
module.exports = {
config: {
name: "salam",
version: "1.0.0",
author: "SUJON-BOSS",
countDown: 5,
role: 0,
shortDescription: "Auto reply to salam",
longDescription: "সালামের জবাব অটোমেটিক দেবে",
category: "noprefix",
guide: {
body: "{pn}"
}
},
// ==========================================
// AUTO SALAM REPLY
// ==========================================
onChat: async function ({ message, event, usersData, threadsData }) {
try {
const body = (event.body || "").trim();
if (!body) return;
const text = body.toLowerCase();
// ==========================================
// SALAM TRIGGER
// ==========================================
const salamWords = [
"assalamu alaikum",
"assalamualaikum",
"আসসালামু আলাইকুম",
"salam",
"সালাম",
"আসসালামু"
];
const isSalam = salamWords.some(word =>
text.startsWith(word.toLowerCase())
);
if (!isSalam) return;
// ==========================================
// CHECK GROUP SALAM STATUS
// ==========================================
let enabled = true;
try {
const threadData = await threadsData.get(event.threadID);
if (
threadData &&
typeof threadData.salam !== "undefined"
) {
enabled = threadData.salam;
}
} catch (e) {
enabled = true;
}
if (!enabled) return;
// ==========================================
// USER NAME
// ==========================================
let name = "প্রিয় গ্রুপ মেম্বার";
try {
name = await usersData.getName(event.senderID);
} catch (e) {}
// ==========================================
// IMAGE LIST
// ==========================================
const link = [
"https://i.postimg.cc/vB1ZLhXQ/received_1378256350541808.jpg",
"https://i.postimg.cc/vB1ZLhXQ/received_1378256350541808.jpg"
];
const randomImage =
link[Math.floor(Math.random() * link.length)];
// ==========================================
// CACHE
// ==========================================
const cachePath = path.join(
__dirname,
"cache"
);
await fs.ensureDir(cachePath);
const filePath = path.join(
cachePath,
`emon_${Date.now()}.jpeg`
);
// ==========================================
// DOWNLOAD IMAGE
// ==========================================
const response = await axios.get(
randomImage,
{
responseType: "arraybuffer",
timeout: 30000
}
);
await fs.writeFile(
filePath,
Buffer.from(response.data)
);
// ==========================================
// REPLY MESSAGE
// ==========================================
const msg =
`╭•┄┅════❁🌺❁════┅┄•╮
ওয়ালাইকুম আসসালাম-!!🖤💫
╰•┄┅════❁🌺❁════┅┄•╯
✿🦋༎প্রি্ঁয়্ঁ গ্রুপ্ঁ মে্ঁম্বা্ঁর্ঁ ${name}༎✨🧡
⋆✦⋆⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⋆✦⋆`;
// ==========================================
// SEND
// ==========================================
await message.reply(
{
body: msg,
attachment: fs.createReadStream(filePath)
}
);
// ==========================================
// DELETE IMAGE
// ==========================================
setTimeout(async () => {
try {
if (await fs.pathExists(filePath)) {
await fs.remove(filePath);
}
} catch (e) {}
}, 3000);
} catch (error) {
console.error(
"SALAM AUTO REPLY ERROR:",
error
);
}
},
// ==========================================
// ON / OFF COMMAND
// ==========================================
onStart: async function ({
message,
event,
threadsData
}) {
try {
const threadID = event.threadID;
const threadData =
await threadsData.get(threadID);
// বর্তমান status
let currentStatus = true;
if (
threadData &&
typeof threadData.salam !== "undefined"
) {
currentStatus = threadData.salam;
}
// Toggle
const newStatus = !currentStatus;
// Save
await threadsData.set(
threadID,
{
salam: newStatus
}
);
if (newStatus) {
return message.reply(
"✅ Salam Auto Reply চালু করা হয়েছে! 🧠"
);
} else {
return message.reply(
"❌ Salam Auto Reply বন্ধ করা হয়েছে! 🧠"
);
}
} catch (error) {
console.error(
"SALAM TOGGLE ERROR:",
error
);
return message.reply(
"❌ Salam settings পরিবর্তন করতে সমস্যা হয়েছে।"
);
}
}
};