Skip to content

Commit

Permalink
Update tweet message and float formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
HelixSpiral committed Jul 25, 2023
1 parent 9f048c5 commit e2eb966
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,20 @@ func main() {
}

if buoyInfo.WindSpeed > 0 {
tweetMessage += fmt.Sprintf("sustained winds of %f m/s", buoyInfo.WindSpeed)
if buoyInfo.GustSpeed > 0 {
tweetMessage += fmt.Sprintf(", and gusting up to %f m/s!", buoyInfo.GustSpeed)
tweetMessage += fmt.Sprintf("sustained winds of %.1f m/s", buoyInfo.WindSpeed)
if buoyInfo.GustSpeed > 0 && buoyInfo.GustSpeed != buoyInfo.WindSpeed {
tweetMessage += fmt.Sprintf(", and gusting up to %.1f m/s!", buoyInfo.GustSpeed)
} else {
tweetMessage += "."
tweetMessage += "!"
}
}

if tweetMessage != "" {
tweetMessage += "\\r\\n\\r\\n"
}

tweetMessage += "#noaa #ndbc #buoy #Maine #coast #weather #ocean"

// I'm sure there's a better way to do this, but it's simple and it works.
// We use this to ensure the first letter is capital, there's a change it wont be if there's no
// wind direction information
Expand Down

0 comments on commit e2eb966

Please sign in to comment.