This commit is contained in:
potassium 2024-12-27 00:31:19 +03:00
parent ddc2c6640f
commit 0912afa68a

View File

@ -98,13 +98,7 @@ func GetImage(link string) (image.Image, error) {
} }
defer resp.Body.Close() defer resp.Body.Close()
if resp == nil {
log.Fatal("pizdec")
}
img, _, err := image.Decode(resp.Body) img, _, err := image.Decode(resp.Body)
if img == nil {
log.Fatal("img is nil")
}
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -115,7 +109,7 @@ func HandleCommand(update tg.Update, bot *tg.BotAPI) {
maxCost := 5 maxCost := 5
var err error var err error
for i := 0; i <= maxCost; i++ { for i := 0; i <= maxCost; i++ {
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
var img = imageutils.Concat( var img = imageutils.Concat(
Must(GetImage(fmt.Sprintf(LinkFormat, Must(GetImage(fmt.Sprintf(LinkFormat,
takeOne(ShuffledCardPool)))), takeOne(ShuffledCardPool)))),
@ -123,14 +117,7 @@ buf := new(bytes.Buffer)
takeOne(ShuffledCardPool)))), takeOne(ShuffledCardPool)))),
imageutils.Right, imageutils.Right,
) )
if img == nil { err = png.Encode(buf, img)
log.Fatal("pizdec")
}
err = png.Encode(
buf,
img,
)
if err != nil { if err != nil {
log.Println("error on decode:", err) log.Println("error on decode:", err)
} }