Skip to content

πŸ› οΈ Modern Dart wrapper for WhatsApp automation via Neonize. Build chatbots, automate messaging, and handle WhatsApp events with clean, type-safe Dart APIs.

License

Notifications You must be signed in to change notification settings

krypton-byte/neonize-dart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Neonize Dart

WhatsApp Automation Made Simple for Dart & Flutter

Dart Flutter License WhatsApp

A powerful Dart wrapper for Neonize - enabling seamless WhatsApp automation in your Dart and Flutter applications


⚠️ DEVELOPMENT STATUS - NOT READY FOR PRODUCTION

🚧 WORK IN PROGRESS 🚧

This project is currently under active development and is NOT ready for production use.


Getting Started β€’ Features β€’ Examples β€’ Documentation β€’ Contributing

✨ What is Neonize Dart?

Neonize Dart is a comprehensive Dart wrapper around the powerful Neonize shared library, bringing WhatsApp automation capabilities directly to your Dart and Flutter projects.

🎯 Why Choose Neonize Dart?

  • πŸ”₯ High Performance - Built on top of the battle-tested Neonize library
  • πŸ“± Cross-Platform - Works seamlessly on Android, iOS, Windows, macOS, and Linux
  • πŸ›‘οΈ Type Safe - Full Dart type safety with comprehensive error handling
  • ⚑ Real-time - Handle messages, media, and events in real-time
  • πŸ”§ Easy Integration - Simple API design for quick implementation
  • πŸ“š Well Documented - Comprehensive documentation and examples

🌟 Features

Core Messaging

  • βœ… Send and receive text messages
  • βœ… Handle media files (images, videos, documents, audio)
  • βœ… Group management and operations
  • βœ… Real-time message events
  • βœ… Message receipts and status tracking

Advanced Capabilities

  • πŸ” End-to-end encryption support
  • 🎯 Contact and user information retrieval
  • πŸ“ž Call event handling
  • πŸ”” Presence and typing indicators
  • πŸ“° Newsletter support
  • 🚫 Blocklist management

Developer Experience

  • πŸ”„ Event-driven architecture
  • πŸ“Š Built-in logging and debugging
  • πŸ—„οΈ SQLite and PostgreSQL database support
  • πŸ§ͺ Comprehensive test coverage

πŸš€ Getting Started

Prerequisites

  • Dart SDK 3.0 or higher
  • Flutter 3.0+ (for Flutter projects)

Installation

⚠️ Since this project is still unstable, please follow these manual installation steps:

  1. Clone this repository

    git clone https://github.com/krypton-byte/neonize-dart.git
    cd neonize-dart
  2. Download the Neonize shared library

    • Go to Neonize Releases
    • Download the appropriate shared library for your platform:
      • Linux: .so file
      • macOS: .dylib file
      • Windows: .dll file
  3. Set environment variable

    # Set NEONIZE_PATH to point to your shared library location
    export NEONIZE_PATH=/path/to/your/neonize-library.so
    
    # For Windows (PowerShell)
    $env:NEONIZE_PATH="C:\path\to\your\neonize-library.dll"
    
    # For Windows (Command Prompt)
    set NEONIZE_PATH=C:\path\to\your\neonize-library.dll
  4. Install dependencies

    dart pub get
  5. Run the example

    # You can run the example directly from the bin folder
    dart run bin/main.dart

Alternative Installation (When Stable)

Once the project becomes stable, you'll be able to add it directly to your pubspec.yaml:

dependencies:
  neonize: ^1.0.0  # Replace with actual version

Quick Start

import 'package:neonize/neonize.dart';

void main() {
  // Initialize the client
  final client = NewAClient(
    name: 'my-whatsapp-bot',
    config: Config(
      tempPath: '/tmp',
      databasePath: './whatsapp.db',
    ),
  );

  // Handle incoming messages
  client.on<Message>((message) {
    print('πŸ“¨ Received: ${message.message}');
    
    // Auto-reply example
    if (message.message?.conversation?.toLowerCase() == 'hello') {
      client.sendMessage(
        message.info!.messageSource!.chat!,
        text: 'πŸ‘‹ Hello there! How can I help you?'
      );
    }
  });

  // Handle QR code for authentication
  client.qr((qrData) {
    print('πŸ“± Scan this QR code with WhatsApp:');
    qrTerminal(qrData, 2, size: 10);
  });

  // Handle connection events
  client.on<Connected>((event) {
    print('πŸŽ‰ Connected to WhatsApp!');
  });

  // Start the client
  client.connect();
}

