Skip to main content

The (not so official) WhatsApp automation framework!

Project description

WhaBot Logo


Status PyPI version License

The (not so official) WhatsApp automation framework!

📝 Table of Contents

🧐 About

WhaBot is a framework that automates all the tasks that a human can do on WhatsApp!

It's created to (somehow) create powerfull bots in this platform, as we can do in others as Discord, Slack, Telegram, etc.

🏁 Getting Things Ready

If you follow this easy step by step guide, you will get you a copy of the project up and running on your local machine for development and testing purposes.

# Python 3.6+ required
python -m venv .venv
source .venv/bin/activate

pip install -U pip
pip install WhaBot

Also, the Core of this framework is Selenium, that's why you need to download a chromedriver binary that works with your chromium based browser and matches the correct version. You can find more information about this steup here.


For you to create a functional bot, you will need a WhatsApp account. We recommend a WhatsApp Bussiness account and a phone number just dedicated to run the bot.

Running it

After installing the framework via pip and downloading the correct chromedriver, we are ready to go!

Here is an example code to create a simple bot!

import WhaBot

WhaBot = WhaBot(reloaded=False)

chat = "Myself" # Change this to a contact from your contact lists! (This also works with phone numbers or groups!)

WhaBot.SendMessage(chat=chat, message="Hello!\nWe are up and running!!")

Once you have that done, here you have an actual bot, with 2 commands!

import time
import WhaBot

WhaBot = WhaBot(reloaded=False)

def HandleCommands(ctx):
	for contact in ctx:
		if WhaBot.CommandHandler(ctx=contact, command="!ping"):
			message = "Pong!\nWe are working fine!"
			WhaBot.SendMessage(chat=contact["Chat_Name"], message=message)

		elif WhaBot.CommandHandler(ctx=contact, command="!help"):
			message = f"Hey @{contact['Chat_Name']}!\nWe are still working in this option!\n\nStay tune for new updates!"
			WhaBot.SendMessage(chat=contact["Chat_Name"], message=message)

while __name__ == '__main__':
	unreads = SendMessage.GetUnreadChats(scrolls=10)

That's it! You now have your first bot up and running, listening for 2 commands: !ping and !help, try them!!

⚙️ Usage

The functions are very self-explained, but here is the list of functions and params!

Function Params Description Returns
GetUnreadChats scrolls:int Retrieeves the unread chats that the bot has [["Chat_Name":"Lanfran02", "Last_Message":"Hey!", "Time":"10:00", "Unreads":1, "is_group": FALSE]]
GetMutedChats scrolls:int Retrieves Muted Chats ["Lanfran02", "A Group", "Another User"]
GetPinnedChats None Retrieves Pinned Chats ["Lanfran02", "An special contact"]
GetLastMessagesFrom chat:str Retrieves the last messages from a chat ["Hey", "Don't forget to support!"]
GetChatName None Retrieves the conversation name where the bot is "Lanfran02"
SendMessage chat:str message:str Send a message to a desired chat boolean
SendImage chat:str message:str image:str Send a message with a local image attached to a desired chat boolean
SendDocument chat:str document:str Send a message with a local document attached to a desired chat boolean
CommandHandler ctx command:str Tries to find a desired command within the context boolean
BlockContact chat:str Block a desired contact boolean
UnblockContact chat:str Unblock a desired contact boolean
ExitGroup group_name:str Exit a desired group boolean
ArchiveChat chat:str Archive the desired chat boolean
PinChat chat:str Pin the desired chat boolean
MuteChat chat:str mute_time:str Mute the desired chat boolean
UnmuteChat chat:str Unmute the desired chat boolean
ChangeTheme theme:str Change the theme to dark or light boolean
TerminateSession sure:str Terminate the WhatsApp session boolean
CloseDriver None Closes the driver void

✍️ Authors

Feel free to contribute, you will be add to the the list of contributors who participated in this project!

⚖️ Disclaimer

We, the developers, are not responsible for any illegal actions carried out through the use of this software or that do not comply with the WhatsApp code of conduct.

The material embodied in this software is provided to you "as-is" and without warranty of any kind, express, implied or otherwise, including without limitation, any warranty of fitness for a particular purpose.

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

WhaBot-Release-1.0.tar.gz (11.4 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page