예제 #1
0
def run_hologram_receive_sms(args):

    global hologram
    hologram = HologramCloud(None,
                             enable_inbound=False,
                             network='cellular-iota')

    hologram.event.subscribe('sms.received', popReceivedSMS)
    hologram.enableSMS()

    handle_timeout(args['timeout'])

    hologram.disableSMS()
예제 #2
0
        sendSMS("Currently I'm thinking about " + str(numProcesses) + " things right now. I'm a genius!")

    elif "body" in sms.message:
        # If I'm asked anything about my body
        sendSMS("Sniffle :(  I do not have a body, will you make one for me?")

    else:
        # default answer if I have no idea what was asked
        sendSMS("Sorry, I do not have an answer for that question.")

# Connect to the Hologram Global Network
hologram.network.connect()

try:
    print "Listening for incoming SMS..."
    while True:
        # Start listening for incoming SMS questions
        hologram.enableSMS()
        time.sleep(5)
        hologram.disableSMS()

        # check if we recieved a new question
        sms = hologram.popReceivedSMS()
        if sms is not None:
            print "GOT MESSAGE"
            print sms
            answerQuestion(sms) # try to answer the question and send a response
finally:
    print "Closing cell connection"
    hologram.network.disconnect()