From 93fe4fd479ded2ba320e5b2fc9da940bb306aa4d Mon Sep 17 00:00:00 2001 From: potassium Date: Fri, 27 Dec 2024 18:43:19 +0300 Subject: [PATCH] and finally it all works as intended --- market.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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)