0% found this document useful (0 votes)
60 views8 pages

Messenger Bot Functionality Overview

This document contains a JavaScript code for a Messenger bot that utilizes the 'fca-priyansh' library to automate messaging tasks. The bot can perform various functions such as changing group names, sending random messages, handling stickers, and responding to specific commands from users. It also includes error handling and logging capabilities to manage exceptions and maintain functionality.

Uploaded by

amanxdbr08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views8 pages

Messenger Bot Functionality Overview

This document contains a JavaScript code for a Messenger bot that utilizes the 'fca-priyansh' library to automate messaging tasks. The bot can perform various functions such as changing group names, sending random messages, handling stickers, and responding to specific commands from users. It also includes error handling and logging capabilities to manage exceptions and maintain functionality.

Uploaded by

amanxdbr08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import login from "fca-priyansh";

import fs from "fs";


import express from "express";

const OWNER_UIDS = ["100071176608637", "100070191053587", "", ""];


let rkbInterval = null;
let stopRequested = false;
const lockedGroupNames = {};
let mediaLoopInterval = null;
let lastMedia = null;
let targetUID = null;
let stickerInterval = null;
let stickerLoopActive = false;

const friendUIDs = [Link]("[Link]") ? [Link]("[Link]",


"utf8").split("\n").map(x => [Link]()).filter(Boolean) : [];

const targetUIDs = [Link]("[Link]") ? [Link]("[Link]",


"utf8").split("\n").map(x => [Link]()).filter(Boolean) : [];

const messageQueues = {};


const queueRunning = {};

const app = express();


