You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
✅ Intelligent WhatsApp Bot is running...
{"level":30,"time":"2025-02-06T15:39:31.830Z","pid":4424,"hostname":"DESKTOP-Q6DH6MA","class":"baileys","trace":"Error: WebSocket Error (Opening handshake has timed out)\n at WebSocketClient. (/mnt/c/Users/USER/Antilink-bot/node_modules/@whiskeysockets/baileys/lib/Socket/socket.js:620:17)\n at WebSocketClient.emit (node:events:517:28)\n at WebSocket. (/mnt/c/Users/USER/Antilink-bot/node_modules/@whiskeysockets/baileys/lib/Socket/Client/websocket.js:46:100)\n at WebSocket.emit (node:events:517:28)\n at emitErrorAndClose (/mnt/c/Users/USER/Antilink-bot/node_modules/ws/lib/websocket.js:1041:13)\n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)","msg":"connection errored"}
const { makeWASocket, useMultiFileAuthState } = `require("@whiskeysockets/baileys");`
// Admin phone number (replace with yours)
const ADMIN_PHONE = "@s.whatsapp.net";
// List of approved group admins
const ADMIN_LIST = [ADMIN_PHONE];
// Track warnings for anti-spam
const WARNING_COUNT = {};
const MAX_WARNINGS = 2; // Ban user after exceeding warnings
(async () => {
const { state, saveCreds } = await useMultiFileAuthState("./auth_info");
const sock = makeWASocket({ auth: state });
sock.ev.on("creds.update", saveCreds);
// Handle incoming messages
sock.ev.on("messages.upsert", async ({ messages }) => {
const msg = messages[0];
if (!msg.message || !msg.key.remoteJid || msg.key.fromMe) return;
const chatId = msg.key.remoteJid;
const sender = msg.key.participant || msg.key.remoteJid;
const messageText = msg.message.conversation || msg.message.extendedTextMessage?.text;
if (!messageText) return;
console.log(`📩 New message from ${sender}: ${messageText}`);
// Bot Commands
const args = messageText.slice(1).trim().split(" ");
const command = args.shift().toLowerCase();
switch (command) {
case "help":
await sock.sendMessage(chatId, { text: "🛠️ Commands: \n!help - Show commands\n!news - Latest news\n!weather Nairobi - Get weather\n!kick @user - Remove user" });
break;
case "news":
const news = await getNews();
await sock.sendMessage(chatId, { text: news });
break;
case "weather":
const city = args.join(" ");
const weather = await getWeather(city);
await sock.sendMessage(chatId, { text: weather });
break;
case "kick":
if (ADMIN_LIST.includes(sender)) {
const userToKick = args[0]?.replace("@", "") + "@s.whatsapp.net";
await sock.groupParticipantsUpdate(chatId, [userToKick], "remove");
await sock.sendMessage(chatId, { text: `❌ @${userToKick.split("@")[0]} has been removed.`, mentions: [userToKick] });
} else {
await sock.sendMessage(chatId, { text: "🚫 Only admins can use this command!" });
}
break;
default:
await sock.sendMessage(chatId, { text: "⚠️ Unknown command! Type !help for a list of commands." });
}
});
console.log("✅ Intelligent WhatsApp Bot is running...");
})();
// Get Latest News
async function getNews() {
try {
const response = await axios.get("https://newsapi.org/v2/top-headlines?country=ke&apiKey=your_newsapi_key");
return `📰 Latest News: ${response.data.articles[0].title}\nRead more: ${response.data.articles[0].url}`;
} catch (error) {
console.error("News API Error:", error);
return "⚠️ Could not fetch news.";
}
}
// Get Weather Info
async function getWeather(city) {
try {
const response = await axios.get(`https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=your_weatherapi_key&units=metric`);
return `🌤️ Weather in ${city}: ${response.data.weather[0].description}, Temp: ${response.data.main.temp}°C`;
} catch (error) {
console.error("Weather API Error:", error);
return "⚠️ Could not fetch weather info.";
}
}
The text was updated successfully, but these errors were encountered:
✅ Intelligent WhatsApp Bot is running...
{"level":30,"time":"2025-02-06T15:39:31.830Z","pid":4424,"hostname":"DESKTOP-Q6DH6MA","class":"baileys","trace":"Error: WebSocket Error (Opening handshake has timed out)\n at WebSocketClient. (/mnt/c/Users/USER/Antilink-bot/node_modules/@whiskeysockets/baileys/lib/Socket/socket.js:620:17)\n at WebSocketClient.emit (node:events:517:28)\n at WebSocket. (/mnt/c/Users/USER/Antilink-bot/node_modules/@whiskeysockets/baileys/lib/Socket/Client/websocket.js:46:100)\n at WebSocket.emit (node:events:517:28)\n at emitErrorAndClose (/mnt/c/Users/USER/Antilink-bot/node_modules/ws/lib/websocket.js:1041:13)\n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)","msg":"connection errored"}
The text was updated successfully, but these errors were encountered: