From ab017b8584225ddeb27082e65d65a76a21af0a7f Mon Sep 17 00:00:00 2001 From: Hamcha Date: Sat, 20 Feb 2016 23:18:25 +0100 Subject: [PATCH] DEBUG MODE OFF --- broker/telegram.go | 5 +---- mods/memegen.go | 11 ++++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/broker/telegram.go b/broker/telegram.go index 76cf437..bc544bf 100644 --- a/broker/telegram.go +++ b/broker/telegram.go @@ -106,11 +106,8 @@ func (t Telegram) SendPhoto(data tg.ClientPhotoData) { req.Header.Add("Content-Type", writer.FormDataContentType()) - resp, err := client.Do(req) + _, err = client.Do(req) checkerr("SendPhoto/http.Do", err) - defer resp.Body.Close() - respbytes, _ := ioutil.ReadAll(resp.Body) - fmt.Println(string(respbytes)) } // GetFile sends a "getFile" API call to Telegram's servers and fetches the file diff --git a/mods/memegen.go b/mods/memegen.go index dab843c..740c0d3 100644 --- a/mods/memegen.go +++ b/mods/memegen.go @@ -98,7 +98,7 @@ func memegen(broker *tg.Broker, update tg.APIMessage) { gc.Save() // Detect appropriate font size - scale := iwidth / iheight * 200 + scale := iheight / iwidth * (iwidth / 10) gc.SetFontSize(scale) gc.SetLineWidth(scale / 15) @@ -127,15 +127,16 @@ func memegen(broker *tg.Broker, update tg.APIMessage) { // Still too big? Decrease font size again iter := 0 for width > iwidth && iter < 10 { - left, _, right, _ = gc.GetStringBounds(texts[longid]) - gc.SetFontSize(scale * 0.8) + log.Println("Warning, resizing!") + left, top, right, bottom = gc.GetStringBounds(texts[longid]) + gc.SetFontSize(scale * (0.8 - 0.1*float64(iter))) width = right - left iter++ } } height := bottom - top - margin := float64(10) + margin := float64(height / 50) lines := float64(len(texts) - 1) gc.Save() @@ -146,7 +147,7 @@ func memegen(broker *tg.Broker, update tg.APIMessage) { y := float64(0) if istop { - y = (height-margin)*float64(id+1) + margin*5 + y = (height+margin)*float64(id+1) + margin*5 } else { y = iheight - (height * lines) + (height * float64(id)) - margin*5 }