Documentation ¶
Index ¶
- Constants
- func CompileRegexp(pattern string) *regexp.Regexp
- func CompileTemplate(temp string) (*template.Template, error)
- func EvalTemplate(temp *template.Template, params Parameters) (string, error)
- func FormatBytes(bytes uint64) string
- func FormatDuration(duration time.Duration) string
- func GetFullEventKey(event slack.MessageEvent) string
- func GetMessageTime(event slack.MessageEvent) time.Time
- func GetShortEventKey(event slack.MessageEvent) string
- func ParseDuration(input string) (time.Duration, error)
- func RandString(n int) string
- func RegexpResultToParams(regexp *regexp.Regexp, match []string) map[string]string
- func RegisterFunctions(funcMap template.FuncMap)
- type IncreasingDelay
- type Parameters
- type TemplateFunctionProvider
Examples ¶
Constants ¶
const FullMatch = "match"
FullMatch is the key of the "Result" which contains the initial full string of the matching process
Variables ¶
This section is empty.
Functions ¶
func CompileRegexp ¶
CompileRegexp compiles a regexp to a unified regexp layout: - case insensitive - always match a full line -> implicitly adds "^" and "$"
func CompileTemplate ¶
CompileTemplate pre compiles a template and returns an error if an function is not available etc
func EvalTemplate ¶
func EvalTemplate(temp *template.Template, params Parameters) (string, error)
EvalTemplate renders the template
func FormatBytes ¶ added in v1.6.0
func FormatDuration ¶
FormatDuration shortens a duration string representation. e.g. "12m1.231001s" -> "12m1s"
func GetFullEventKey ¶
func GetFullEventKey(event slack.MessageEvent) string
GetFullEventKey builds a key over user-channel-threadtimestamp
func GetMessageTime ¶
func GetMessageTime(event slack.MessageEvent) time.Time
GetMessageTime will return a time.Time of the sent date from the MessageEvent
func GetShortEventKey ¶
func GetShortEventKey(event slack.MessageEvent) string
GetShortEventKey builds a key over user-channel
func ParseDuration ¶
ParseDuration also allowes other duration modifier like "min" or "sec" e.g. 12min10sec -> 12m10s
Example ¶
fmt.Println(ParseDuration("12min1sec"))
Output: 12m1s <nil>
func RandString ¶ added in v1.3.0
RandString get random string containing just letters and numbers
func RegexpResultToParams ¶
RegexpResultToParams converts a regexp result into a simple string map...kind of deprecated
func RegisterFunctions ¶
RegisterFunctions will add a function to any template renderer
Types ¶
type IncreasingDelay ¶ added in v1.6.0
type IncreasingDelay struct {
// contains filtered or unexported fields
}
func GetIncreasingDelay ¶ added in v1.6.0
func GetIncreasingDelay(minDuration time.Duration, maxDuration time.Duration) IncreasingDelay
Returns a increasing duration to have less polling overhead but keep a higher frequency in the first day
given: min: 2, max: 9 Timeline: start max now Result: 22223333444455556666777788889999999999999999999
func (IncreasingDelay) GetNextDelay ¶ added in v1.6.0
func (d IncreasingDelay) GetNextDelay() time.Duration