Skip to main content

Wrapper for vjwhats library to send messages and sent messages

Project description

WhatsApp Library

MIT License Python

A Python library that provides a convenient interface to interact with WhatsApp Web using Selenium. This library automates WhatsApp Web operations, enabling message sending, file sharing, and conversation management through Python code.

Developed by Renan, primarily used by VJ Bots for automation solutions.

Features

  • 🔍 Find and open conversations by username or phone number
  • 💬 Send text messages programmatically
  • 📎 Share files, images, and documents
  • 📱 Start new conversations with unsaved contacts
  • 🔄 Automated session handling with Chrome profiles

Installation

Install the WhatsApp library and its dependencies:

# Install required dependencies
pip install selenium

# Clone the repository (or install via pip if published)
git clone https://github.com/username/vjwhats.git
cd vjwhats
pip install -e .

Usage Example

from vjwhats import WhatsApp
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from pathlib import Path

def main():
    # Set up Chrome with an existing user profile (to use saved WhatsApp Web session)
    chrome_options = Options()
    chrome_options.add_argument("user-data-dir=C:/Users/EXAMPLE/AppData/Local/Google/Chrome/User Data")
    chrome_options.add_argument("profile-directory=Default")

    # Initialize the Chrome WebDriver
    driver = webdriver.Chrome(options=chrome_options)

    # Create WhatsApp instance
    wpp = WhatsApp(driver)

    # Example 1: Send message to existing contact
    wpp.find_by_username("Contact 1")
    wpp.send_message("Hello, this is a test message!")

    # Example 2: Send file to another contact
    wpp.find_by_username("Contact 2")
    wpp.send_file(Path("path/to/file"), which=1)  # 'which=1' refers to file selector type

    # Example 3: Start conversation with new number and send a file
    wpp.start_conversation("+55999977885")  # Format with country code
    wpp.send_file(Path("path/to/file"), which=1)

    # Close driver when finished
    # driver.quit()

if __name__ == "__main__":
    main()

API Reference

Core Functions

  • __init__(driver) - Initialize with Selenium WebDriver
  • find_by_username(username) - Open chat with specific contact
  • send_message(message) - Send text message to current chat
  • send_file(file_path, which=1) - Send file to current chat
  • start_conversation(phone) - Start new chat with phone number

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

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

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

wrapper_vjwhats-0.0.1.tar.gz (6.8 kB view details)

Uploaded Source

File details

Details for the file wrapper_vjwhats-0.0.1.tar.gz.

File metadata

  • Download URL: wrapper_vjwhats-0.0.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for wrapper_vjwhats-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3fc99c02a632d9f5b8e8ab156b314c269eddc2ad96b9061b0c359927b0d1a897
MD5 d8829ecc34dc3fb32f00d4e8aff9d9b6
BLAKE2b-256 243f3a931f77516a6aec1ef0d0762d5889816756b79671eed32a8f809f93dc0e

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