Skip to content

danielcardeenas/whatsapp-framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Warning

Whatsapp blocks numbers now. Framework wont work properly until next version

Meanwhile heres a better alternative: project sulla

mac (Whatsapp framework)

Version Version

Mac is a whatsapp bot/framework I made as a weekend project. The project itself has all you need to make your own custom bot easily.

Mac has built-in human behavior so you only have to worry about the functions you make. Every module works completely separated from the core, this means that you can erease every module and mac will keep working

This needs Python 3.5

Setup:

  1. Clone this repository (with submodules since it uses tgalal's yowsup library)
> git clone https://github.com/danielcardeenas/whatsapp-framework.git
  1. Run setup.sh (Most likely on sudo since its going to install some libraries)
> sudo ./setup.sh
  1. Register your phone and get a password with like this:
# Replace CC with your country code (See https://countrycode.org)
> yowsup-cli registration --requestcode sms --phone CCXXXXXXXX --cc CC -E android
# After getting the sms code (in this example: 123456)
> yowsup-cli registration --register 123456 --phone CCXXXXXXXX --cc CC -E android
  1. Open config.py and add set your credentials

  2. Ready to go! (Now you can add your own whatsapp modules)

> ./start.sh

Quickstart

Create your own module inside modules/ directory

# modules/hi_module.py

from app.mac import mac, signals

@signals.message_received.connect
def handle(message):
    if message.text == "hi":
        mac.send_message("Hello", message.conversation)
        
        # Can also send media
        #mac.send_image("path/to/image.png", message.conversation)
        #mac.send_video("path/to/video.mp4", message.conversation)

Now you should only add it into modules/__init__.py to enable the module

# modules/__init__.py
...
from modules import hi_module
...

And that's it! You are ready to go.

If your module needs libraries from pip you should add them into a requirements.txt and run sudo ./setup.sh to download the dependencies
You can take hihelp module as an example.

Updates

The project is not submoduling yowsup now due to a lot of the modifications made are focused for this project only and to make things simpler.

  • Notification on messages receipt (received and blue check marks)
  • Get contacts statuses
  • Get contacts profile picture (also from groups)
  • Set profile picture (also from groups)
  • Send videos (needs ffmpeg installed)
  • Add support for @tag messages
  • Add support for reply messages
  • Add support for receiving images
  • Add support for big receiving big files (downloading and decryption done in chunks)
  • Add support for sending images
  • Add support for encrypting images in chunks (TODO)
  • Add pickle support to remember the messages when mac its turned off(TODO)

Example screenshots:

Wiki

Read this