Documentation
¶
Overview ¶
Package replier provides the delayed replier.
Index ¶
- func Cancel(ctx *plugin.Context)
- func NewMiddleware(o *Options) bot.MiddlewareFunc
- func NoSplit(message string) []string
- func Reply(ctx *plugin.Context, content string) ([]discord.Message, error)
- func ReplyDM(ctx *plugin.Context, content string) ([]discord.Message, error)
- func ReplyDMWithDelay(ctx *plugin.Context, content string, f DelayFunc) ([]discord.Message, error)
- func ReplyWithDelay(ctx *plugin.Context, content string, f DelayFunc) ([]discord.Message, error)
- type DelayFunc
- type Options
- type Splitter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cancel ¶
Cancel cancels the replier, making ongoing calls to one of the Reply methods return errors.Abort.
func NewMiddleware ¶
func NewMiddleware(o *Options) bot.MiddlewareFunc
NewMiddleware creates a new middleware for the passed *Replier, that stores the replier in the *plugin.Context.
func Reply ¶
Reply sends a textual reply in the invoking channel. The passed content may be split in accordance with the SplitterFunc defined in the replier's Options.
func ReplyDM ¶
ReplyDM sends a textual reply in a direct message channel with the invoking user. The passed content may be split in accordance with the SplitterFunc defined in the replier's Options.
func ReplyDMWithDelay ¶
ReplyDMWithDelay is the same as Reply, but uses the passed DelayFunc instead of the replier's default.
Types ¶
type DelayFunc ¶
DelayFunc is the function type used to calculate how long a specific message shall be delayed.
func RandomizedDelay ¶
RandomizedDelay returns a delay that consists of a fixed character-based delay.
func StaticDelay ¶
StaticDelay is a DelayFunc that always returns the same delay.
type Options ¶
type Options struct {
// DefaultDelayFunc is the DelayFunc used if no replacement was
// provided.
//
// Default: RandomizedDelay(500*time.Millesecond, 0.1)
DefaultDelayFunc DelayFunc
// Splitter is the Splitter used to split messages.
//
// Default: NoSplit
Splitter Splitter
// NoTyping specifies that no typing event shall be sent.
//
// Default: false
NoTyping bool
}
Options holds the configuration of the replier.
type Splitter ¶
Splitter is the function used to split messages into smaller ones.
func FieldsFuncSplitter ¶
FieldsFuncSplitter creates a new Splitter that splits, as if f was handed to strings.FieldsFunc.