func setWebhookHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") bot, err := botApi.NewBotAPIWithClient(TOKEN, urlfetch.Client(appengine.NewContext(r))) resp, err := bot.SetWebhook(botApi.NewWebhook(r.URL.Query().Get("url"))) str, err := json.Marshal(resp) checkErr(w, err) fmt.Fprint(w, string(str)) }
//----------------------------------------------Handlers func meHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") bot, err := botApi.NewBotAPIWithClient(TOKEN, urlfetch.Client(appengine.NewContext(r))) user, err := bot.GetMe() resp, err := json.Marshal(user) checkErr(w, err) fmt.Fprint(w, string(resp)) }
func updateHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") bot, err := botApi.NewBotAPIWithClient(TOKEN, urlfetch.Client(appengine.NewContext(r))) num, err := strconv.Atoi(r.URL.Query().Get("offset")) updates, err := bot.GetUpdates(botApi.NewUpdate(num)) resp, err := json.Marshal(updates) checkErr(w, err) fmt.Fprint(w, string(resp)) }