-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrun.py
33 lines (27 loc) · 997 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from yowsup.stacks import YowStackBuilder
from layer import EchoLayer
from yowsup.layers.auth import AuthError
from yowsup.layers import YowLayerEvent
from yowsup.layers.network import YowNetworkLayer
from dotenv import load_dotenv
import os
from os.path import expanduser
envPath = str(expanduser("~")) + '/whatsappbot.env'
print(envPath)
load_dotenv(envPath)
UNAME = str(os.environ.get("uname"))
PASS = str(os.environ.get("pass"))
credentials = (UNAME, PASS) # replace with your phone and password
if __name__== "__main__":
stackBuilder = YowStackBuilder()
stack = stackBuilder\
.pushDefaultLayers(True)\
.push(EchoLayer)\
.build()
print("setting credentials")
stack.setCredentials(credentials)
stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT)) #sending the connect signal
try:
stack.loop() #this is the program mainloop
except AuthError as e:
print("Authentication Error: %s" % e.message)