示例#1
0
func Repeat(tw twilio.Context) {
	req := tw.Request()
	c := appengine.NewContext(req)
	parts := strings.Split(req.URL.Path, "/")
	from := parts[len(parts)-1]
	var lf LastFortune
	if err := datastore.Get(c, datastore.NewKey(c, "LastFortune", from, 0, nil), &lf); err != nil {
		c.Errorf("error getting last fortune for %q: %v", from, err)
		return
	}
	c.Debugf("LastFortune(%q): %v", from, lf)
	tw.Response(string(lf.Twiml))
}
示例#2
0
func (ft Fortwilio) Handle(tw twilio.Context) {
	c := appengine.NewContext(tw.Request())
	twiml := ft.Say()
	c.Debugf(twiml)
	tw.Response(twiml)
	lf := &LastFortune{
		tw.Value("To"),
		[]byte(twiml),
	}
	if _, err := datastore.Put(c, datastore.NewKey(c, "LastFortune", tw.Value("From"), 0, nil), lf); err != nil {
		c.Errorf("error recording last fortune for %q: %v", tw.Value("From"), err)
		return
	}
}