yowsup
yowsup copied to clipboard
Maintaining state in a yowsup application
Thats more a python problem than an Yowsup specific problem.
I agree with dedmen.
This question is more for stackoverflow, i think.
Anyway, try to store the values in a global list, and when you get all you need, then make the database insert.
closing as not exactly yowsup issue
@zenithanon you would just send the message to an actual USSD app that keeps state. here is a simple example using zeromq
def ussdRequest(self,messageProtocolEntity):
try:
context = zmq.Context()
sock = context.socket(zmq.REQ)
sock.connect("tcp://127.0.0.1:5690")
message = "{msisdn}||{message}".format(msisdn=messageProtocolEntity.getFrom(False),
message=messageProtocolEntity.getBody())
print "req >> %s from %s"% (messageProtocolEntity.getBody(),messageProtocolEntity.getFrom(False))
sock.send(message)
resp = sock.recv()
resp = resp.split('||')
outgoingMessageProtocolEntity = TextMessageProtocolEntity(
resp[1],to = '%[email protected]'% (resp[0]))
self.toLower(outgoingMessageProtocolEntity)
print "resp << %s to %s"% (resp[0],resp[1])
sock.close()
except Exception,e:
print e