소스 검색

Add new syntax for giving votes

Toni Fadjukoff 5 년 전
부모
커밋
fb7c68b763
2개의 변경된 파일5개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 1
      bot.go
  2. 4 1
      bot_test.go

+ 1 - 1
bot.go 파일 보기

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 파일 보기

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()