Skip to main content

Whatsappy 4.2.0

License: MIT Downloads

Overview

Whatsappy is a Python library for interacting with WhatsApp Web using Selenium. With this library, you can automate WhatsApp tasks such as sending messages, creating groups, and more.

Requirements

  • Python 3.11+
  • Chrome 94+
  • WhatsApp Web in English

Installation

You can install Whatsappy using pip:

pip install whatsappy-py

Usage

Here's an example of how you can use Whatsappy to send a message:

from whatsappy import Whatsapp

# Create a new instance of Whatsapp
whatsapp = Whatsapp()

# Create event handlers
@whatsapp.event
def on_ready():
    print("WhatsApp Web is ready!")

@whatsapp.event
def on_message(chat):
    print(f"New message from {chat.name}: {chat.message}")

# Open WhatsApp Web in Chrome
whatsapp.run()

# Select the chat you want to send a message to
chat = whatsapp.open("John Smith")

# Send a message
chat.send("Hello, John!")

# Close WhatsApp Web
whatsapp.close()

API Reference

Whatsapp

Properties

  • driver: webdriver.Chrome: The Chrome driver.
  • unread_messages: List[UnreadMessage]: List of unread messages.
  • me: Me: The current user.
  • current_chat: str | None: The name of the current chat. Returns None if no chat is selected.

Methods

  • run(): Opens WhatsApp Web in Chrome.
  • close(): Closes the Chrome window.
  • open(chat: str) -> (Chat | Group | None): Selects a chat by name and returns a Chat or Group instance. Returns None if the chat does not exist.

Me

Properties

  • name: str: The name of the user.
  • about: str: The about of the user.
  • profile_picture: JpegImageFile: The profile picture of the user.

Chat

Properties

  • name: str: The name of the chat.
  • number: str: The number of the chat.
  • about: str: The about of the chat.
  • profile_picture: JpegImageFile: The profile picture of the chat.
  • last_message: Message | None: The last message of the chat.
  • is_muted: bool: Whether the chat is muted or not.
  • is_blocked: bool: Whether the chat is blocked or not.
  • is_pinned: bool: Whether the chat is pinned or not.

Methods

  • open(): Opens the chat.
  • send(message: str, attachments: Optional[List[str]] = None, type: Optional[str] = "auto"): Sends a message to the chat.
  • mute(): Mutes the chat.
  • unmute(): Unmutes the chat.
  • block(): Blocks the chat.
  • unblock(): Unblocks the chat.
  • clear(keep_starred: bool = False): Clears the chat messages.
  • delete(): Deletes the chat.
  • pin(): Pins the chat.
  • unpin(): Unpins the chat.

Group

Properties

  • subject: str: The subject of the group.
  • description: str: The description of the group.
  • profile_picture: Optional[JpegImageFile]: The profile picture of the group.
  • participants: int: The number of participants of the group.
  • last_message: Message | None: The last message of the group.
  • is_muted: bool: Whether the group is muted or not.
  • is_pinned: bool: Whether the group is pinned or not.

Methods

  • open(): Opens the group.
  • send(message: str, attachments: Optional[List[str]] = None, type: Optional[str] = "auto"): Sends a message to the group.
  • mute(): Mutes the group.
  • unmute(): Unmutes the group.
  • leave(): Leaves the group.
  • clear(keep_starred: bool = False): Clears the group messages.
  • pin(): Pins the group.
  • unpin(): Unpins the group.
  • promote(user: str): Promotes a user to admin.
  • demote(user: str): Demotes a user from admin.

Message

Properties

  • chat: Chat | Group: The chat the message belongs to.
  • author: str: The author of the message.
  • content: str: The content of the message.
  • timestamp: datetime.datetime: The timestamp of the message.
  • attachments: List[str]: The attachments of the message.
  • is_forwarded: bool: Whether the message is forwarded or not.
  • is_reply: bool: Whether the message is a reply or not.

Methods

  • reply(message: str, attachments: Optional[List[str]] = None, type: Optional[str] = "auto"): Replies to the message.

UnreadMessage

Properties

  • name: str: The name of the chat.
  • count: int: The number of unread messages in the chat.
  • message: Optional[str]: The last message in the chat.

Methods

  • reply(message: str, attachments: Optional[List[str]] = None, type: Optional[str] = "auto"): Replies to the unread chat with a message. and returns a Chat or Group instance.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Donation

If you like this project, please consider donating to help me continue working on it.

License

Whatsappy is licensed under the MIT License

Release files for whatsappy-py 4.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for whatsappy-py 4.2.1
File Size Uploaded
whatsappy-py-4.2.1.tar.gz 6.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for whatsappy-py 4.2.1
File Interpreter ABI Platform
whatsappy_py-4.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 6.6 MB

Release files / whatsappy-py-4.2.1.tar.gz

Download URL whatsappy-py-4.2.1.tar.gz
Size 6.6 MB
Tags Source
SHA-256 checksum
How to use checksums
17d173fff5c0a44d2ae35eec945ba5080f20a3e727ffbb7e1940dd3546204219
BLAKE2b-256 checksum
How to use checksums
b28f5ebfcbd689117d55ffcaba9eba9286533dd47d176ef87775666145ab67b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / whatsappy_py-4.2.1-py3-none-any.whl

Download URL whatsappy_py-4.2.1-py3-none-any.whl
Size 22.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9b3ceb8a0beca906ae20bb18dbd979b37647fcaafd64203f064c38ed70b67b97
BLAKE2b-256 checksum
How to use checksums
9ae9f62080415d11b96a2f3539454b9c7122bbaf5a596e7f9b52d1a24487403c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

4.2.1 This release

2 release files

4.2.0

2 release files

4.1.3

2 release files

4.1.2

2 release files

4.1.1

2 release files

4.1.0

2 release files

4.0.0

2 release files

3.3.5

1 release file

3.3.4

1 release file

3.3.3

1 release file

3.3.2

1 release file

3.3.1

1 release file

3.3.0

1 release file

3.2.0

1 release file

3.1.1

1 release file

3.1.0

1 release file

3.0.0

1 release file

2.3.1

1 release file

2.3

1 release file

2.1.2

1 release file

2.1.1

1 release file

2.1.0

1 release file

2.0.6

1 release file

2.0.5

1 release file

2.0.4

1 release file

2.0.3

1 release file

2.0.2

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.9.9

1 release file

1.9.8

1 release file

1.9.7

1 release file

1.9.6

1 release file

1.9.5

1 release file

1.9.4

1 release file

1.9.2

1 release file

1.9.1

1 release file

1.9.0

1 release file

1.8.8

1 release file

1.8.7

1 release file

0.1.8.7

1 release file

0.1.8.6

1 release file

0.1.8.5

1 release file

0.1.8.4

1 release file

0.1.8.3

1 release file

0.1.8.2

1 release file

0.1.8.1

1 release file

0.1.8

1 release file

0.1.7.1

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5.1

1 release file

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page