2024-01-01 16:52:18 +00:00
|
|
|
// Package numeric contains helpers for numeric manipulation
|
2021-11-19 21:53:30 +00:00
|
|
|
package numeric
|
|
|
|
|
2022-02-10 00:12:57 +00:00
|
|
|
import (
|
|
|
|
"math"
|
|
|
|
|
2022-11-02 21:38:14 +00:00
|
|
|
"github.com/Luzifer/twitch-bot/v3/plugins"
|
2022-02-10 00:12:57 +00:00
|
|
|
)
|
2021-11-19 21:53:30 +00:00
|
|
|
|
2024-01-01 16:52:18 +00:00
|
|
|
// Register provides the plugins.RegisterFunc
|
2021-11-19 21:53:30 +00:00
|
|
|
func Register(args plugins.RegistrationArguments) error {
|
2023-08-25 21:37:37 +00:00
|
|
|
args.RegisterTemplateFunction("pow", plugins.GenericTemplateFunctionGetter(math.Pow), plugins.TemplateFuncDocumentation{
|
|
|
|
Description: "Returns float from calculation: `float1 ** float2`",
|
|
|
|
Syntax: "pow <float1> <float2>",
|
|
|
|
Example: &plugins.TemplateFuncDocumentationExample{
|
|
|
|
Template: `{{ printf "%.0f" (pow 10 4) }}`,
|
|
|
|
ExpectedOutput: "10000",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2021-11-19 21:53:30 +00:00
|
|
|
return nil
|
|
|
|
}
|