-
Notifications
You must be signed in to change notification settings - Fork 0
/
whatsappChat.py
28 lines (23 loc) · 1.17 KB
/
whatsappChat.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
from yowsup.layers.interface import YowInterfaceLayer, ProtocolEntityCallback
from yowsup.layers.protocol_messages.protocolentities import TextMessageProtocolEntity
from yowsup.layers.protocol_receipts.protocolentities import IncomingReceiptProtocolEntity
from yowsup.layers.protocol_acks.protocolentities import OutgoingAckProtocolEntity
import time
class ChatLayer(YowInterfaceLayer):
PROP_MESSAGES = "org.openwhatsapp.yowsup.prop.sendclient.queue"
@ProtocolEntityCallback("success")
def onSuccess(self, successProtocolEntity):
for target in self.getProp(self.__class__.PROP_MESSAGES, []):
phone, message = target
messageEntity = TextMessageProtocolEntity(message, to=phone)
receipt = IncomingReceiptProtocolEntity(messageEntity.getId(), phone, int(time.time()))
self.toLower(messageEntity)
print "Testing"
self.toLower(receipt)
@ProtocolEntityCallback("receipt")
def onReceipt(self, entity):
print "Inside receipt"
self.toLower(entity.ack())
@ProtocolEntityCallback("ack")
def onAck(self, entity):
self.lower(entity.ack())