Documentation
¶
Index ¶
- Constants
- Variables
- func Filter[T any](prefix string) handlers.Filter[*goram.CallbackQuery]
- func FilterFunc[T any](prefix string, predicate func(data T) bool) handlers.Filter[*goram.CallbackQuery]
- func Pack[T any](prefix string, value T) string
- func Unpack[T any](prefix string, callbackData string) (T, error)
Constants ¶
const Key = "callbackData"
handlers.Data key for unpacked callback data
Variables ¶
var ErrInvalidPrefix = errors.New("invalid prefix")
Functions ¶
func Filter ¶
Creates callback query filter for callback data. Unpacks callback data and check the prefix. If a query has no data, the created filter returns false. If the prefix matches, the created filter puts unpacked callback data to handler data with "callbackData" key and returns true. Otherwise returns false.
func FilterFunc ¶
func FilterFunc[T any]( prefix string, predicate func(data T) bool, ) handlers.Filter[*goram.CallbackQuery]
Does the same as .Filter() but also applies the provided predicate.
func Pack ¶
Packs callback data string.
T should be fixed size. T will be binary encoded to consume less space (because callback data is up to 64 bytes only). Prefix is used to determine what value got encoded to the string. See .Unpack(). Prefix should not contain ':' since it is used as a delimiter.
Returns packed callback data string. Panics if T can't be binary encoded. The returned string is *not* checked to fit 64 bytes.
Types ¶
This section is empty.