Skip to main content

QwenPaw's fork of neonize with proto stubs regenerated against protoc 30.2 (gencode 6.30.2) so it cohabitates with protobuf 6.x ecosystems (grpcio-status, google-cloud-*, etc.). Upstream neonize ships stubs generated by protoc 32.1 which require protobuf runtime >= 7.34.1 and break those packages. Drop-in replacement: keeps the `neonize` import path unchanged.

Project description

๐Ÿš€ Neonize

WhatsApp Automation Made Simple for Python

Python Go License WhatsApp Release

A powerful Python library built on top of Whatsmeow - enabling seamless WhatsApp automation with enterprise-grade performance


Getting Started โ€ข Features โ€ข Examples โ€ข Documentation โ€ข Contributing

Neonize

โœจ What is Neonize?

Neonize is a cutting-edge Python library that transforms WhatsApp automation from complex to simple. Built on top of the robust Whatsmeow Go library, it delivers enterprise-grade performance with Python's ease of use and developer-friendly API.

๐ŸŽฏ Why Choose Neonize?

  • ๐Ÿ”ฅ High Performance - Built with Go backend for maximum speed and efficiency
  • ๐Ÿ Python Native - Seamless integration with your existing Python ecosystem
  • ๐Ÿ›ก๏ธ Enterprise Ready - Production-tested with robust error handling and reliability
  • โšก Real-time - Handle messages, media, and events in real-time with async support
  • ๐Ÿ”ง Easy Integration - Simple, intuitive API design for rapid development
  • ๐Ÿ“š Well Documented - Comprehensive documentation with practical 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
  • ๐Ÿ“Š Polls and interactive messages
  • ๐Ÿšซ Blocklist management

Developer Experience

  • ๐Ÿ”„ Event-driven architecture
  • ๐Ÿ“Š Built-in logging and debugging
  • ๐Ÿ—„๏ธ SQLite and PostgreSQL database support
  • โšก Both synchronous and asynchronous APIs
  • ๐Ÿงช Comprehensive examples and documentation

๐Ÿ’Ž Sponsors

We are grateful to our sponsors who help make Neonize possible. Their support enables us to continue developing and maintaining this open-source project for the community.

User avatar: FeedMeUser avatar: Fernando Leon Franco

๐Ÿค Become a Sponsor

Your sponsorship helps us:

  • โšก Maintain and improve Neonize
  • ๐Ÿ› Fix bugs and add new features
  • ๐Ÿ“š Create better documentation
  • ๐Ÿ”ง Provide community support
  • ๐Ÿš€ Keep the project free and open-source

Become a Sponsor โ†’

Thank you to all our sponsors for believing in Neonize and supporting open-source development! ๐Ÿ™

๐Ÿš€ Getting Started

Prerequisites

  • Python 3.8 or higher
  • Go 1.19+ (for building from source)

Installation

pip install neonize

Quick Start

from neonize.client import NewClient
from neonize.events import MessageEv, ConnectedEv, event

# Initialize client
client = NewClient("your_bot_name")

@client.event(ConnectedEv)
def on_connected(client: NewClient, event: ConnectedEv):
    print("๐ŸŽ‰ Bot connected successfully!")

@client.event(MessageEv)
def on_message(client: NewClient, event: MessageEv):
    if event.message.conversation == "hi":
        client.reply_message("Hello! ๐Ÿ‘‹", event.message)

# Start the bot
client.connect()
event.wait()  # Keep running

Async Version

import asyncio
from neonize.aioze.client import NewAClient
from neonize.aioze.events import MessageEv, ConnectedEv

client = NewAClient("async_bot")

@client.event(MessageEv)
async def on_message(client: NewAClient, event: MessageEv):
    if event.Message.conversation == "ping":
        await client.reply_message("pong! ๐Ÿ“", event)

async def main():
    await client.connect()
    await client.idle()  # Keep receiving events

asyncio.run(main())

!!! important "Python 3.10+ Event Loop" Neonize uses asyncio.run() as the standard entry point. The event loop is automatically obtained via asyncio.get_running_loop() inside connect(). Do not use the deprecated asyncio.get_event_loop() or loop.run_until_complete() โ€” these raise errors on Python 3.12+.

๐Ÿ’ก Examples

๐Ÿ“ฑ Basic Client Setup

from neonize.client import NewClient
from neonize.events import MessageEv, ConnectedEv, event
import logging

# Enable logging for debugging
logging.basicConfig(level=logging.INFO)

# Initialize the WhatsApp client
client = NewClient(
    name="my-whatsapp-bot",
    database="./neonize.db"
)

# Handle successful connection
@client.event(ConnectedEv)
def on_connected(client: NewClient, event: ConnectedEv):
    print("๐ŸŽ‰ Successfully connected to WhatsApp!")
    print(f"๐Ÿ“ฑ Device: {event.device}")

