A very simple and generic bot developed using Python and Selenium. He can be used as a starting point for some more complex operations depending on what's needed to be done.
- Open a specific chat given the contact or group name
- Send a message to the contact or group that was selected previously (depends on the previous method)
- Send a media supported file by WhatsApp and optionally use a caption (if the file is an image), it also depends on previously opening a chat
- You need to have Git installed
- You need to have Python installed
- You need to have Selenium installed (you can install it via Pip)
- You need to have a chosen webdriver installed
You can find it here.
You can find it here.
-
If you're using Python 3.x
$ sudo apt-get update $ sudo apt-get install python3-pip
Check installed version
$ pip3 --version
Should return something like this
#=> Output pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
-
If you're using Python 2.x
$ sudo apt-get update $ sudo apt-get install python-pip
Check installed version
$ pip --version
Should return something like this
#=> Output pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
-
If you're using Python 3.x and Pip3
pip3 install selenium
-
If you're using Python 2.x and Pip
pip install selenium
You can find the documentation here.
In this project I'm using chromedriver (can be found and downloaded here, you just need to check your current Chromium/Chrome version before downloading).
If you want to use another webdriver, Firefox's for instance, you can find more details and links here.
git clone git@github.com:fernandoepm1/zapbot.git
- Check your current Chromium/Chrome version and download the appropriate chromedriver (if you're using version Chromium 80 and linux64, the chromedriver in this project is already the right one)
- If you don't want to use Chrome, then download the appropriate webdriver and change the code to instanciate the selected browser
-
Using Python 3.x
python3 zapbot.py
-
Using Python 2.x
python zapbot.py
Important: After the first time the script is run, it will create the profile folder to save your current session, WhatsApp will request the QRcode, but just for the first time (as long as the profile folder is there). It's possible the first time does not work because of the QRcode request, but after that it should work properly.