Archived
1
0
Fork 0

Add Telegram Messenger notifications

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2021-03-23 18:12:44 +01:00
commit 0a9ae46d19
No known key found for this signature in database
GPG key ID: FF42D23B580C89F7
11 changed files with 255 additions and 39 deletions

View file

@ -1,9 +1,26 @@
package main
import "time"
import (
"fmt"
"time"
)
// Notifier interface to notify when a product becomes available or is sold out again
type Notifier interface {
NotifyWhenAvailable(string, string, float64, string, string) error
NotifyWhenNotAvailable(string, time.Duration) error
}
// formatPrice using internationalization rules
// euro sign is placed after the value
// default the currency, or symbol if applicable, is placed before the value
func formatPrice(value float64, currency string) string {
switch {
case currency == "EUR":
return fmt.Sprintf("%.2f€", value)
case currency == "USD":
return fmt.Sprintf("$%.2f", value)
default:
return fmt.Sprintf("%s%.2f", currency, value)
}
}