and finally it all works as intended

This commit is contained in:
potassium 2024-12-27 18:43:19 +03:00
parent 73afcc1861
commit 93fe4fd479

View File

@ -10,6 +10,7 @@ import (
"math/rand" "math/rand"
"net/http" "net/http"
"time" "time"
"slices"
"git.niplace.ru/XoxJlopeZi4BB/imageutils" "git.niplace.ru/XoxJlopeZi4BB/imageutils"
"git.niplace.ru/XoxJlopeZi4BB/paxpamir/token" "git.niplace.ru/XoxJlopeZi4BB/paxpamir/token"
@ -31,10 +32,10 @@ func shuffle[S ~[]E, E any](a S) {
} }
} }
func takeOne[S ~[]T, T any](s S) T { func takeOne[S ~[]T, T any](s *S) T {
v := s[0] var new = slices.Clone(*s)
s = s[2:] v := new[0]
fmt.Println(s) *s = new[1:]
return v return v
} }
@ -113,9 +114,9 @@ func HandleCommand(update tg.Update, bot *tg.BotAPI) {
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)))),
Must(GetImage(fmt.Sprintf(LinkFormat, Must(GetImage(fmt.Sprintf(LinkFormat,
takeOne(ShuffledCardPool)))), takeOne(&ShuffledCardPool)))),
imageutils.Right, imageutils.Right,
) )
err = png.Encode(buf, img) err = png.Encode(buf, img)