# Start the client
client.connect()
event.wait()

๐Ÿ’ฌ Sending Messages

from neonize.utils import build_jid

# Send simple text message
jid = build_jid("1234567890")
client.send_message(jid, text="Hello from Neonize! ๐Ÿš€")

# Send image with caption
with open("image.jpg", "rb") as f:
    image_data = f.read()

image_msg = client.build_image_message(
    image_data,
    caption="Check out this amazing image! ๐Ÿ“ธ",
    mime_type="image/jpeg"
)
client.send_message(jid, message=image_msg)

# Send document file
with open("document.pdf", "rb") as f:
    doc_data = f.read()

doc_msg = client.build_document_message(
    doc_data,
    filename="document.pdf",
    caption="Here is the document you requested",
    mime_type="application/pdf"
)
client.send_message(jid, message=doc_msg)

๐ŸŽญ Message Event Handling

from neonize.events import MessageEv, ReceiptEv, PresenceEv
from datetime import datetime

# Handle incoming text messages
@client.event(MessageEv)
def on_message(client: NewClient, event: MessageEv):
    message_text = event.message.conversation
    sender_jid = event.info.message_source.sender
    chat_jid = event.info.message_source.chat
    
    print(f"๐Ÿ“จ Received from {sender_jid}: {message_text}")
    
    # Auto-reply functionality
    if message_text and message_text.lower() == "hello":
        client.send_message(chat_jid, text="Hello there! ๐Ÿ‘‹")
    elif message_text and message_text.lower() == "help":
        help_text = """
๐Ÿค– *Bot Commands:*
โ€ข hello - Get a greeting
โ€ข help - Show this help message
โ€ข time - Get current time
โ€ข joke - Get a random joke
"""
        client.send_message(chat_jid, text=help_text)
    elif message_text and message_text.lower() == "time":
        current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        client.send_message(chat_jid, text=f"๐Ÿ• Current time: {current_time}")

# Handle message receipts (delivery status)
@client.event(ReceiptEv)
def on_receipt(client: NewClient, event: ReceiptEv):
    print(f"๐Ÿ“ง Message {event.receipt.type}: {event.message_ids}")

# Handle typing indicators
@client.event(PresenceEv)
def on_presence(client: NewClient, event: PresenceEv):
    chat = event.message_source.chat
    participant = event.message_source.sender
    print(f"๐Ÿ’ฌ {participant} is {event.presence} in {chat}")

๐Ÿ‘ฅ Group Management

from neonize.utils import build_jid

# Create a new group
participants = [
    build_jid("1234567890"),
    build_jid("0987654321"),
]

group_info = client.create_group(
    "My Awesome Group ๐Ÿš€",
    participants
)
print(f"๐ŸŽ‰ Group created: {group_info.jid}")

# Get group information
group_info = client.get_group_info(group_jid)
print(f"๐Ÿ“‹ Group Name: {group_info.group_name}")
print(f"๐Ÿ“ Description: {group_info.group_desc}")
print(f"๐Ÿ‘ฅ Participants: {len(group_info.participants)}")

# Add participants to group
client.update_group_participants(
    group_jid,
    [user_jid],
    "add"
)

# Remove participants from group
client.update_group_participants(
    group_jid,
    [user_jid],
    "remove"
)

# Update group name
client.update_group_name(
    group_jid,
    "New Group Name ๐ŸŽฏ"
)

# Update group description
client.update_group_description(
    group_jid,
    "This is our updated group description"
)

๐Ÿ” Contact & Profile Management

# Get user profile information
profile = client.get_profile_picture(
    user_jid,
    full_resolution=True
)
print(f"๐Ÿ‘ค Profile picture URL: {profile.url}")
print(f"๐Ÿ†” Profile ID: {profile.id}")

# Update your own status
client.set_presence("available")
print("โœ… Status updated to available")

# Check if contacts are on WhatsApp
contacts = ["1234567890", "0987654321", "1122334455"]
registered_contacts = client.is_on_whatsapp(contacts)

for contact in registered_contacts:
    if contact.is_in:
        print(f"โœ… {contact.jid} is on WhatsApp")
    else:
        print(f"โŒ {contact.query} is not on WhatsApp")

๐Ÿ“Š Polls & Interactive Messages

from neonize.utils.enum import VoteType

# Create a poll
poll_msg = client.build_poll_vote_creation(
    "What's your favorite programming language?",
    ["Python ๐Ÿ", "Go ๐Ÿš€", "JavaScript ๐Ÿ’›", "Rust ๐Ÿฆ€"],
    VoteType.SINGLE_SELECT
)
client.send_message(chat_jid, message=poll_msg)

