예제 #1
0
 def testAddConference(self):
     """ add a conference to a dial """
     r = Response()
     d = twiml.Dial()
     d.append(twiml.Conference("My Room"))
     r.append(d)
     r = self.strip(r)
     assert_equal(r, '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Conference>My Room</Conference></Dial></Response>')
예제 #2
0
 def testAddAttribute(self):
     """add attribute"""
     r = twiml.Conference("MyRoom", foo="bar")
     r = self.strip(r)
     self.assertEquals(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Conference foo="bar">MyRoom</Conference>'
     )
예제 #3
0
 def testImproperNesting(self):
     """ bad nesting """
     verb = twiml.Gather()
     self.assertRaises(TwimlException, verb.append, twiml.Gather())
     self.assertRaises(TwimlException, verb.append, twiml.Record())
     self.assertRaises(TwimlException, verb.append, twiml.Hangup())
     self.assertRaises(TwimlException, verb.append, twiml.Redirect())
     self.assertRaises(TwimlException, verb.append, twiml.Dial())
     self.assertRaises(TwimlException, verb.append, twiml.Conference(""))
     self.assertRaises(TwimlException, verb.append, twiml.Sms(""))
예제 #4
0
 def improperAppend(self, verb):
     self.assertRaises(TwimlException, verb.append, twiml.Say(""))
     self.assertRaises(TwimlException, verb.append, twiml.Gather())
     self.assertRaises(TwimlException, verb.append, twiml.Play(""))
     self.assertRaises(TwimlException, verb.append, twiml.Record())
     self.assertRaises(TwimlException, verb.append, twiml.Hangup())
     self.assertRaises(TwimlException, verb.append, twiml.Reject())
     self.assertRaises(TwimlException, verb.append, twiml.Redirect())
     self.assertRaises(TwimlException, verb.append, twiml.Dial())
     self.assertRaises(TwimlException, verb.append, twiml.Conference(""))
     self.assertRaises(TwimlException, verb.append, twiml.Sms(""))
     self.assertRaises(TwimlException, verb.append, twiml.Pause())
예제 #5
0
def join(conference_uuid):
    """
    TwiML Endpoint for for Twilio join callbacks

    Has two modes depending on the value of POST variable 'Digits':
      - != 1: Ask the caller to press 1 to join the bridge
      - == 1: Join the caller to the conference bridge

    """
    if validate_twiml() == False:
        abort(403, 'Validation failed')
    log.debug("received join on {}".format(conference_uuid))
    conference = Conference(uuid=conference_uuid)
    conference_name = conference.get_name()
    log.debug(
        "using conference_uuid {}, determined conference_name is: {}".format(
            conference_uuid, conference_name))
    call_sid = request.forms.get('CallSid')
    log.debug("caller has call_sid: {}".format(call_sid))
    phone_number = request.forms.get('To')
    log.debug("caller has phone_number: {}".format(phone_number))
    r = twiml.Response()
    digits = request.forms.get('Digits')
    if digits:
        log.debug("caller has entered digits: {}".format(digits))
    if digits == '1':
        log.debug("caller has pressed one to join")
        conference.add(call_sid, phone_number)
        r.say("Now joining you to the conference bridge named, {}".format(
            conference_name))
        d = twiml.Dial()
        d.append(twiml.Conference(conference_uuid))
        r.append(d)
        log.info("caller is now entering conference_uuid: {}".format(
            conference_uuid))
        return str(r)
    else:
        log.info("caller will be prompted to join")
        with r.gather(timeout=10, numDigits=1) as g:
            g.say(
                "You have been requested to join the conference bridge named, {}"
                .format(conference_name))
            g.say("To accept, please press one")
        r.redirect('{}/twiml/join/{}'.format(
            application.config.Twiml.callback_base_url, conference_uuid),
                   method='POST')
        log.debug("sending join prompt now")
        log.debug("sending twiml: {}".format(str(r)))
        return str(r)
예제 #6
0
 def joinroom(self, var=None, **params):
     room = str(urllib.unquote(cherrypy.request.params['room']))
     user = str(urllib.unquote(cherrypy.request.params['user']))
     if room == "welcome-test" and user == "guest-test":
         r = twiml.Response()
         r.say(
             "Please record a short message after the tone, it will then be played back to you"
         )
         r.record(action="http://voxirc.sammachin.com/twiliotest/recorded",
                  maxLength="6")
     else:
         print user + " entered " + room
         leaveurl = "http://ec2.sammachin.com/pusher2talk/leaveroom?room={0}&user={1}".format(
             room, user)
         c = twiml.Conference(room, waitUrl="", beep="false")
         r = twiml.Response()
         d = twiml.Dial(action=leaveurl)
         d.append(c)
         r.append(d)
         p = pusher.Pusher()
         p["presence-" + room].trigger('join', {'user': user})
         adduser(room, user)
     return str(r)
예제 #7
0
 def testBadAppend(self):
     """ should raise exceptions for wrong appending """
     self.improperAppend(twiml.Conference("Hello"))