Open
Conversation
const { default: makeWASocket, useMultiFileAuthState, delay } = require("@whiskeysockets/baileys");
const { OpenAI } = require("openai");
const qrcode = require("qrcode-terminal");
// 1. Masukkan API Key OpenAI kamu di sini
const openai = new OpenAI({ apiKey: 'YOUR_OPENAI_API_KEY' });
async function startNoxm() {
const { state, saveCreds } = await useMultiFileAuthState('auth_noxm');
const sock = makeWASocket({
auth: state,
printQRInTerminal: true,
browser: ['NOXM-MD', 'Chrome', '1.0.0']
});
sock.ev.on('creds.update', saveCreds);
sock.ev.on('messages.upsert', async m => {
const msg = m.messages[0];
if (!msg.message || msg.key.fromMe) return;
const from = msg.key.remoteJid;
const type = Object.keys(msg.message)[0];
const body = (type === 'conversation') ? msg.message.conversation : (type === 'extendedTextMessage') ? msg.message.extendedTextMessage.text : '';
const command = body.toLowerCase();
// --- SISTEM MENU NOXM-MD ---
if (command === '.menu' || command === 'help' || command === '.start') {
const menuText = `
*╭─── [ NOXM-MD BOT ] ───*
│
│ *🎓 AI TUTOR MODE ON*
│ (Just ask me anything!)
│
│ *📌 COMMANDS:*
│ 🤖 *.menu* - Show this list
│ 🧠 *.ai [question]* - Ask Tutor
│ 👤 *.owner* - Bot Developer
│ 🕒 *.runtime* - Bot Active Time
│
*╰────────────────────*
_Powered by Khan AI Logic_`;
return await sock.sendMessage(from, { text: menuText });
}
if (command === '.owner') {
return await sock.sendMessage(from, { text: "My owner is a Creative Developer using NOXM-MD." });
}
// --- SISTEM AI TUTOR (KHAN AI LOGIC) ---
if (body.length > 3) {
await sock.sendPresenceUpdate('composing', from); // Biar kelihatan lagi ngetik
try {
const response = await openai.chat.completions.create({
model: "gpt-4",
messages: [
{
role: "system",
content: "You are NOXM-MD, a witty and supportive AI tutor. Rule: Never give direct answers. Guide students with questions and hints like Khanmigo. Use WhatsApp formatting like *bold* for emphasis."
},
{ role: "user", content: body }
],
});
const reply = response.choices[0].message.content;
await sock.sendMessage(from, { text: `*NOXM-MD TUTOR:* \n\n${reply}` });
} catch (e) {
console.log("Error AI:", e);
}
}
});
}
console.log("Starting NOXM-MD...");
startNoxm();
NOXM-MD WHATSAPP BOT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
const {
default: makeWASocket,
useMultiFileAuthState,
downloadContentFromMessage
} = require("@whiskeysockets/baileys");
const { OpenAI } = require("openai");
const { GoogleGenerativeAI } = require("@google/generative-ai");
const qrcode = require("qrcode-terminal");
const fs = require('fs');
const axios = require('axios');
const { exec } = require("child_process");
const path = require("path");
const pino = require('pino');
// ==========================================
// ⚙️ CONFIGURATION
// ==========================================
const OPENAI_KEY = 'YOUR_OPENAI_API_KEY';
const GEMINI_KEY = 'YOUR_GEMINI_API_KEY';
const WEATHER_KEY = 'YOUR_OPENWEATHER_KEY';
const botName = 'NOXM-MD';
const prefix = '.';
const openai = new OpenAI({ apiKey: OPENAI_KEY });
const genAI = new GoogleGenerativeAI(GEMINI_KEY);
if (!fs.existsSync('./tmp')) fs.mkdirSync('./tmp');
const pointDb = './tmp/points.json';
if (!fs.existsSync(pointDb)) fs.writeFileSync(pointDb, JSON.stringify({}));
// ==========================================
// 🛠️ HELPER FUNCTIONS
// ==========================================
function addPoints(userId, amount) {
let data = JSON.parse(fs.readFileSync(pointDb));
data[userId] = (data[userId] || 0) + amount;
fs.writeFileSync(pointDb, JSON.stringify(data));
return data[userId];
}
const getRandom = (ext) =>
${Math.floor(Math.random() * 10000)}${ext};async function imageToWebp(media) {
const tmpIn = path.join(__dirname,
./tmp/${getRandom('.jpg')});const tmpOut = path.join(__dirname,
./tmp/${getRandom('.webp')});fs.writeFileSync(tmpIn, media);
await new Promise((res, rej) => {
exec(
ffmpeg -i ${tmpIn} -vcodec libwebp -filter:v fps=fps=20 -lossless 1 -loop 0 -preset default -an -vsync 0 -s 512:512 ${tmpOut}, (err) => {if (err) rej(err); res();
});
});
const buff = fs.readFileSync(tmpOut);
fs.unlinkSync(tmpIn); fs.unlinkSync(tmpOut);
return buff;
}
// ==========================================
// 🚀 START BOT
// ==========================================
async function startNoxm() {
const { state, saveCreds } = await useMultiFileAuthState('session_noxm');
const sock = makeWASocket({
auth: state,
printQRInTerminal: true,
logger: pino({ level: 'silent' }),
browser: [botName, 'iOS', '1.0.0']
});
│ 👤 User: @${sender.split('@')[0]}
│ 💰 Points: ${myP}
│
│ 🤖 ᴍᴜʟᴛɪ-ᴀɪ ᴇɴɢɪɴᴇ
│ ‣ .gpt | .gemini | .meta | .kling
│
│ 🧠 ᴇᴅᴜ-ᴀɪ (ᴀᴜᴛᴏ-ʟᴀɴɢ)
│ ‣ Chat directly for AI Tutor
│ ‣ .tr [lang] | .wiki | .brainly
│
│ 🔍 sᴇᴀʀᴄʜ ғᴇᴀᴛᴜʀᴇs
│ ‣ .google | .yts | .pin 📌
│
│ 🎮 ɢᴀᴍᴇs (ᴇᴀʀɴ ᴘᴏɪɴᴛs)
│ ‣ .tambang | .polisi | .suit
│ ‣ .tebakbendera | .tebaknegara
│
│ 🎨 ᴄʀᴇᴀᴛɪᴠᴇ & sᴛɪᴄᴋᴇʀ
│ ‣ .brat | .sticker | .genimage | .toimg
│
│ 📥 ᴅᴏᴡɴʟᴏᴀᴅᴇʀ
│ ‣ .play | .ytmp4 | .tiktok | .ig
│
│ 🕋 ʀᴇʟɪɢɪᴏɴ
│ ‣ .sholat | .bible | .quotes
│
│ 🌐 ᴜᴛɪʟs & ᴀᴅᴍɪɴ
│ ‣ .weather | .poll | .tagall
│ ‣ .forward | .points | .del
│
╰──────────────────────────`;
await sock.sendMessage(from, { text: menu, mentions: [sender] });
break;
}
startNoxm();