Skip to content

Commit b8467bc

Browse files
author
n0str
committed
Add float parsing due to API change
1 parent 2544e16 commit b8467bc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/requests.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package main
33

44
import (
55
"fmt"
6-
"github.com/gocarina/gocsv"
76
"log"
87
"net/http"
98
"net/url"
109
"strconv"
1110
"strings"
11+
12+
"github.com/gocarina/gocsv"
1213
)
1314

1415
const openCollectiveURL string = "https://rest.opencollective.com/v2/editorjs/transactions.txt?" +
@@ -42,15 +43,15 @@ func GetTransactionsFromOpenCollective() []*Transaction {
4243
func SendToChat(transactions []*Transaction, webhookToken string) {
4344
var message string
4445
for i := 0; i < len(transactions); i++ {
45-
amount, err := strconv.Atoi(transactions[i].Amount)
46+
amount, err := strconv.ParseFloat(transactions[i].Amount, 64)
4647

4748
if err != nil {
4849
log.Fatal(err)
4950
}
5051

5152
// Check if amount is less than zero.
5253
if amount > 0 {
53-
message = message + fmt.Sprintf("💰 %d$ %s to %s \n\n", amount, transactions[i].Description, transactions[i].To)
54+
message = message + fmt.Sprintf("💰 %d$ %s to %s \n\n", int(amount), transactions[i].Description, transactions[i].To)
5455
}
5556
}
5657
if len(message) > 0 {
@@ -59,6 +60,7 @@ func SendToChat(transactions []*Transaction, webhookToken string) {
5960

6061
_, err := http.Post(fmt.Sprintf("%s%s", webhookURL, webhookToken), webhookContentType,
6162
strings.NewReader(data.Encode()))
63+
6264
if err != nil {
6365
log.Fatal(err)
6466
}

0 commit comments

Comments
 (0)