πŸ’‘ Examples

πŸ“± Basic Client Setup

import 'package:neonize/neonize.dart';
import 'dart:io';

void main() {
  // Initialize the WhatsApp client
  final client = NewAClient(
    name: 'my-whatsapp-bot',
    config: Config(
      tempPath: '/tmp',
      databasePath: './neonize.db',
    ),
  );

  // Setup QR code authentication
  client.qr((qrData) {
    print('πŸ“± Scan this QR code with WhatsApp:');
    qrTerminal(qrData, 2, size: 10);
  });

  // Handle successful connection
  client.on<Connected>((event) {
    print('πŸŽ‰ Successfully connected to WhatsApp!');
  });

  // Start the client
  client.connect();
}

πŸ’¬ Sending Messages

// Send simple text message
client.sendMessage(
  buildJID('1234567890'), 
  text: 'Hello from Neonize Dart! πŸš€'
);

// Send image with caption
final imageFile = File('/path/to/your/image.jpg');
final imageBytes = imageFile.readAsBytesSync();

final imageMessage = client.buildImageMessage(
  imageBytes,
  'Check out this amazing image! πŸ“Έ',
  'image/jpeg',
  Uint8List(0), // thumbnail (optional)
);

client.sendMessage(
  buildJID('1234567890'),
  message: imageMessage,
);

// Send document file
final document = File('/path/to/document.pdf');
final documentBytes = document.readAsBytesSync();

final documentMessage = client.buildDocumentMessage(
  documentBytes,
  'document.pdf',
  'Here is the document you requested',
  'application/pdf',
);

client.sendMessage(
  buildJID('1234567890'),
  message: documentMessage,
);

🎭 Message Event Handling

// Handle incoming text messages
client.on<Message>((message) {
  final messageText = message.message?.conversation;
  final senderJID = message.info?.messageSource?.sender;
  final chatJID = message.info?.messageSource?.chat;
  
  print('πŸ“¨ Received from $senderJID: $messageText');
  
  // Auto-reply functionality
  if (messageText?.toLowerCase() == 'hello') {
    client.sendMessage(chatJID, text: 'Hello there! πŸ‘‹');
  } else if (messageText?.toLowerCase() == 'help') {
    const helpText = '''
πŸ€– *Bot Commands:*
β€’ hello - Get a greeting
β€’ help - Show this help message
β€’ time - Get current time
β€’ joke - Get a random joke
''';
    client.sendMessage(chatJID, text: helpText);
  }
});

// Handle message receipts (delivery status)
client.on<Receipt>((receipt) {
  print('πŸ“§ Message ${receipt.type}: ${receipt.messageIds}');
});

// Handle typing indicators
client.on<ChatPresence>((chatPresence) {
  final chat = chatPresence.messageSource?.chat;
  final participant = chatPresence.messageSource?.sender;
  print('πŸ’¬ $participant is typing in $chat');
});

πŸ‘₯ Group Management

// Create a new group
final participants = [
  buildJID('1234567890'),
  buildJID('0987654321'),
];

final groupInfo = client.createGroup(
  'My Awesome Group πŸš€',
  participants,
);
print('πŸŽ‰ Group created: ${groupInfo.jid}');

// Get group information
final groupInfo = client.getGroupInfo(...);
print('πŸ“‹ Group Name: ${groupInfo.groupName}');
print('πŸ“ Description: ${groupInfo.groupDesc}');
print('πŸ‘₯ Participants: ${groupInfo.participants?.length ?? 0}');

// Add participants to group
client.updateGroupParticipants(
  jidGroup,
  [userJid],
  ParticipantAction.add,
);

// Remove participants from group
client.updateGroupParticipants(
  jidGroup,
  [userJid],
  ParticipantAction.remove,
);

// Update group name
client.updateGroupName(
  jidGroup,
  'New Group Name 🎯',
);

