yowsup icon indicating copy to clipboard operation
yowsup copied to clipboard

Maintaining state in a yowsup application

Open zenithanon opened this issue 11 years ago • 4 comments

zenithanon avatar Feb 10 '15 04:02 zenithanon

Thats more a python problem than an Yowsup specific problem.

dedmen avatar Feb 10 '15 20:02 dedmen

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.

ericromanenghi avatar Feb 10 '15 22:02 ericromanenghi

closing as not exactly yowsup issue

tgalal avatar Feb 17 '15 06:02 tgalal

@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

gisho avatar Feb 23 '15 21:02 gisho