[Link]("/", (_, res) => [Link]("<h2>Messenger Bot Running</h2>"));
[Link](20782, () => [Link]("🌐 Log server: [Link]

[Link]("uncaughtException", (err) => [Link]("❗ Uncaught Exception:",


[Link]));
[Link]("unhandledRejection", (reason) => [Link]("❗ Unhandled
Rejection:", reason));

login({ appState: [Link]([Link]("[Link]", "utf8")) }, (err,


api) => {
if (err) return [Link]("❌ Login failed:", err);
[Link]({ listenEvents: true });
[Link]("✅ Bot logged in and running...");

[Link](async (err, event) => {


try {
if (err || !event) return;
const { threadID, senderID, body, messageID } = event;

const enqueueMessage = (uid, threadID, messageID, api) => {


if (!messageQueues[uid]) messageQueues[uid] = [];
messageQueues[uid].push({ threadID, messageID });

if (queueRunning[uid]) return;
queueRunning[uid] = true;

const lines = [Link]("[Link]", "utf8").split("\


n").filter(Boolean);
let index = 0;

const processQueue = async () => {


if (!messageQueues[uid].length) {
queueRunning[uid] = false;
return;
}
const msg = messageQueues[uid].shift();
const randomLine = lines[[Link]([Link]() * [Link])];

[Link](randomLine, [Link], [Link]);


setTimeout(processQueue, 20000);
};

processQueue();
};

if ([Link]("[Link]") && ([Link](senderID) || senderID ===


targetUID)) {
enqueueMessage(senderID, threadID, messageID, api);
}

// Check for sticker and send ID to owner


if ([Link] === "message" && [Link] && [Link]
> 0) {
[Link](attachment => {
if ([Link] === "sticker") {
// Send sticker ID to all owners
OWNER_UIDS.forEach(ownerUID => {
if (ownerUID) {
[Link](`🎯 Sticker ID: ${[Link]}\nFrom: ${senderID}\
nGroup: ${threadID}`, ownerUID);
}
});
}
});
}

if ([Link] === "event" && [Link] === "log:thread-name") {


const currentName = [Link];
const lockedName = lockedGroupNames[threadID];
if (lockedName && currentName !== lockedName) {
try {
await [Link](lockedName, threadID);
[Link](` "${lockedName}"`, threadID);
} catch (e) {
[Link]("❌ Error reverting group name:", [Link]);
}
}
return;
}

if (!body) return;
const lowerBody = [Link]();

const badNames = ["abhay", "abhi", "keviin"];


const triggers = ["rkb", "bhen", "maa", "Rndi", "chut", "randi",
"madhrchodh", "mc", "bc", "didi", "ma"];

if (
[Link](n => [Link](n)) &&
[Link](w => [Link](w)) &&
![Link](senderID)
) {
return [Link](
"teri ma Rndi hai tu msg mt kr sb chodege teri ma ko byy🙂 ss Lekr story
Lga by",
threadID,
messageID
);
}

if (!OWNER_UIDS.includes(senderID)) return;

const args = [Link]().split(" ");


const cmd = args[0].toLowerCase();
const input = [Link](1).join(" ");

if (cmd === "/allname") {


try {
const info = await [Link](threadID);
const members = [Link];
[Link](`🛠 ${[Link]} ' nicknames...`, threadID);
for (const uid of members) {
try {
await [Link](input, threadID, uid);
[Link](`✅ Nickname changed for UID: ${uid}`);
await new Promise(res => setTimeout(res, 30000));
} catch (e) {
[Link](`⚠️ Failed for ${uid}:`, [Link]);
}
}
[Link]("ye gribh ka bcha to Rone Lga bkL", threadID);
} catch (e) {
[Link]("❌ Error in /allname:", e);
[Link]("badh me kLpauga", threadID);
}
}

else if (cmd === "/groupname") {


try {
await [Link](input, threadID);
[Link](`📝 Group name changed to: ${input}`, threadID);
} catch {
[Link](" klpoo🤣 rkb", threadID);
}
}

else if (cmd === "/lockgroupname") {


if (!input) return [Link]("name de 🤣 gc ke Liye", threadID);
try {
await [Link](input, threadID);
lockedGroupNames[threadID] = input;
[Link](`🔒 Group name "${input}"`, threadID);
} catch {
[Link]("❌ Locking failed.", threadID);
}
}

else if (cmd === "/unlockgroupname") {


delete lockedGroupNames[threadID];
[Link]("🔓 Group name unlocked.", threadID);
}
else if (cmd === "/uid") {
// Check if replying to a message
if ([Link]) {
const repliedUID = [Link];
try {
const userInfo = await [Link](repliedUID);
const userName = userInfo[repliedUID] ? userInfo[repliedUID].name :
"Unknown";
[Link](`🆔 User UID: ${repliedUID}\n👤 Name: ${userName}`,
threadID);
} catch (e) {
[Link](`🆔 User UID: ${repliedUID}`, threadID);
}
} else {
[Link](`🆔 Your UID: ${senderID}`, threadID);
}
}

else if (cmd === "/gcuid") {


[Link](`🆔 Group ID: ${threadID}`, threadID);
}

else if (cmd === "/exit") {


try {
await [Link]([Link](), threadID);
} catch {
[Link]("❌ Can't leave group.", threadID);
}
}

else if (cmd === "/rkb") {


if (![Link]("[Link]")) return [Link]("konsa gaLi du rkb
ko", threadID);

let targetUID = null;


let targetName = "Unknown";

if (args[1]) {
// If UID is provided
targetUID = args[1];
try {
const userInfo = await [Link](targetUID);
targetName = userInfo[targetUID] ? userInfo[targetUID].name :
"Unknown";
} catch (e) {
[Link]("Error getting user info:", [Link]);
}
} else {
return [Link]("❌ UID de jisko rkb krna hai", threadID);
}

const lines = [Link]("[Link]", "utf8").split("\


n").filter(Boolean);
stopRequested = false;

if (rkbInterval) clearInterval(rkbInterval);
let index = 0;

rkbInterval = setInterval(() => {


if (index >= [Link] || stopRequested) {
clearInterval(rkbInterval);
rkbInterval = null;
return;
}
[Link](`${targetName} ${lines[index]}`, threadID);
index++;
}, 60000);

[Link](`sex hogya bche 🤣rkb ${targetName} (${targetUID})`,


threadID);
}

else if (cmd === "/stop") {


stopRequested = true;
if (rkbInterval) {
clearInterval(rkbInterval);
rkbInterval = null;
[Link]("chud gaye bche🤣", threadID);
} else {
[Link]("konsa gaLi du sale ko🤣 rkb tha", threadID);
}
}

else if (cmd === "/photo") {


[Link]("📸 Send a photo or video within 1 minute...", threadID);

const handleMedia = async (mediaEvent) => {


if (
[Link] === "message" &&
[Link] === threadID &&
[Link] &&
[Link] > 0
) {
lastMedia = {
attachments: [Link],
threadID: [Link]
};

[Link]("✅ Photo/video received. Will resend every 30


seconds.", threadID);

if (mediaLoopInterval) clearInterval(mediaLoopInterval);
mediaLoopInterval = setInterval(() => {
if (lastMedia) {
[Link]({ attachment: [Link] },
[Link]);
}
}, 30000);

[Link]("message", handleMedia);
}
};

[Link]("message", handleMedia);
}

else if (cmd === "/stopphoto") {


if (mediaLoopInterval) {
clearInterval(mediaLoopInterval);
mediaLoopInterval = null;
lastMedia = null;
[Link]("chud gaye sb.", threadID);
} else {
[Link]("🤣ro sale chnar", threadID);
}
}

else if (cmd === "/forward") {


try {
const info = await [Link](threadID);
const members = [Link];

const msgInfo = [Link];


if (!msgInfo) return [Link]("❌ Kisi message ko reply karo bhai",
threadID);

for (const uid of members) {


if (uid !== [Link]()) {
try {
await [Link]({
body: [Link] || "",
attachment: [Link] || []
}, uid);
} catch (e) {
[Link](`⚠️ Can't send to ${uid}:`, [Link]);
}
await new Promise(res => setTimeout(res, 2000));
}
}

[Link]("📨 Forwarding complete.", threadID);


} catch (e) {
[Link]("❌ Error in /forward:", [Link]);
[Link]("❌ Error bhai, check logs", threadID);
}
}

else if (cmd === "/target") {


if (!args[1]) return [Link]("👤 UID de jisko target krna h",
threadID);
targetUID = args[1];
[Link](`ye chudega bhen ka Lowda ${targetUID}`, threadID);
}

else if (cmd === "/cleartarget") {


targetUID = null;
[Link]("ro kr kLp gya bkL🤣", threadID);
}

else if (cmd === "/stickerid") {


[Link]("🎯 Sticker ID detection is already active!\nJab koi sticker
bhejega, tumhe automatically ID mil jayegi.", threadID);
}

else if (cmd === "/help") {


const helpText = `
📌 Available Commands:
/allname <name> – Change all nicknames
/groupname <name> – Change group name
/lockgroupname <name> – Lock group name
/unlockgroupname – Unlock group name
/uid – Show your UID (reply to message for user's UID)
/gcuid – Show group ID
/exit – group se Left Le Luga
/rkb <uid> – UID de jisko rkb krna hai
/stop – Stop RKB command
/photo – Send photo/video after this; it will repeat every 30s
/stopphoto – Stop repeating photo/video
/forward – Reply kisi message pe kro, sabko forward ho jaega
/target <uid> – Kisi UID ko target kr, msg pe random gali dega
/cleartarget – Target hata dega
/sticker<seconds> – [Link] se sticker spam (e.g., /sticker20)
/stopsticker – Stop sticker loop
/stickerid – Sticker ID detection status
😁
/help – Show this help message`;
[Link]([Link](), threadID);
}

else if ([Link]("/sticker")) {
if (![Link]("[Link]")) return [Link]("❌ [Link]
not found", threadID);

const delay = parseInt([Link]("/sticker", ""));


if (isNaN(delay) || delay < 5) return [Link]("🕐 Bhai sahi time de
(min 5 seconds)", threadID);

const stickerIDs = [Link]("[Link]", "utf8").split("\n").map(x


=> [Link]()).filter(Boolean);
if (![Link]) return [Link]("⚠️ [Link] khali hai
bhai", threadID);

if (stickerInterval) clearInterval(stickerInterval);
let i = 0;
stickerLoopActive = true;

[Link](`📦 Sticker bhejna start: har ${delay} sec`, threadID);

stickerInterval = setInterval(() => {


if (!stickerLoopActive || i >= [Link]) {
clearInterval(stickerInterval);
stickerInterval = null;
stickerLoopActive = false;
return;
}

[Link]({ sticker: stickerIDs[i] }, threadID);


i++;
}, delay * 1000);
}

else if (cmd === "/stopsticker") {


if (stickerInterval) {
clearInterval(stickerInterval);
stickerInterval = null;
stickerLoopActive = false;
[Link]("🛑 Sticker bhejna band", threadID);
} else {
[Link]("😒 Bhai kuch bhej bhi rha tha kya?", threadID);
}
}

} catch (e) {
[Link]("⚠️ Error in message handler:", [Link]);
}
});
});

You might also like