当前位置: 首页>>代码示例>>Python>>正文


Python Tropo.call方法代码示例

本文整理汇总了Python中tropo.Tropo.call方法的典型用法代码示例。如果您正苦于以下问题:Python Tropo.call方法的具体用法?Python Tropo.call怎么用?Python Tropo.call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tropo.Tropo的用法示例。


在下文中一共展示了Tropo.call方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tropo

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def tropo():
    """
        Receive a JSON POST from the Tropo WebAPI

        @see: https://www.tropo.com/docs/webapi/newhowitworks.htm
    """

    # Stored in modules/tropo.py
    from tropo import Tropo, Session

    try:
        s = Session(request.body.read())
        t = Tropo()
        # This is their service contacting us, so parse their request
        try:
            row_id = s.parameters["row_id"]
            # This is an Outbound message which we've requested Tropo to send for us
            table = s3db.msg_tropo_scratch
            query = (table.row_id == row_id)
            row = db(query).select().first()
            # Send the message
            #t.message(say_obj={"say":{"value":row.message}},to=row.recipient,network=row.network)
            t.call(to=row.recipient, network=row.network)
            t.say(row.message)
            # Update status to sent in Outbox
            outbox = s3db.msg_outbox
            db(outbox.id == row.row_id).update(status=2)
            # Set message log to actioned
            log = s3db.msg_log
            db(log.id == row.message_id).update(actioned=True)
            # Clear the Scratchpad
            db(query).delete()
            return t.RenderJson()
        except:
            # This is an Inbound message
            try:
                message = s.initialText
                # This is an SMS/IM
                # Place it in the InBox
                uuid = s.id
                recipient = s.to["id"]
                try:
                    fromaddress = s.fromaddress["id"]
                except:
                    # SyntaxError: s.from => invalid syntax (why!?)
                    fromaddress = ""
                s3db.msg_log.insert(uuid=uuid, fromaddress=fromaddress,
                                    recipient=recipient, message=message,
                                    inbound=True)
                # Send the message to the parser
                reply = msg.parse_message(message)
                t.say([reply])
                return t.RenderJson()
            except:
                # This is a Voice call
                # - we can't handle these yet
                raise HTTP(501)
    except:
        # GET request or some random POST
        pass
开发者ID:mrbtano,项目名称:eden,代码行数:62,代码来源:msg.py

示例2: sms_in

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def sms_in(request):
    """
    Handles tropo messaging requests
    """
    if request.method == "POST":
        data = json.loads(request.body)
        session = data["session"]
        # Handle when Tropo posts to us to send an SMS
        if "parameters" in session:
            params = session["parameters"]
            if ("_send_sms" in params) and ("numberToDial" in params) and ("msg" in params):
                numberToDial = params["numberToDial"]
                msg = params["msg"]
                t = Tropo()
                t.call(to = numberToDial, network = "SMS")
                t.say(msg)
                return HttpResponse(t.RenderJson())
        # Handle incoming SMS
        phone_number = None
        text = None
        if "from" in session:
            phone_number = session["from"]["id"]
        if "initialText" in session:
            text = session["initialText"]
        if phone_number is not None and len(phone_number) > 1:
            if phone_number[0] == "+":
                phone_number = phone_number[1:]
        incoming_sms(phone_number, text, SQLTropoBackend.get_api_id())
        t = Tropo()
        t.hangup()
        return HttpResponse(t.RenderJson())
    else:
        return HttpResponseBadRequest("Bad Request")
开发者ID:philipkaare,项目名称:commcare-hq,代码行数:35,代码来源:views.py

示例3: tropo_view

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def tropo_view(request):
    if request.method == "POST":
        data = json.loads(request.raw_post_data)
        session = data["session"]
        if "parameters" in session:
            params = session["parameters"]
            if ("_send_sms" in params) and ("numberToDial" in params) and ("msg" in params):
                numberToDial = params["numberToDial"]
                msg = params["msg"]
                t = Tropo()
                t.call(to = numberToDial, network = "SMS")
                t.say(msg)
                log("OUT", "TEXT", numberToDial, "TROPO", request.raw_post_data, msg)
                return HttpResponse(t.RenderJson())
        if "from" in session:
            caller_id = session["from"]["id"]
            channel = session["from"]["channel"]
            msg = None
            if "initialText" in session:
                msg = session["initialText"]
            log("IN", channel, caller_id, "TROPO", request.raw_post_data, msg)
            if channel == "VOICE":
                send_sms_tropo(caller_id, "Callback received.")
        t = Tropo()
        t.hangup()
        return HttpResponse(t.RenderJson())
    else:
        return HttpResponseBadRequest()
