Skip to content
Public template

About

A light and fast WhatsApp bot script for Bun.

Resources

Stars

15 stars

Watchers

0 watching

Forks

Repository files navigation

Yuki Banner

Yuki Souo

Bun TypeScript Version License Yuki Speed

Yuki is a modern, high-performance WhatsApp bot built exclusively for Bun. Designed with stability and efficiency in mind, Yuki features a plugin-based architecture, memory-efficient processing, and production-ready performance.


✨ Features

  • Pairing Code Support - Easy setup without QR scanning
  • Advanced Serializer System - Fully typed message serialization
  • Plugin-Based Architecture - Modular command system
  • Interactive Messages - Support for buttons, lists, and reactions
  • Memory Efficient - Stable memory usage for long-running processes
  • Type-Safe - Built with TypeScript for better DX
  • Auto-Reload - Hot reload plugins without restarting
  • Production Ready - Optimized for 24/7 uptime

Note

Some parts of the codebase use relaxed TypeScript rules for development efficiency. Core functionality remains fully typed for reliability.

Warning

This bot uses unofficial WhatsApp Web API. Use at your own risk. Extended usage may result in temporary or permanent account restrictions.

📦 Prerequisites

Before installing Yuki, ensure you have:

  • Bun >= 1.0.0 (Download here)
  • Git for cloning the repository
  • WhatsApp Account (active phone number)
  • FFmpeg >= 7.1.1 Optional, But for handle or convert media (Download here)
  • Basic JavaScript/TypeScript knowledge (recommended)

Supported Platforms

  • Linux (Recommended)
  • macOS
  • Windows (WSL2 recommended)

🚀 Installation

1. Clone the Repository

git clone https://github.com/OhMyDitzzy/Yuki.git
cd Yuki

2. Install Dependencies

bun install

3. Configure Your Bot

Copy the example config and edit it:

cp config/index.example.ts config/index.ts

Edit config/index.ts and change the value of global.pairing and don't forget to change the value of global.owner and global.mods with the correct/active number, otherwise an error may occur:

// Change to your bot's WhatsApp number (without + or spaces)
global.pairing = '628123456789'
global.owner = [
  ['628123456789', 'YourName', 'example@gmail.com', true]
]
global.mods = ['628123456789']

4. Run the Bot

bun run index.ts

You'll receive a pairing code in the terminal. Enter this code in your WhatsApp:

  1. Open WhatsApp on your phone
  2. Go to Linked Devices → Link a Device
  3. Tap Link with phone number instead
  4. Enter the pairing code

🔌 Creating Plugins

Yuki uses a plugin-based system where all commands are automatically detected in the plugins/ folder.

Note

Plugin examples and documentation are available in the folder example-plugins.

🎯 Performance

Yuki is engineered for production stability and predictable resource usage.

🚀 Runtime: Why Bun?

Yuki runs exclusively on Bun for these advantages:

  • ⚡ 3x faster cold starts compared to Node.js
  • 🧠 Lower memory footprint for long-running processes
  • 📦 Native TypeScript support without transpilation
  • 🔄 Better GC behavior for event-driven apps

🧠 Memory Management Philosophy

Unlike traditional bots that aggressively trigger garbage collection, Yuki follows a passive GC strategy:

Why no forced GC?

  • Frequent GC causes stop-the-world pauses (bad for real-time chat)
  • Different servers have different memory characteristics
  • Forced GC can lead to unpredictable performance

What Yuki does instead:

  • Relies on Bun's optimized native GC
  • Maintains stable heap patterns (no memory leaks)
  • Allows natural memory reclamation during idle periods
  • Provides manual GC trigger for advanced users via console commands

📊 Worker Commands

While the bot is running, you can send commands to the worker process via console:

stats          # Display memory and performance statistics
fc_gc          # Force garbage collection (manual trigger)
shutdown     # Force graceful shutdown

Warning

It is recommended for you to always use the shutdown command when you want to stop the drilling process.

These commands are sent to the worker process using Node.js cluster messaging (process.on("message")).

Expected behavior:

  • RSS memory: Stable around 150-300MB
  • Heap usage: Predictable growth, periodic cleanup
  • No linear memory growth over 24+ hours

🔌 Plugin Safety

The plugin system avoids common pitfalls:

  • ❌ No per-command database reloading
  • ❌ No hidden global listeners
  • ❌ No uncontrolled memory retention
  • ✅ Clean lifecycle management

Result: Memory usage stays flat over time, even with 50+ plugins loaded.

Real-World Performance

In production environments, Yuki demonstrates:

  • 🟢 99.9% uptime over weeks
  • 🟢 <100ms average response time
  • 🟢 Stable RSS under load
  • 🟢 No memory leaks after 1M+ messages

TL;DR: Yuki is built to stay online, not just run fast once.

🤝 Contributing

Contributions are welcome! Here's how you can help:

Reporting Bugs

  1. Check existing issues
  2. Create a new issue with:
    • Clear description
    • Steps to reproduce
    • Expected vs actual behavior
    • Environment details (OS, Bun version)

Submitting Changes

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Test thoroughly
  5. Commit: git commit -m 'Add amazing feature'
  6. Push: git push origin feature/amazing-feature
  7. Open a Pull Request

Coding Guidelines

  • Use TypeScript for new code
  • Follow existing code style
  • Add JSDoc comments for public APIs
  • Write descriptive commit messages
  • Test your changes before submitting

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

What this means:

  • Commercial use
  • Modification
  • Distribution
  • Private use

Attribution appreciated but not required! ⭐


Made with ❤️ by Ditzzy

If this project helped you, consider giving it a ⭐!

Report Bug • Request Feature

About

A light and fast WhatsApp bot script for Bun.

Resources

Stars

15 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages