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.4.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

wrapper_vjwhats-0.0.4-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for wrapper_vjwhats-0.0.4.tar.gz
Algorithm Hash digest
SHA256 226b16ac5f4a4fbcade39c63e8d5fb73bb0e83c71726b9be4cff179055a5b565
MD5 0a01bcf46aecb225e261d57c29bed972
BLAKE2b-256 97999a5e7659f46ce65054fd214a4f000e0efa06d434e87d5595e53588bb5791

See more details on using hashes here.

File details

Details for the file wrapper_vjwhats-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for wrapper_vjwhats-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ba91249843831ab9e818710488bf814f09c2000d6c6012c4b0479d80dab5c1ab
MD5 f586f27befce46dc98f84618018d34dc
BLAKE2b-256 2fad96a8c7315d642c5af557d9b48e6a2ba69760efb1572f10ad4599f5f724ce

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