开发者ID:gcapalbo,项目名称:flashback_test,代码行数:30,代码来源:views.py

示例4: index

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
	
	t = Tropo()
	t.call("+xxx")
	t.record(name = "recording", timeout = 10, maxSilence = 7, maxTime = 60, choices = {"terminator": "#"}, transcription = {"id":"1234", "url":"mailto:[email protected]", "language":"de_DE"}, say = {"value":"Willkommen zur Abfage! Sag uns bitte, wie es dir geht!"}, url = "http://www.example.com/recordings.py", voice =" Katrin")
	
	return t.RenderJson()
开发者ID:esinfaik,项目名称:tropo-webapi-python,代码行数:9,代码来源:record_transcription_language.py

示例5: index

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
    s = Session(request.body)
    t = Tropo()
    t.call(to=' ' + TO_NUMBER, _from=' ' + FROM_NUMBER, label='xiangwyujianghu', voice='Tian-tian', callbackUrl='http://192.168.26.88:8080/FileUpload/receiveJson', promptLogSecurity='suppress')
    t.say('This is your mother. Did you brush your teeth today?')
    json = t.RenderJson() 
    print json
    return json
开发者ID:tropo,项目名称:tropo-webapi-python,代码行数:10,代码来源:gh-14.test_call.py

示例6: index

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):

	t = Tropo()

	t.call(to="+17326820887", network = "SMS")
	t.say("Tag, you're it!")
	
	return t.RenderJson()
开发者ID:choogiesaur,项目名称:internship-stuff-2k15,代码行数:10,代码来源:test.py

示例7: index

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):

    t = Tropo()
    t.call("sip:[email protected]:5678")
    t.say("tropo status")
    t.wait(27222, allowSignals = 'dfghjm')
    t.say("today is Friday 2017-06-02")
    return t.RenderJson()
开发者ID:tropo,项目名称:tropo-webapi-python,代码行数:10,代码来源:wait_test.py

示例8: index

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
    s = Session(request.body)
    t = Tropo()
    t.call(to='tel:+' + TO_NUMBER, _from='tel:+' + FROM_NUMBER)
    t.say('This is your mother. Did you brush your teeth today?')
    json = t.RenderJson()
    print(json)
    return json
开发者ID:buildingspeak,项目名称:tropo-webapi-python,代码行数:10,代码来源:gh-14.test_call.py

示例9: index

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
    #s = Session(request.body)
    t = Tropo()
    t.call(to=' ' + TO_NUMBER, _from=' ' + FROM_NUMBER, label='xiangwyujianghu', network = 'MMS')
    mediaa = ['http://www.gstatic.com/webp/gallery/1.jpg', 'macbook eclipse', 'http://artifacts.voxeolabs.net.s3.amazonaws.com/test/test.png', 1234567890, '0987654321', 'https://www.travelchinaguide.com/images/photogallery/2012/beijing-tiananmen-tower.jpg']
    t.say('This is your mother. Did you brush your teeth today?', media = mediaa)
    json = t.RenderJson() 
    print json
    return json
开发者ID:tropo,项目名称:tropo-webapi-python,代码行数:11,代码来源:gh-14.test_call_MMS.py

示例10: index

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
	t = Tropo()
	t.call(to = "[email protected]", _from = "[email protected]", channel = "TEXT", network = "JABBER")
	t.ask(choices = "yes(yes,y,1), no(no,n,2)", timeout=60, name="reminder", say = "Hey, did you remember to take your pills?")	
	t.on(event = "continue", next ="verify_yes")
	t.on(event = "incomplete", next ="verify_no")
	json = t.RenderJson()
	print json
	return HttpResponse(json)
开发者ID:kwantopia,项目名称:shoppley-migrate,代码行数:11,代码来源:views.py

