mukulhase / WebWhatsapp-Wrapper

An API for sending and receiving messages over web.whatsapp [Working as of 18th May 2018]
https://webwhatsapi.readthedocs.io/en/latest/
MIT License
2.03k stars 796 forks source link

Can somebody explain to me how to get started? #95

Closed ghost closed 6 years ago

ghost commented 6 years ago

Could someone please explain to me how to get started with this API, I have some university level Java and C++ knowledge and I will be learning Python syntax as I make a simple bot using this API that posts the messages of people that deleted them and maybe send a couple of links on request. The problem is that I am a total noob, so I've got no idea how to set up the API. Is it all done from inside the browser or I need to install python on my pc as well. I'm using Chrome (but i can switch to firefox) and I'm on a Windows PC. A simple newbie guide would be very appreciated, doesn't have to be step by step, the obvious parts I can google. Basically a list of programs that I need in order to get started.

Thank you.

ghost commented 6 years ago

At first you have to install Python (v2.7) on the system, which the WhatsApp-Web should run on. After this you need to follow the README.md. In the following is a little example for an autoreply for the messages "Hi" and "How are you?":

import time
from webwhatsapi import WhatsAPIDriver
from webwhatsapi.objects.message import Message

driver = WhatsAPIDriver()
print("Waiting for QR")
driver.wait_for_login()

print("Bot started")

while True:
    time.sleep(3)
    print('Checking for more messages')
    for contact in driver.get_unread():
        for message in contact.messages:
            if isinstance(message, Message):
                msg = message.safe_content.lower()
                if(msg == "hi")
                    contact.chat.send_message("Hi, I'm Spielie and what's your name?")
                elif(msg = "how are you?")
                    contact.chat.send_message("I'm fine")

Please let me know if you need more help

Xetera commented 6 years ago

Also just fyi, you're probably working with python 3.6 as of now so if you want to install a different version of python without messing up your current one you can download Anaconda and install python2 and the library on there

ghost commented 6 years ago

Yes I did, in fact, download python 3.6 but I since uninstalled it. Thank you for the help guys.