DEBUG MODE ..OFF?

This commit is contained in:
Hamcha 2016-02-20 21:57:04 +01:00
parent 7501afc81d
commit 23b847b94a
2 changed files with 10 additions and 4 deletions

View file

@ -88,16 +88,21 @@ func (t Telegram) GetFile(data tg.FileRequestData, client net.Conn, callback int
}
defer resp.Body.Close()
var filespecs tg.APIFile
var filespecs = struct {
Ok bool `json:"ok"`
Result *tg.APIFile `json:"result,omitempty"`
}{}
err = json.NewDecoder(resp.Body).Decode(&filespecs)
if checkerr("GetFile/json.Decode", err) {
fail("Server sent garbage (or error)")
return
}
if filespecs.Result == nil {
fail("Server didn't send a file info, does the file exist?")
return
}
fmt.Println(filespecs)
path := "https://api.telegram.org/file/bot" + t.Token + "/" + *(filespecs.Path)
path := APIEndpoint + "file/bot" + t.Token + "/" + *(*(filespecs.Result).Path)
fileresp, err := http.Get(path)
if checkerr("GetFile/get", err) {
fail("Could not retrieve file from Telegram's servers")

View file

@ -56,6 +56,7 @@ func memegen(broker *tg.Broker, update tg.APIMessage) {
photo = curphoto
}
}
broker.GetFile(photo.FileID, func(broker *tg.Broker, data tg.BrokerUpdate) {
pbytes, err := base64.StdEncoding.DecodeString(*data.Bytes)
if err != nil {