# Handle poll responses
@client.event(MessageEv)
def on_poll_vote(client: NewClient, event: MessageEv):
    voter = event.info.message_source.sender
    selected_options = event.message.poll_update_message.vote.selected_options
    print(f"๐Ÿ“Š {voter} voted for: {selected_options}")

๐Ÿ—๏ธ Project Structure

neonize/
โ”œโ”€โ”€ examples/
โ”‚   โ”œโ”€โ”€ async_basic.py
โ”‚   โ”œโ”€โ”€ basic.py
โ”‚   โ”œโ”€โ”€ multisession_async.py
โ”‚   โ”œโ”€โ”€ multisession.py
โ”‚   โ””โ”€โ”€ paircode.py
โ”œโ”€โ”€ goneonize/
โ”‚   โ”œโ”€โ”€ build_python_proto.py
โ”‚   โ”œโ”€โ”€ chat_settings_store.go
โ”‚   โ”œโ”€โ”€ contact_store.go
โ”‚   โ”œโ”€โ”€ go.mod
โ”‚   โ”œโ”€โ”€ go.sum
โ”‚   โ”œโ”€โ”€ main.go
โ”‚   โ””โ”€โ”€ defproto/
โ”œโ”€โ”€ neonize/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ client.py
โ”‚   โ”œโ”€โ”€ events.py
โ”‚   โ”œโ”€โ”€ types.py
โ”‚   โ”œโ”€โ”€ aioze/          # Async client
โ”‚   โ”œโ”€โ”€ proto/          # Protocol buffers
โ”‚   โ””โ”€โ”€ utils/          # Helper utilities
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ conf.py
โ”‚   โ”œโ”€โ”€ index.rst
โ”‚   โ””โ”€โ”€ getstarted.rst
โ””โ”€โ”€ tools/              # Build and development tools

๐Ÿ“– Documentation

Core Classes

Event System

The event system in Neonize is built around decorators and type-safe events:

# Synchronous event handling
@client.event(MessageEv)
def on_message(client: NewClient, event: MessageEv):
    handle_message(event)

@client.event(ReceiptEv)
def on_receipt(client: NewClient, event: ReceiptEv):
    handle_receipt(event)

# Asynchronous event handling
@async_client.event(MessageEv)
async def on_message(client: NewAClient, event: MessageEv):
    await handle_message_async(event)

Database Support

Neonize supports multiple database backends for storing session data:

# SQLite (default)
client = NewClient("bot_name", database="./app.db")

# PostgreSQL (recommended for production)
client = NewClient("bot_name", database="postgres://user:pass@localhost/dbname")

# In-memory (for testing)
client = NewClient("bot_name", database=":memory:")

Multi-Session Support

Handle multiple WhatsApp accounts simultaneously:

import asyncio
from neonize.aioze.client import ClientFactory, NewAClient
from neonize.aioze.events import MessageEv, ConnectedEv

client_factory = ClientFactory("multisession.db")

# Load existing sessions from database
for device in client_factory.get_all_devices():
    client_factory.new_client(device.JID)

# Register shared event handlers
@client_factory.event(ConnectedEv)
async def on_connected(client: NewAClient, event: ConnectedEv):
    print(f"โšก Client connected")

@client_factory.event(MessageEv)
async def on_message(client: NewAClient, event: MessageEv):
    text = event.Message.conversation
    if text == "ping":
        await client.reply_message("pong!", event)

async def main():
    await client_factory.run()      # connect() all clients
    await client_factory.idle_all()  # keep running

asyncio.run(main())

๐Ÿค 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.git
cd neonize

# Install dependencies with Poetry
poetry install --with dev

# Or install with pip in development mode
pip install -e .

# Run the basic example
python examples/basic.py

# Run tests
python -m pytest

# Build documentation
cd docs && make html

Code Standards

  • Follow PEP 8 for Python code style
  • Use type hints for better code documentation
  • Write comprehensive tests for new features
  • Update documentation for API changes
  • Ensure backward compatibility when possible

๐Ÿ—„๏ธ Database Configuration

SQLite (Default)

Perfect for development and small-scale deployments:

client = NewClient("my_bot", database="./whatsapp.db")

PostgreSQL (Production Recommended)

For high-performance and scalable applications:

# Basic connection
client = NewClient("my_bot", database="postgres://username:password@localhost:5432/dbname")

# With SSL disabled
client = NewClient("my_bot", database="postgres://username:password@localhost:5432/dbname?sslmode=disable")

# With SSL required
client = NewClient("my_bot", database="postgres://username:password@localhost:5432/dbname?sslmode=require")

Connection Pool Settings

For production applications, configure connection pooling:

