nyasocket
v1.0.3
Published
Advanced, robust, and easy-to-use WhatsApp bot framework for Node.js
Maintainers
Readme
🐱✨ NyaSocket ✨🐱
The cutest WhatsApp bot framework you'll ever use! 💕
Making WhatsApp bots as easy as saying "Nya~!" 🎀
✨ Features • 🚀 Quick Start • 📚 Docs • 🎨 Examples
💝 Why NyaSocket?
Building WhatsApp bots shouldn't be complicated! NyaSocket wraps the powerful Baileys library in a super cute and easy-to-use API that makes bot development feel like magic! ✨
// Look how simple! 🎉
bot.command("hello", async (ctx) => {
await ctx.reply("Nya~ Hello! 🐱");
});� Trusted by developers who love cute things 🌟
✨ Sparkles Features
🎨 Beautiful API
Write clean, readable code that makes you smile! Our fluent API is designed for maximum cuteness and minimum complexity.
� Plugin Magic
Extend your bot with adorable plugins! Mix and match features like building with LEGO blocks! 🧩
�️ Built-in Protection
Rate limiting keeps your bot safe from spam. No more bans! Your bot stays happy and healthy! 💪
🎯 Smart Commands
Simple /command system that just works! No configuration headaches, just pure joy! ✨
� Rich Media
Send images, videos, stickers, and more! Make your conversations come alive! 🎭
� TypeScript Love
Full type safety means fewer bugs and more fun! Your IDE will love you! 💕
� Rocket Quick Start
Installation 📦
npm install nyasocket
# or with yarn
yarn add nyasocketYour First Bot 🎀
import { Bot, LocalAuth, RateLimitMiddleware } from 'nyasocket';
import QRCode from 'qrcode-terminal';
// Create your adorable bot! 🐱
const bot = new Bot(
"my-cute-bot-uuid",
new LocalAuth("my-uuid", "sessions"),
{ jid: "", pn: "", name: "CuteBot" }
);
// Show QR code in terminal ✨
bot.on("qr", (qr) => {
QRCode.generate(qr, { small: true });
console.log("✨ Scan me with WhatsApp! ✨");
});
// Celebrate when connected! 🎉
bot.on("open", () => {
console.log("🎊 Bot is online and ready to spread joy! 🎊");
});
// Add some protection 🛡️
bot.use(RateLimitMiddleware);
// Create your first command! 💫
bot.command("ping", async (ctx) => {
await ctx.reply("🏓 Pong! I'm alive and well! 💕");
});
bot.command("cute", async (ctx) => {
await ctx.reply("(=^・ω・^=) Nya~! 🐱✨");
});
// Start the magic! 🌟
await bot.login("qr");✨ That's it! Your bot is ready to spread happiness! ✨
🎨 Art Examples
🖼️ Send Beautiful Images
bot.command("cat", async (ctx) => {
await ctx.replyImage(
"https://cataas.com/cat",
"Here's a random cat for you! 🐱💕"
);
});🎬 Share Videos
bot.command("video", async (ctx) => {
await ctx.replyVideo(
"https://example.com/cute-video.mp4",
"Check out this adorable video! 🎥✨"
);
});🎵 Play Audio
bot.command("music", async (ctx) => {
await ctx.replyAudio("https://example.com/song.mp3");
});🔌 Plugin System
Create reusable magic! ✨
const WelcomePlugin = {
name: 'WelcomePlugin',
init: (bot) => {
bot.on('group-participants.update', async (update) => {
if (update.action === 'add') {
await bot.sendMessage(update.id, {
text: "🎉 Welcome to our awesome group! 🎊"
});
}
});
}
};
await bot.loadPlugin(WelcomePlugin);🎁 Built-in Plugins
- 🎊 WelcomePlugin - Greet new members with style
- 👑 AdminPlugin - Powerful group management
- 🎮 FunPlugin - Games and entertainment
🌈 Middleware Magic
Stack middleware like pancakes! 🥞
// Log all messages 📝
bot.use(async (ctx, next) => {
console.log(`💬 Message from ${ctx.from.name}`);
await next();
});
// Rate limiting (built-in!) 🛡️
bot.use(RateLimitMiddleware);
// Custom middleware 🎨
bot.use(async (ctx, next) => {
if (ctx.body.includes("bad word")) {
await ctx.reply("Please be nice! 💕");
return;
}
await next();
});👥 Group Management
Manage groups like a pro! 👑
// Create a group 🎉
await bot.createGroup("Cute Friends", [
"[email protected]",
"[email protected]"
]);
// Promote to admin 👑
await bot.promoteGroupParticipants(groupJid, [userJid]);
// Update group info 📝
await bot.updateGroupSubject(groupJid, "Super Cute Friends 🌟");
await bot.updateGroupDescription(groupJid, "The cutest group ever! 💕");📚 Books Documentation
🎯 Core Concepts
| Concept | Description |
|---------|-------------|
| Bot 🤖 | Your main bot instance - the heart of everything! |
| Commands ⚡ | Simple /command handlers that respond to messages |
| Middleware 🔄 | Process messages before they reach commands |
| Plugins 🔌 | Reusable modules that add features |
| Events 📡 | React to WhatsApp events in real-time |
🎨 Context Object
Every command gets a magical ctx object:
bot.command("info", async (ctx) => {
ctx.msg // 📨 Original message
ctx.from // 👤 Sender info
ctx.chat // 💬 Chat info
ctx.body // 📝 Message text
// Helper methods ✨
await ctx.reply("Text message")
await ctx.replyImage(url, caption)
await ctx.replyVideo(url, caption)
await ctx.replyAudio(url)
await ctx.replySticker(url)
});🎪 Events
Listen to everything! 👂
bot.on("qr", (qr) => {
// 📱 QR code for login
});
bot.on("open", (account) => {
// 🎉 Connected!
});
bot.on("messages.upsert", (messages) => {
// 💬 New messages
});
bot.on("contacts.update", (contacts) => {
// 👥 Contact updates
});🔐 Session Encryption
Protect your WhatsApp sessions with military-grade encryption! 🛡️
NyaSocket includes a unique encryption system using AES-256-GCM with PBKDF2 key derivation.
🎯 Features
- 🔒 AES-256-GCM - Authenticated encryption
- 🔑 PBKDF2 - 100,000 iterations for key derivation
- 🎲 Unique Salt - Cryptographically secure per-session
- ✅ Auth Tag - Integrity verification
- 🛡️ Random IV - Unique initialization vector per file
💫 Usage
import { EncryptedAuth } from 'nyasocket';
const auth = new EncryptedAuth(
uuid,
"sessions",
"your-super-secret-password"
);
const bot = new Bot(uuid, auth, account);Your session files will be completely encrypted and unreadable without the password! 🎉
🌥️ Cloud Deployment
NyaSocket is cloud-ready out of the box! Deploy to modern platforms with ease! ✨
🎯 Session Storage Options
🔴 RedisAuth
Perfect for cloud platforms!
import { RedisAuth } from 'nyasocket';
const auth = new RedisAuth(
uuid,
process.env.REDIS_URL
);Best for: Heroku, Railway, Render
🍃 MongoAuth
Persistent & scalable!
import { MongoAuth } from 'nyasocket';
const auth = new MongoAuth(
uuid,
process.env.MONGO_URL
);Best for: MongoDB Atlas
☁️ S3Auth
Serverless-friendly!
import { S3Auth } from 'nyasocket';
const auth = new S3Auth(
uuid,
process.env.S3_BUCKET
);Best for: AWS Lambda
🚀 Quick Deploy
Railway (Easiest!)
railway init
railway add redis
railway upDocker
docker-compose up -dHeroku
heroku create my-bot
heroku addons:create heroku-redis:mini
git push heroku main💡 Pro Tips
🌟 Make your bot even more amazing! 🌟
- 🛡️ Always use RateLimitMiddleware - Keep your bot safe!
- 🎨 Use plugins - Don't reinvent the wheel!
- 📝 Log everything - Debugging is easier with good logs!
- 💕 Be nice - Make bots that spread positivity!
- 🔐 Protect sessions - Keep your auth data safe!
🤝 Contributing
We love contributions! 💕
- 🍴 Fork the repo
- 🌟 Create your feature branch
- 💝 Commit your changes
- 🚀 Push to the branch
- 🎉 Open a Pull Request
� License
MIT License - Use it, love it, share it! 💕
🌸 Made with love and lots of Nya~! 🌸
⭐ Star us on GitHub • 🐛 Report Bug • 💡 Request Feature
Built with 💖 by developers who believe coding should be fun!
