Fix compilation error and comment out some code for testing
This commit is contained in:
parent
f3186708ef
commit
a4bdd6c71f
2 changed files with 22 additions and 12 deletions
|
@ -2,9 +2,12 @@ package main
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"../tg"
|
||||
)
|
||||
|
||||
const APIEndpoint = "https://api.telegram.org/"
|
||||
|
@ -29,6 +32,12 @@ func (t Telegram) setWebhook(webhook string) {
|
|||
log.Println("Could not read reply: " + err.Error())
|
||||
return
|
||||
}
|
||||
if result.Ok {
|
||||
log.Println("Webhook successfully set!")
|
||||
} else {
|
||||
log.Printf("Error setting webhook (errcode %d): %s\n", *(result.ErrCode), *(result.Description))
|
||||
panic(errors.New("Cannot set webhook"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"../tg"
|
||||
"os"
|
||||
)
|
||||
|
||||
func webhook(rw http.ResponseWriter, req *http.Request) {
|
||||
log.Println("Received request! Details follow:")
|
||||
defer req.Body.Close()
|
||||
|
||||
/*
|
||||
var update tg.APIUpdate
|
||||
|
||||
err := json.NewDecoder(req.Body).Decode(&update)
|
||||
|
@ -22,4 +21,6 @@ func webhook(rw http.ResponseWriter, req *http.Request) {
|
|||
|
||||
jenc, _ := json.Marshal(update)
|
||||
log.Println(jenc)
|
||||
*/
|
||||
io.Copy(os.Stdout, req.Body)
|
||||
}
|
||||
|
|
Reference in a new issue