database_url = "postgres://user:pass@localhost:5432/neonize?pool_min_conns=5&pool_max_conns=20"
client = NewClient("production_bot", database=database_url)

๐Ÿš€ Quick Integration

With FastAPI

from contextlib import asynccontextmanager
from fastapi import FastAPI
from neonize.aioze.client import NewAClient
from neonize.aioze.events import MessageEv
from neonize.utils.jid import build_jid

whatsapp_client = NewAClient("fastapi_bot")

@whatsapp_client.event(MessageEv)
async def on_message(client: NewAClient, event: MessageEv):
    if event.Message.conversation == "/api_status":
        await client.reply_message("API is running! โœ…", event)

@asynccontextmanager
async def lifespan(app: FastAPI):
    # connect() automatically picks up the running event loop
    await whatsapp_client.connect()
    yield
    await whatsapp_client.disconnect()

app = FastAPI(lifespan=lifespan)

@app.get("/send-message")
async def send_message(phone: str, message: str):
    jid = build_jid(phone)
    await whatsapp_client.send_message(jid, message)
    return {"status": "sent"}

With Django

# apps.py
from django.apps import AppConfig
from neonize.client import NewClient
import threading

class WhatsAppConfig(AppConfig):
    name = 'whatsapp_integration'
    
    def ready(self):
        self.whatsapp_client = NewClient("django_bot")
        thread = threading.Thread(target=self.whatsapp_client.connect)
        thread.daemon = True
        thread.start()

With Flask

from flask import Flask, request, jsonify
from neonize.client import NewClient
import threading

app = Flask(__name__)
whatsapp_client = NewClient("flask_bot")

@app.route('/webhook', methods=['POST'])
def webhook():
    data = request.json
    phone = data.get('phone')
    message = data.get('message')
    
    if phone and message:
        jid = build_jid(phone)
        whatsapp_client.send_message(jid, text=message)
        return jsonify({"status": "success"})
    
    return jsonify({"status": "error"}), 400

if __name__ == '__main__':
    # Start WhatsApp client in background
    thread = threading.Thread(target=whatsapp_client.connect)
    thread.daemon = True
    thread.start()
    
    app.run(debug=True)

๐Ÿ“„ License

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

๐Ÿ™ Acknowledgments

  • Whatsmeow - The powerful Go library that powers Neonize
  • Thundra - Companion library for easy bot creation
  • Python Community - For the amazing ecosystem and support
  • Contributors - All the developers who have contributed to this project

๐Ÿ“ž Support

๐ŸŒŸ Introducing Tryx

Looking for another powerful tool for WhatsApp automation? Check out Tryx โ€” a Rust-powered Python SDK designed for building WhatsApp automations with an async-first API, strong typing, and production-focused performance.

Why Tryx?

  • Async-first architecture for event-driven bots
  • Python-friendly API with namespace-based clients
  • High-performance native core for protocol and transport workloads
  • Typed interfaces for better editor support and safer integrations

Tryx combines the best of:

  • Rust for protocol and runtime-heavy paths
  • PyO3 for Python bindings
  • Tokio for async orchestration
  • Typed Python package distribution (.pyi + py.typed)

Note: This project is an independent developer SDK and is not affiliated with WhatsApp or Meta.

For more details, visit the Tryx repository.


๐ŸŒŸ Related Projects

  • Thundra - High-level bot framework built on Neonize
  • Neonize Dart - Dart/Flutter wrapper for Neonize
  • Whatsmeow - Go WhatsApp Web API library
  • Tryx - Rust-powered Python SDK for WhatsApp automation

Made with โค๏ธ for the Python community

If this project helped you, please consider giving it a โญ on GitHub!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neonize_qwenpaw-0.3.16.1.tar.gz (6.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file neonize_qwenpaw-0.3.16.1.tar.gz.

File metadata

  • Download URL: neonize_qwenpaw-0.3.16.1.tar.gz
  • Upload date:
  • Size: 6.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for neonize_qwenpaw-0.3.16.1.tar.gz
Algorithm Hash digest
SHA256 98423df2c18ded9659426d73b8cad9473e254094c11119c1dfd0cd8b3a9ab585
MD5 be42698a962ecd39052b9e4ebbc67b3f
BLAKE2b-256 39cfb66851579651b6cb1d75524e484a46c1716fd13778e2ec80e324556e98f7

See more details on using hashes here.

File details

Details for the file neonize_qwenpaw-0.3.16.1-py310-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for neonize_qwenpaw-0.3.16.1-py310-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 68bdb8604c120bcb419d309c018db73a6854e6dd173878b1b14b0d52268925ae
MD5 5d2c0bc26973bfae695d0a40f18787ed
BLAKE2b-256 bc1de929031fc85f96730962c78f6a422665146b8de28292146dd9ccb74f3d42

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page