本文整理汇总了Python中twilio.twiml.Response.say方法的典型用法代码示例。如果您正苦于以下问题:Python Response.say方法的具体用法?Python Response.say怎么用?Python Response.say使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twilio.twiml.Response
的用法示例。
在下文中一共展示了Response.say方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import say [as 别名]
def get(self, request, client_call, pks):
pks = pks.split(",")
try:
shelter = Shelter.objects.get(pk=pks[0])
except Shelter.DoesNotExist:
pks = ",".join(pks[1:])
if pks:
return redirect(reverse("phone:start_shelter_call", kwargs={"pks": pks, "client_call": client_call}))
site = Site.objects.get_current()
client.calls.create(
to=shelter.phone_number,
from_=settings.TWILIO_CALLER_ID,
url=urljoin(
"http://" + site.domain,
reverse("phone:verify_shelter_availability", kwargs={"client_call": client_call, "pk": pks[0]}),
),
method="GET",
status_callback="http://%s/phone/shelter_call_callback/%s/%s/"
% (site.domain, client_call, ",".join(pks[1:])),
status_method="GET",
)
r = Response()
r.say("We are contacting %s. Please hold." % shelter.name)
r.enqueue(name="waiting_for_shelter", wait_url="http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient")
return r
示例2: handle_connect
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import say [as 别名]
def handle_connect(request):
recipient_number = request.POST.get('Digits', '')
r = Response()
if 'visitor' in request.session:
try:
recipient = Visitor.objects.get(access_code=recipient_number)
request.session['recipient'] = {
'id': recipient.id,
'name': recipient.user.first_name,
'number': recipient.access_code
}
# record a message
r.say(
'The person you tried to call is unavailable. Please leave a message')
r.record(maxLength=30, action=reverse(
'twiliorouter:handle_record')
)
except Visitor.DoesNotExist:
request.session['welcome_message'] = 'Number not recognised'
r.redirect(reverse('twiliorouter:connect'))
else:
request.session[
'welcome_message'] = 'You need to enter your phone number'
r.redirect(reverse('twiliorouter:welcome'))
return r
示例3: handle_selection
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import say [as 别名]
def handle_selection(request, slug):
voicemailbox = get_object_or_404(VoicemailBox, slug=slug)
chunk = voicemailbox.work.chunk_set.filter(number=request.POST.get('Digits'))
if chunk.chunksubmission:
r = Response()
r.say(
"Thank you. "
"Please start reading, "
"when you are done, you can hang up. "
)
action = reverse('handle-recording', kwargs={'slug': slug})
r.record(action=action, timeout=20, maxLength=360, playBeep=True)
@csrf_exempt
def handle_recording(request, slug=None):
voicemailbox = get_object_or_404(VoicemailBox, slug=slug)
voicemailbox.collection.add_voicemail(
audio_url=request.POST.get('RecordingUrl'),
title='recorded in %s for %s' % (location, voicemailbox.target_location),
location=voicemailbox.target_location,
)
return HttpResponse()
示例4: handle_response_digits
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import say [as 别名]
def handle_response_digits(request):
twilio_request = decompose(request)
digits = twilio_request.digits
twilio_response = Response()
if digits == '2':
# twilio_response.play('http://bit.ly/phaltsw')
number = request.POST.get('From', '')
twilio_response.say('A text message is on its way. Daaaaaaaaaaaaaaamn Daniel! Peace out yo')
twilio_response.sms('Daaaaaaaaaaaaaaamn Daniel!', to=number)
elif digits == '1':
# twilio_response.play('http://bit.ly/phaltsw')
# twilio_response.play('https://p.scdn.co/mp3-preview/934da7155ec15deb326635d69d050543ecbee2b4')
# twilio_response.play('https://p.scdn.co/mp3-preview/934da7155ec15deb326635d69d050543ecbee2b4')
twilio_response.play('https://demo.twilio.com/hellomonkey/monkey.mp3')
# number = request.POST.get('From', '')
# twilio_response.say('I got you bruh, sending you a text in a bit. PEACE!')
# twilio_response.sms('You looking lovely today!', to=number)
elif digits == "3":
twilio_response.say("Record your monkey howl after the tone.")
twilio_response.record(maxLength="5", action="/handle_recording")
# If the caller pressed invalid input
else:
# twilio_response.say('Incorrect Number Pressed')
return redirect("/gather")
return twilio_response
示例5: do_simplehelp
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import say [as 别名]
def do_simplehelp():
data = parse_form(request.form)
url = "{}/handle?{}".format(request.base_url, urlencode(data, True))
r = Response()
r.say('System is down for maintenance')
fallback_url = echo_twimlet(r.toxml())
try:
client = twilio()
client.phone_numbers.update(
request.form['twilio_number'],
friendly_name='[RRKit] Simple Help Line',
voice_url=url,
voice_method='GET',
voice_fallback_url=fallback_url,
voice_fallback_method='GET'
)
flash('Help menu configured', 'success')
except Exception as e:
print(e)
flash('Error configuring help menu', 'danger')
return redirect('/simplehelp')
示例6: handle_replay_message
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import say [as 别名]
def handle_replay_message(request):
digits = request.GET['digits']
msg = get_fizzbuzz_message(int(digits))
twilio_response = Response()
twilio_response.say(msg)
return twilio_response
示例7: do_ringdown
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import say [as 别名]
def do_ringdown():
numbers = parse_numbers(request.form.get('numbers', ''))
data = {
'stack': numbers,
'sorry': request.form.get('sorry', '')
}
url = "{}/handle?{}".format(request.base_url, urlencode(data, True))
r = Response()
r.say('System is down for maintenance')
fallback_url = echo_twimlet(r.toxml())
try:
client = twilio()
client.phone_numbers.update(request.form['twilio_number'],
friendly_name='[RRKit] Ringdown',
voice_url=url,
voice_method='GET',
voice_fallback_url=fallback_url,
voice_fallback_method='GET')
flash('Number configured', 'success')
except Exception:
flash('Error configuring number', 'danger')
return redirect('/ringdown')
示例8: gather
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import say [as 别名]
def gather(request):
logger.debug("Calling gather")
d = request.GET.get("Digits")
logger.debug("Digit Pressed= %s" % d)
try:
r = Response()
if d == "1":
r.say("You pressed 1")
try:
api = twitter.Api()
statuses = api.GetUserTimeline("diarmuid")
r.say(statuses[0].text)
except Exception, ex:
logger.debug(ex)
r.say("Error getting twitter results")
r.redirect(reverse("calls_hello"))
return r
elif d == "2":
r.say("You pressed 2")
r.say("Record your message after the tone.")
r.record(maxLength="10", action=reverse("calls_record"))
return r
示例9: handle_ringdown
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import say [as 别名]
def handle_ringdown():
stack = request.args.getlist('stack')
sorry = request.args.get('sorry', 'Sorry, no one answered')
if len(stack) == 0:
# Nothing else to ringdown
resp = Response()
resp.say(sorry)
return str(resp)
top = stack.pop(0)
data = {
'stack': stack,
'sorry': sorry
}
qs = urlencode(data, True)
resp = Response()
resp.dial(top, timeout=10, action="/ringdown/handle?{}".format(qs),
method='GET')
return str(resp)
示例10: echo
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import say [as 别名]
def echo(request):
response = Response()
if request.method == 'POST':
response.play(request.POST['RecordingUrl'])
else:
response.say("Echo test", voice='woman')
response.record()
return response
示例11: answer
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import say [as 别名]
def answer(request, slug=None):
r = Response()
r.say("Thank you for contributing to the invisible library.")
make_selection(r)
return r
示例12: handle_call
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import say [as 别名]
def handle_call(request):
r = Response()
if request.GET['key'] == settings.TWILIO_KEY:
kwargs = {'text':settings.GREETINGS, 'voice':None, 'language':None, 'loop':None}
r.say(**kwargs)
kwargs = {'action':settings.BASE_URL+'call_reference/?key='+request.GET['key'], 'method':'POST', 'timeout':settings.TWILIO_TIMEOUT, 'finish_on_key':settings.TWILIO_FINISHKEY}
r.gather(**kwargs)
return r
示例13: call_reference
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import say [as 别名]
def call_reference(request):
r = Response()
if request.GET['key'] == settings.TWILIO_KEY:
kwargs = {'number':'+447513623450', 'action':None, 'method':None, 'timeout':settings.TWILIO_TIMEOUT, 'hangupOnStar':False,'timeLimit':None, 'callerId':None,'record':True}
r.dial(**kwargs)
kwargs = {'text':settings.ENDCALL, 'voice':None, 'language':None, 'loop':None}
r.say(**kwargs)
return r
示例14: twilio_call_transfer_ended
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import say [as 别名]
def twilio_call_transfer_ended(request, calllog_id):
call_log = get_object_or_404(CallLog, id=int(calllog_id))
call_log.status = "connection-ended"
call_log.log["finished"] = dict(request.POST)
call_log.log["finished"]["_request"] = get_request_log_info(request)
call_log.save()
resp = TwilioResponse()
resp.say("Your call to Congress has ended. Thank you for being a good citizen. Goodbye.")
return resp
示例15: twilio_call_transfer_end
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import say [as 别名]
def twilio_call_transfer_end(request, call_id):
report = get_object_or_404(WhipReport, id=int(call_id))
report.call_status = "connection-ended"
report.call_log["finished"] = dict(request.POST)
report.call_log["finished"]["_request"] = get_request_log_info(request)
report.save()
resp = TwilioResponse()
resp.say("Your call to Congress has ended. Thank you for being a great citizen. Goodbye.")
return resp