Compare commits
No commits in common. "ca2ccc569d17f9b613fa10ed849e7a354812687f" and "58b1eabadf7836c824d99e38ad50aa52d8fd3b2f" have entirely different histories.
ca2ccc569d
...
58b1eabadf
@ -1,3 +1,3 @@
|
|||||||
SN_BASE_URL=
|
SN_BASE_URL=
|
||||||
SN_API_KEY=
|
SN_API_TOKEN=
|
||||||
SN_MEDIA_URL=
|
SN_MEDIA_URL=
|
||||||
|
14
main.go
14
main.go
@ -263,12 +263,11 @@ func parseGameStart(input string) (string, error) {
|
|||||||
for _, line := range strings.Split(input, "\n") {
|
for _, line := range strings.Split(input, "\n") {
|
||||||
line = strings.Trim(line, " ")
|
line = strings.Trim(line, " ")
|
||||||
|
|
||||||
var found bool
|
if !strings.HasPrefix(line, "@chess") {
|
||||||
if line, found = strings.CutPrefix(line, "@chess"); !found {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Trim(line, " "), nil
|
return strings.Trim(strings.ReplaceAll(line, "@chess", ""), " "), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", errors.New("failed to parse game start")
|
return "", errors.New("failed to parse game start")
|
||||||
@ -279,18 +278,15 @@ func parseGameProgress(input string) (string, error) {
|
|||||||
words := strings.Split(input, " ")
|
words := strings.Split(input, " ")
|
||||||
|
|
||||||
if len(lines) == 1 && len(words) == 1 {
|
if len(lines) == 1 && len(words) == 1 {
|
||||||
return strings.Trim(strings.ReplaceAll(input, "@chess", ""), " "), nil
|
return strings.Trim(input, " "), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, line := range strings.Split(input, "\n") {
|
for _, line := range strings.Split(input, "\n") {
|
||||||
line = strings.Trim(line, " ")
|
if !strings.Contains(line, "@chess") {
|
||||||
|
|
||||||
var found bool
|
|
||||||
if line, found = strings.CutPrefix(line, "@chess"); !found {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Trim(line, " "), nil
|
return strings.Trim(strings.ReplaceAll(line, "@chess", ""), " "), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", errors.New("failed to parse game update")
|
return "", errors.New("failed to parse game update")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user