Fixed bug where looks for attending status in 1st line, but not always there
This commit is contained in:
parent
1bbbbd0dd3
commit
3e1e091356
2 changed files with 12 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -14,6 +14,7 @@ awp-cli
|
|||
awp-cli.*
|
||||
players.json
|
||||
.DS_Store
|
||||
.vscode
|
||||
|
||||
# air-related stuff
|
||||
tmp
|
||||
|
|
|
|||
|
|
@ -15,13 +15,17 @@ import (
|
|||
func isAttending(body string) string {
|
||||
body = strings.ToLower(body)
|
||||
lines := strings.Fields(body)
|
||||
if strings.Contains(lines[0], "yes") {
|
||||
|
||||
for _, l := range lines {
|
||||
line := strings.Trim(l, " \t\r\n")
|
||||
if strings.HasPrefix(line, "yes") {
|
||||
return "yes"
|
||||
} else if strings.Contains(lines[0], "no") {
|
||||
} else if strings.HasPrefix(line, "no") {
|
||||
return "no"
|
||||
} else {
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
// checkCmd represents the check command
|
||||
|
|
@ -41,6 +45,7 @@ will attend the next session.`,
|
|||
if len(emails) == 0 {
|
||||
log.Default().Println("No new emails")
|
||||
} else {
|
||||
log.Default().Println("Reading new emails")
|
||||
session, err := data.ReadSessionData()
|
||||
if err != nil {
|
||||
log.Default().Println(err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue