Fixed bug where looks for attending status in 1st line, but not always there

This commit is contained in:
Harry Culpan 2024-01-21 01:01:38 -05:00
parent 1bbbbd0dd3
commit 3e1e091356
2 changed files with 12 additions and 6 deletions

1
.gitignore vendored
View file

@ -14,6 +14,7 @@ awp-cli
awp-cli.*
players.json
.DS_Store
.vscode
# air-related stuff
tmp

View file

@ -15,15 +15,19 @@ 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
var checkCmd = &cobra.Command{
Use: "check",
@ -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)