Compare commits
2 Commits
58b1eabadf
...
ca2ccc569d
Author | SHA1 | Date |
---|---|---|
ekzyis | ca2ccc569d | |
ekzyis | 0a877f9f27 |
|
@ -1,3 +1,3 @@
|
|||
SN_BASE_URL=
|
||||
SN_API_TOKEN=
|
||||
SN_API_KEY=
|
||||
SN_MEDIA_URL=
|
||||
|
|
14
main.go
14
main.go
|
@ -263,11 +263,12 @@ func parseGameStart(input string) (string, error) {
|
|||
for _, line := range strings.Split(input, "\n") {
|
||||
line = strings.Trim(line, " ")
|
||||
|
||||
if !strings.HasPrefix(line, "@chess") {
|
||||
var found bool
|
||||
if line, found = strings.CutPrefix(line, "@chess"); !found {
|
||||
continue
|
||||
}
|
||||
|
||||
return strings.Trim(strings.ReplaceAll(line, "@chess", ""), " "), nil
|
||||
return strings.Trim(line, " "), nil
|
||||
}
|
||||
|
||||
return "", errors.New("failed to parse game start")
|
||||
|
@ -278,15 +279,18 @@ func parseGameProgress(input string) (string, error) {
|
|||
words := strings.Split(input, " ")
|
||||
|
||||
if len(lines) == 1 && len(words) == 1 {
|
||||
return strings.Trim(input, " "), nil
|
||||
return strings.Trim(strings.ReplaceAll(input, "@chess", ""), " "), nil
|
||||
}
|
||||
|
||||
for _, line := range strings.Split(input, "\n") {
|
||||
if !strings.Contains(line, "@chess") {
|
||||
line = strings.Trim(line, " ")
|
||||
|
||||
var found bool
|
||||
if line, found = strings.CutPrefix(line, "@chess"); !found {
|
||||
continue
|
||||
}
|
||||
|
||||
return strings.Trim(strings.ReplaceAll(line, "@chess", ""), " "), nil
|
||||
return strings.Trim(line, " "), nil
|
||||
}
|
||||
|
||||
return "", errors.New("failed to parse game update")
|
||||
|
|
Loading…
Reference in New Issue