Browse Source

Add new syntax for giving votes

Toni Fadjukoff 6 years ago
parent
commit
fb7c68b763
2 changed files with 5 additions and 2 deletions
  1. 1 1
      bot.go
  2. 4 1
      bot_test.go

+ 1 - 1
bot.go View File

167
 	if stars.MatchString(score) {
167
 	if stars.MatchString(score) {
168
 		return fmt.Sprintf("%d", len(score))
168
 		return fmt.Sprintf("%d", len(score))
169
 	}
169
 	}
170
-	imageStars, _ := regexp.Compile("^(\\[\\[Image:[01]\\.png\\]\\]){5}$")
170
+	imageStars, _ := regexp.Compile("^(\\[\\[Image:[01]\\.png\\]\\]){1,5}$")
171
 	if imageStars.MatchString(score) {
171
 	if imageStars.MatchString(score) {
172
 		return fmt.Sprintf("%d", strings.Count(score, "1"))
172
 		return fmt.Sprintf("%d", strings.Count(score, "1"))
173
 	}
173
 	}

+ 4 - 1
bot_test.go View File

7
 	if s != "3" {
7
 	if s != "3" {
8
 		t.Fail()
8
 		t.Fail()
9
 	}
9
 	}
10
-
10
+	s = parseScore("[[Image:1.png]][[Image:1.png]]")
11
+	if s != "2" {
12
+		t.Fail()
13
+	}
11
 	s = parseScore("{{Rating|3|5}}")
14
 	s = parseScore("{{Rating|3|5}}")
12
 	if s != "3" {
15
 	if s != "3" {
13
 		t.Fail()
16
 		t.Fail()