From e2eb966d302c8ce6d816bea917ec28fc404cd70a Mon Sep 17 00:00:00 2001 From: Shawn Smith Date: Mon, 24 Jul 2023 21:56:30 -0400 Subject: [PATCH] Update tweet message and float formatting --- main.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 7a7ba1a..cc8ab5c 100644 --- a/main.go +++ b/main.go @@ -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