-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReadMsg.py
48 lines (39 loc) · 1.36 KB
/
ReadMsg.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import SendMsg
import Conexion
class ReadMsg:
msg = ""
COMMAND_PEDIR_TEMPERATURA = 1
sendMsg = None
stopMsg = 1
con = None
authorId = None
def __init__(self, fbChat, author):
self.authorId = author
self.sendMsg = SendMsg.sendMsg(fbChat)
def setMessage(self, msg):
self.msg = msg
def stopMsg(self):
self.stopMsg = 0
def setAuthorId(self, author):
self.authorId = author
def getAuthorId(self):
return self.authorId
def decifrarComando(self, msg, code = None): # En este metodo deberias hacer lo de PLN
self.con = Conexion.Conexion()
if msg == "dame la temperatura":
fltTemperatura = self.con.lectura()
self.executeAction(SendMsg.sendMsg.ID_MSG_RESPONSE_TEMP, [fltTemperatura])
self.con.close()
elif msg == "dame la temperatura en todo momento" or code == 1:
self.stopMsg = 1
while self.stopMsg:
fltTemperatura = self.con.lectura()
self.executeAction(SendMsg.sendMsg.ID_MSG_RESPONSE_TEMP, [fltTemperatura])
self.con.close()
return 1
elif msg == "parar":
self.stopMsg = 0
return 0
def executeAction(self, comando, datos):
if comando == self.COMMAND_PEDIR_TEMPERATURA:
self.sendMsg.send(comando, datos)