A plugin based whatsapp bot
WhatsBot is one of my weekend - just for fun projects. Thanks to plugin logic, all you need is write the plugin you want and enable it right on the chat without touching the core code.
This bot uses Yowsup, a python library that enables you build application which use whatsapp service.
You might find some dirty and ugly code, feel free to make it clean and better.
- Requires python3 mine is 3.6
- Requires MySQL Don't ask me why i am using this, it's easy to integrate with my other stuff that uses MySQL too. Simply, i do what i want to do :D
- Python Virtualenv
- Yowsup https://github.com/AragurDEV/yowsup This is a fork of https://github.com/tgalal/yowsup
- Edit
VIRTUAL_ENV
in launch.sh with your virtualenv path, ex:VIRTUAL_ENV=${HOME}/.virtualenvs/whatsbot
- Run the install command:
./launch.sh install
- Register to whatsapp
./launch.sh register
Follow the instructions, you will be prompted to input phone number and verification code sent via sms, just follow it. Then you will get password.
- Edit credentials and other configuration detail in
data/config.json
. You need to specify database (make sure it's prepared already). Sudo user is your number in whatsapp user_id format.
{
"bot_name": "Ellissa",
"download_dir": "/tmp/whatsbot",
"credentials" : {
"phone": "62858xxxxxxx",
"password": "xxxxxxxxxxxxxxxxx="
},
"database": {
"db_host": "localhost",
"db_user": "xxxx_user",
"db_password": "xxxxxxxxx",
"db_name": "xxxx_db"
},
"sudo_user": ["62899xxxxxxx@s.whatsapp.net"],
"plugins": ["admin"],
"contacts": {
"62899xxxxxxxxxx": "Botmaster"
}
}
- Via terminal
./launch.sh
- Install as systemd service
./launch.sh deploy
It will start automatically
sudo systemctl start whatsbot
sudo systemctl stop whatsbot
To remove from service you can run this command ./launch.sh undeploy
You can write plugin based on example
chat_data
is where your conversation done. Can be private message (chat_data = user data
), or group message (chat_data = group data
)
user_data
is data of user / sender
- Show plugins available
/plugins
- Enable plugin (botself)
/plugins enable botself
- Disable plugin (botself)
/plugins disable botself
- Reload plugins
/plugins reload
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details
- Hat tip to anyone who's code was used
- mac - danielcardeenas
- cups of coffee
- etc
If you love this project, you can buy me a cup of coffee :)