本文整理汇总了Python中tropo.Tropo类的典型用法代码示例。如果您正苦于以下问题:Python Tropo类的具体用法?Python Tropo怎么用?Python Tropo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tropo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
def index(request):
s = Session(request.body)
t = Tropo()
t.say('12345', _as='DIGITS', voice='dave')
json = t.RenderJson()
print(json)
return json
示例2: do_confirm_ok
def do_confirm_ok(self, candidate_id):
caller_id = models.caller_id_if_valid(self.call_id())
models.record_vote(caller_id, candidate_id)
t = Tropo()
t.say("Great, your vote has been counted. Goodbye.")
t.message("Thanks for voting! Tropo <3 you!", channel="TEXT", to=caller_id)
return t.RenderJson()
示例3: post
def post(self, request):
t = Tropo()
r = Result(request.body)
log.debug('PlayCode got: %s', request.body.__repr__())
session = m.Session.objects.get(identifier=r._sessionId)
player = session.player
if r._state == 'DISCONNECTED':
log.info('player %s disconnected', session.player)
return HttpResponse(t.RenderJson())
# see if there's a user-entered code
try:
code = r.getValue()
except KeyError:
t.say("Please try again.")
code = None
# if there's a code, try changing the station
if code:
try:
song = m.SongStation.objects.get(select_code=code)
player.completed_stations.add(song)
player.current_station = song
player.save()
except ObjectDoesNotExist:
t.say("Sorry, %s is invalid" % code)
prompt_player(t, player)
tropo_response = t.RenderJson()
log.debug('PlayCode returning %s', tropo_response)
return HttpResponse(tropo_response)
示例4: index
def index(request):
r = Result(request.body)
print "request.body : %s" % request.body
t = Tropo()
answer = r.getInterpretation()
value = r.getValue()
t.say("You said " + answer + ", which is a " + value)
actions_options_array = ['name', 'attempts', 'disposition', 'confidence', 'interpretation', 'utterance', 'value', 'concept', 'xml', 'uploadStatus']
actions = r.getActions()
if (type (actions) is list):
for item in actions:
for opt in actions_options_array:
print 'action object filed %(actionfieldname)s\'s value is %(vaalue)s' % {'actionfieldname':opt, "vaalue":item.get(opt,'NoValue')}
print '------------------------------'
else:
dict = actions
for opt in actions_options_array:
print 'action object filed %(actionfieldname)s\'s value is %(vaalue)s' % {'actionfieldname':opt, "vaalue":dict.get(opt,'NoValue')}
json = t.RenderJson()
print json
return json
示例5: do_confirm_ok
def do_confirm_ok(self, song_id):
caller_id = models.votes.caller_id_if_valid(self.call_id())
models.votes.vote_for_song(song_id, caller_id)
t = Tropo()
t.say("Great, your vote has been counted. Goodbye.")
t.message("Thanks for voting!", channel="TEXT", to=caller_id)
return t.RenderJson()
示例6: index
def index(request):
t = Tropo()
t.answer(headers={"P-Header":"value goes here","Remote-Party-ID":"\"John Doe\"<sip:[email protected]>;party=calling;id-type=subscriber;privacy=full;screen=yes"})
t.say('This is your mother. Did you brush your teeth today?')
json = t.RenderJson()
print json
return json
示例7: setup_tropo
def setup_tropo():
tropo_core = Tropo()
tropo_core.on(event='hangup', next=url_for('handle_hangup'))
tropo_core.on(event='error', next=url_for('handle_error'))
return tropo_core
示例8: ivr_in
def ivr_in(request):
"""
Handles tropo call requests
"""
if request.method == "POST":
data = json.loads(request.body)
phone_number = data["session"]["from"]["id"]
# TODO: Implement tropo as an ivr backend. In the meantime, just log the call.
if phone_number:
cleaned_number = strip_plus(phone_number)
v = VerifiedNumber.by_extensive_search(cleaned_number)
else:
v = None
# Save the call entry
msg = CallLog(
phone_number=cleaned_number,
direction=INCOMING,
date=datetime.utcnow(),
backend_api=SQLTropoBackend.get_api_id(),
)
if v is not None:
msg.domain = v.domain
msg.couch_recipient_doc_type = v.owner_doc_type
msg.couch_recipient = v.owner_id
msg.save()
t = Tropo()
t.reject()
return HttpResponse(t.RenderJson())
else:
return HttpResponseBadRequest("Bad Request")
示例9: verify_no
def verify_no(request):
t = Tropo()
t.say("Sorry, that wasn't on of the options.")
json = t.RenderJson()
print json
return HttpResponse(json)
示例10: index
def index(request):
currenttime = datetime.datetime.now()
t = Tropo()
sayobjOutbound = "Now is " + str(currenttime)
t.message(sayobjOutbound, to="+1 725-419-2113", network="SMS")
print t.RenderJson()
return t.RenderJson()
示例11: index
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()
示例12: index
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
示例13: index
def index(request):
t = Tropo()
VOICE = 'Grace'
t.record(name='voicemail.mp3', say='Your call is important. Please leave a short message after the tone: ', url = 'http://www.example.com', beep = True, format = 'audio/mp3', voice = VOICE)
return t.RenderJson()
示例14: index
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
示例15: index
def index(request):
t = Tropo()
t.call(to="+17326820887", network = "SMS")
t.say("Tag, you're it!")
return t.RenderJson()