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