Wrapper for vjwhats library to send messages and sent messages
Project description
WhatsApp Library
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 WebDriverfind_by_username(username)- Open chat with specific contactsend_message(message)- Send text message to current chatsend_file(file_path, which=1)- Send file to current chatstart_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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wrapper_vjwhats-0.0.3.tar.gz.
File metadata
- Download URL: wrapper_vjwhats-0.0.3.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
675877e20b4a3fd49829feb61a3466db687fa0b103b84ace2bab2795252953cd
|
|
| MD5 |
6a9b3ddb3f5b3524c442187839fd0d61
|
|
| BLAKE2b-256 |
4aaad3afa29f8fb4f964bea8e25ac77b36a1c5d765690dbf7c084b91fbf2b3c0
|
File details
Details for the file wrapper_vjwhats-0.0.3-py3-none-any.whl.
File metadata
- Download URL: wrapper_vjwhats-0.0.3-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f39625a300d717acfdccfca6fbcd8e2f4aad2e898d7ea13158b2f6ec7d0b9e6
|
|
| MD5 |
471b43eb0db31b26d81f0ae768e47a2f
|
|
| BLAKE2b-256 |
85c02e09a0e02527fefe8bec9fd643611c42149467111e810c7595e12dd5c16b
|