示例11: index

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
    t = Tropo()

    # s = Session(request.get_json(force=True))
    sys.stderr.write(str(request.body) + "\n")

    s = Session(request.body)
    message = s.initialText
    # print("Initial Text: " + initialText)

    # Check if message contains word "results" and if so send results
    if not message:
        # number = s["session"]["parameters"]["numberToDial"]
        number = s.parameters["numberToDial"]
        reply = "Would you like to vote?"
        t.call(to=number, network="SMS")
        # t.say(reply)

    elif message.lower().find("results") > -1:
        results = get_results()
        reply = ["The current standings are"]
        for i, result in enumerate(results):
            if i == 0:
                reply.append("  *** %s is in the lead with %s percent of the votes.\n" % (result[0], str(round(result[2]))))
            elif i <= 3:
                reply.append("  -   %s has %s percent of the votes.\n" % (result[0], str(round(result[2]))))
    # Check if message contains word "options" and if so send options
    elif message.lower().find("options") > -1:
        options = get_options()
        reply = ["The options are..."]
        msg = ""
        for option in options:
            msg += "%s, " % (option)
        msg = msg[:-2] + ""
        reply.append(msg)
    # Check if message contains word "vote" and if so start a voting session
    elif message.lower().find("vote") > -1:
        # reply = "Let's vote!  Look for a new message from me so you can place a secure vote!"
        reply = [process_incoming_message(message)]
    # If nothing matches, send instructions
    else:
        # Reply back to message
        # reply = "Hello, welcome to the MyHero Demo Room.\n" \
        #         "To find out current status of voting, ask 'What are the results?'\n" \
        #         "To find out the possible options, ask 'What are the options?\n" \
        #         '''To place a vote, simply type the name of your favorite Super Hero and the word "vote".'''
        reply = ["Hello, welcome to the MyHero Demo Room." ,
                "To find out current status of voting, ask 'What are the results?'",
                "To find out the possible options, ask 'What are the options?",
                '''To place a vote, simply type the name of your favorite Super Hero and the word "vote".''']

    # t.say(["Really, it's that easy." + message])
    t.say(reply)
    response = t.RenderJson()
    sys.stderr.write(response + "\n")
    return response
开发者ID:hpreston,项目名称:myhero_tropo,代码行数:58,代码来源:myhero_tropo.py

示例12: index

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
    t = Tropo()
    t.call("sip:[email protected]:5678", say = "ha ha ha ha ha ah ah ah ah")
    t.say("a b c d e f g h i j k")
    on = On("connect", say = "emily", next = "http://freewavesamples.com/files/Kawai-K5000W-AddSquare-C4.wav", post = "http://192.168.26.88:8080/FileUpload/receiveJson").json
    t.transfer(TO_NUMBER, _from= FROM_NUMBER, on=on, callbackUrl="http://192.168.26.88:8080/FileUpload/receiveJson", label="erthnbvc")
    t.say("Hi. I am a robot q a z w s x e d c")
    json = t.RenderJson()
    print json
    return json
开发者ID:tropo,项目名称:tropo-webapi-python,代码行数:12,代码来源:tropo_11270_transferTest.py

示例13: index

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):

  t = Tropo()

  mc = MachineDetection(introduction="This is a test. Please hold while I determine if you are a Machine or Human. Processing. Finished. THank you for your patience.", voice="Victor").json
  t.call(to="+14071234321", machineDetection=mc)
  
  t.on(event="continue", next="/continue.json")

  return t.RenderJson()
开发者ID:DJF3,项目名称:tropo-webapi-python,代码行数:12,代码来源:tropoTestMachineDetection.py

示例14: index

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
    t = Tropo()
    t.call("sip:[email protected]:5678", say = "ha ha ha ha ha ah ah ah ah")
    t.say("ah ah ah ah ah uh uh uh uh ha ha ha")
    on1 = On("connect", ask = Ask(Choices("[5 DIGITS]")).json).json
    on2 = On("ring", say = "emily2").json
    t.transfer(TO_NUMBER, _from= FROM_NUMBER, on=[on1,on2], choices = TransferOnChoices(terminator = '#').json)
    t.say("Hi. I am a robot")
    json = t.RenderJson()
    print json
    return json
开发者ID:tropo,项目名称:tropo-webapi-python,代码行数:13,代码来源:tropo_11258_transferOnTest.py

示例15: index

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
    session = Session(request.body)
    t = Tropo()
    #jj = JoinPrompt(value = "who are you who let you come in")
    jj = JoinPrompt("who are you who let you come in")
    #ll = LeavePrompt(value = "byebye samsung")
    ll = LeavePrompt("byebye samsung")
    t.call(to=session.parameters['callToNumber'], network='SIP')
    t.conference(id='yuxiangj', joinPrompt=jj.json, leavePrompt=ll.json)
    t.say(session.parameters['message'])
    return t.RenderJsonSDK()
开发者ID:tropo,项目名称:tropo-webapi-python,代码行数:13,代码来源:gh-25.conference.py


注:本文中的tropo.Tropo.call方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。