-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayer.py
More file actions
executable file
·34 lines (28 loc) · 1.61 KB
/
layer.py
File metadata and controls
executable file
·34 lines (28 loc) · 1.61 KB
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
34
from yowsup.layers.interface import YowInterfaceLayer, ProtocolEntityCallback
from yowsup.layers.protocol_messages.protocolentities import TextMessageProtocolEntity
from yowsup.layers.protocol_receipts.protocolentities import OutgoingReceiptProtocolEntity
from yowsup.layers.protocol_acks.protocolentities import OutgoingAckProtocolEntity
from Crawl_score import getscore
import datetime
class EchoLayer(YowInterfaceLayer):
@ProtocolEntityCallback("message")
def onMessage(self, messageProtocolEntity):
#send receipt otherwise we keep receiving the same message over and over
if True:
receipt = OutgoingReceiptProtocolEntity(messageProtocolEntity.getId(), messageProtocolEntity.getFrom(), 'read', messageProtocolEntity.getParticipant())
self.toLower(receipt)
fileobject=open("DataDump.txt","a")
fileobject.write(str(datetime.datetime.now()))
fileobject.write(" "+messageProtocolEntity.getBody())
fileobject.write(" "+messageProtocolEntity.getFrom())
fileobject.write("\n")
fileobject.close()
if messageProtocolEntity.getBody() == "#score" :
SMS = getscore()
for sms in SMS:
outgoingMessageProtocolEntity = TextMessageProtocolEntity(sms,to = messageProtocolEntity.getFrom())
self.toLower(outgoingMessageProtocolEntity)
@ProtocolEntityCallback("receipt")
def onReceipt(self, entity):
ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", entity.getType(), entity.getFrom())
self.toLower(ack)