From 510482278688d77a599d42b2d3c33838e9d74749 Mon Sep 17 00:00:00 2001 From: nu50218 Date: Sat, 1 Jun 2019 01:50:40 +0900 Subject: [PATCH] todo --- pattern/tags.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pattern/tags.go b/pattern/tags.go index 36f0d23..732f40b 100644 --- a/pattern/tags.go +++ b/pattern/tags.go @@ -161,9 +161,16 @@ func ConvertTags(message, targetName string, emojiNumber int) string { // combineMultiplePatterns: 複数のパターンをnumber分ランダムにつなげる func combineMultiplePatterns(patterns []string, number int) string { result := "" - // TODO: 同じパターンは使い回さないようにしたほうが自然か? - for i := 0; i < number; i++ { - result += patterns[rand.Intn(len(patterns))] + if number <= len(patterns) { + for i := 0; i < number; i++ { + index := rand.Intn(len(patterns) - i) + result += patterns[index] + patterns[index], patterns[len(patterns)-1-i] = patterns[len(patterns)-1-i], patterns[index] + } + } else { + for i := 0; i < number; i++ { + result += patterns[rand.Intn(len(patterns))] + } } return result }