refacto: Remove overengineered convertAction func
Because it can be simply replaced by a condition. Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
5f67ba2279
commit
fed6459f9d
4 changed files with 1 additions and 15 deletions
|
@ -98,7 +98,6 @@ The following **functions** are available to templates:
|
||||||
* `upper(str string)`: convert string to upper case
|
* `upper(str string)`: convert string to upper case
|
||||||
* `lower(str string)`: convert string to lower case
|
* `lower(str string)`: convert string to lower case
|
||||||
* `convertCurrency(coin string, value int64)`: convert the smallest unit of a coin to a human readable unit
|
* `convertCurrency(coin string, value int64)`: convert the smallest unit of a coin to a human readable unit
|
||||||
* `convertAction(coin string)`: return "Farmed" word for Chia coin or "Mined" for other coins
|
|
||||||
* `formatBlockURL(coin string, hash string)`: return the URL on the explorer website of the coin of the block
|
* `formatBlockURL(coin string, hash string)`: return the URL on the explorer website of the coin of the block
|
||||||
identified by its hash
|
identified by its hash
|
||||||
* `formatTransactionURL(coin string, hash string)`: return the URL on the explorer website of the coin of the
|
* `formatTransactionURL(coin string, hash string)`: return the URL on the explorer website of the coin of the
|
||||||
|
|
|
@ -93,7 +93,6 @@ func (t *TelegramNotifier) formatMessage(templateFileName string, attachment int
|
||||||
"upper": strings.ToUpper,
|
"upper": strings.ToUpper,
|
||||||
"lower": strings.ToLower,
|
"lower": strings.ToLower,
|
||||||
"convertCurrency": ConvertCurrency,
|
"convertCurrency": ConvertCurrency,
|
||||||
"convertAction": ConvertAction,
|
|
||||||
"formatBlockURL": FormatBlockURL,
|
"formatBlockURL": FormatBlockURL,
|
||||||
"formatTransactionURL": FormatTransactionURL,
|
"formatTransactionURL": FormatTransactionURL,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
🎉 *{{ convertAction .Pool.Coin }}* [#{{ .Block.Number }}]({{ formatBlockURL .Pool.Coin .Block.Hash }}) _{{ printf "%.6f" (convertCurrency .Pool.Coin .Block.Reward) }} {{ upper .Pool.Coin }}_
|
🎉 *{{ if (eq .Pool.Coin "xch") }}Farmed{{ else }}Mined{{ end }}* [#{{ .Block.Number }}]({{ formatBlockURL .Pool.Coin .Block.Hash }}) _{{ printf "%.6f" (convertCurrency .Pool.Coin .Block.Reward) }} {{ upper .Pool.Coin }}_
|
12
utils.go
12
utils.go
|
@ -33,18 +33,6 @@ func ConvertMojo(value float64) float64 {
|
||||||
return value / MojoToXCHDivider
|
return value / MojoToXCHDivider
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConvertAction returns "Miner" for Ethereum and "Farmer" for Chia
|
|
||||||
// Because Chia is farmed and not mined
|
|
||||||
func ConvertAction(coin string) (string, error) {
|
|
||||||
switch coin {
|
|
||||||
case "eth":
|
|
||||||
return "Mined", nil
|
|
||||||
case "xch":
|
|
||||||
return "Farmed", nil
|
|
||||||
}
|
|
||||||
return "", fmt.Errorf("Coin %s not supported", coin)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FormatBlockURL returns the URL on the respective blockchain explorer given the coin and the block hash
|
// FormatBlockURL returns the URL on the respective blockchain explorer given the coin and the block hash
|
||||||
func FormatBlockURL(coin string, hash string) (string, error) {
|
func FormatBlockURL(coin string, hash string) (string, error) {
|
||||||
switch coin {
|
switch coin {
|
||||||
|
|
Reference in a new issue