// Update group description
client.updateGroupDescription(
  jidGroup,
  'This is our updated group description',
);

πŸ” Contact & Profile Management

// Get user profile information
final profile = client.getProfilePicture(
  jidUser,
  true, // get full resolution
);
print('πŸ‘€ Profile picture URL: ${profile.url}');
print('πŸ†” Profile ID: ${profile.id}');

// Update your own status
client.setPresence(Presence.available);
print('βœ… Status updated to available');

// Get contact information
final isRegistered = client.isOnWhatsApp(['1234567890']);
if (isRegistered.isNotEmpty && isRegistered.first.isIn) {
  print('βœ… User is registered on WhatsApp');
  print('πŸ“± JID: ${isRegistered.first.jid}');
} else {
  print('❌ User is not on WhatsApp');
}

// Check if multiple contacts are on WhatsApp
final contacts = ['1234567890', '0987654321', '1122334455'];
final registeredContacts = client.isOnWhatsApp(contacts);
for (final contact in registeredContacts) {
  if (contact.isIn) {
    print('βœ… ${contact.jid} is on WhatsApp');
  } else {
    print('❌ ${contact.query} is not on WhatsApp');
  }
}

πŸ—οΈ Project Structure

neonize-dart/
β”œβ”€β”€ bin
β”‚   β”œβ”€β”€ main.dart
β”‚   └── qr_test.dart
β”œβ”€β”€ CHANGELOG.md
β”œβ”€β”€ lib
β”‚   β”œβ”€β”€ neonize.dart
β”‚   └── src
β”‚       β”œβ”€β”€ client.dart
β”‚       β”œβ”€β”€ config.dart
β”‚       β”œβ”€β”€ enum.dart
β”‚       β”œβ”€β”€ error.dart
β”‚       β”œβ”€β”€ event
β”‚       β”‚   β”œβ”€β”€ event.dart
β”‚       β”‚   └── type.dart
β”‚       β”œβ”€β”€ ffi
β”‚       β”‚   β”œβ”€β”€ bindings.dart
β”‚       β”‚   β”œβ”€β”€ structs.dart
β”‚       β”‚   └── utils.dart
β”‚       β”œβ”€β”€ helpers
β”‚       β”‚   β”œβ”€β”€ helpers.dart
β”‚       β”‚   └── image.dart
β”‚       β”œβ”€β”€ logging.dart
β”‚       └── qr.dart
β”œβ”€β”€ LICENSE
β”œβ”€β”€ Makefile
β”œβ”€β”€ neonize.db
β”œβ”€β”€ neonize-linux-amd64.so
β”œβ”€β”€ pubspec.lock
β”œβ”€β”€ pubspec.yaml
β”œβ”€β”€ README.md
β”œβ”€β”€ scripts
β”œβ”€β”€ test
β”‚   └── neonize_test.dart

πŸ“– Documentation

Core Classes

Event System

The event system in Neonize Dart is built around strongly-typed events:

// Type-safe event handling
client.on<Message>((msg) => handleMessage(msg));
client.on<Receipt>((receipt) => handleReceipt(receipt));
client.on<Presence>((presence) => handlePresence(presence));

Database Support

Neonize Dart supports multiple database backends:

// SQLite (default)
Config(databasePath: './app.db')

// PostgreSQL
Config(databasePath: 'postgres://user:pass@localhost/dbname')

🀝 Contributing

We welcome contributions! Here's how you can help:

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

Development Setup

# Clone the repository
git clone https://github.com/krypton-byte/neonize-dart.git
cd neonize-dart

# Get dependencies
dart pub get

# Run tests
dart test

# Run the example
dart run bin/main.dart

πŸ“„ License

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

πŸ™ Acknowledgments

  • Neonize - The powerful Python library this project wraps
  • Whatsmeow - The Go library that powers Neonize
  • Dart & Flutter Community - For the amazing ecosystem

πŸ“ž Support


Made with ❀️ for the Dart & Flutter community

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

About

πŸ› οΈ Modern Dart wrapper for WhatsApp automation via Neonize. Build chatbots, automate messaging, and handle WhatsApp events with clean, type-safe Dart APIs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages