templates

package
v1.15.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2019 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTooManyCalls = errors.New("Too many calls to this function")
View Source
var (
	StandardFuncMap = map[string]interface{}{

		"str":      ToString,
		"toString": ToString,
		"toInt":    tmplToInt,
		"toInt64":  ToInt64,
		"toFloat":  ToFloat64,

		"joinStr":   joinStrings,
		"lower":     strings.ToLower,
		"upper":     strings.ToUpper,
		"slice":     slice,
		"urlescape": url.PathEscape,
		"split":     strings.Split,
		"title":     strings.Title,

		"add":  add,
		"mult": tmplMult,
		"div":  tmplDiv,
		"fdiv": tmplFDiv,

		"dict":   Dictionary,
		"sdict":  StringKeyDictionary,
		"cembed": CreateEmbed,
		"cslice": CreateSlice,

		"formatTime":  tmplFormatTime,
		"json":        tmplJson,
		"in":          in,
		"inFold":      inFold,
		"roleAbove":   roleIsAbove,
		"adjective":   common.RandomAdjective,
		"randInt":     randInt,
		"shuffle":     shuffle,
		"seq":         sequence,
		"currentTime": tmplCurrentTime,

		"escapeHere":         tmplEscapeHere,
		"escapeEveryone":     tmplEscapeEveryone,
		"escapeEveryoneHere": tmplEscapeEveryoneHere,

		"humanizeDurationHours": tmplHumanizeDurationHours,
		"humanizeTimeSinceDays": tmplHumanizeTimeSinceDays,
	}
)

Functions

func CreateEmbed added in v1.4.1

func CreateEmbed(values ...interface{}) (*discordgo.MessageEmbed, error)

func CreateSlice added in v1.4.1

func CreateSlice(values ...interface{}) ([]interface{}, error)

func Dictionary

func Dictionary(values ...interface{}) (map[interface{}]interface{}, error)

dictionary creates a map[string]interface{} from the given parameters by walking the parameters and treating them as key-value pairs. The number of parameters must be even.

func LimitWriter added in v1.10.1

func LimitWriter(w io.Writer, n int64) io.Writer

LimitWriter works like io.LimitReader. It writes at most n bytes to the underlying Writer. It returns io.ErrShortWrite if more than n bytes are attempted to be written.

func MaybeScheduledDeleteMessage added in v1.13.0

func MaybeScheduledDeleteMessage(guildID, channelID, messageID int64, delaySeconds int)

func RegisterSetupFunc

func RegisterSetupFunc(f ContextSetupFunc)

func TODO

func TODO()

func ToFloat64 added in v1.15.1

func ToFloat64(from interface{}) float64

func ToInt64

func ToInt64(from interface{}) int64

func ToString

func ToString(from interface{}) string

Types

type Context

type Context struct {
	GS *dstate.GuildState
	CS *dstate.ChannelState

	MS  *dstate.MemberState
	Msg *discordgo.Message

	BotUser *discordgo.User

	ContextFuncs map[string]interface{}
	Data         map[string]interface{}

	MentionEveryone  bool
	MentionHere      bool
	MentionRoles     []int64
	MentionRoleNames []string

	DelResponse bool
	DelTrigger  bool

	DelTriggerDelay  int
	DelResponseDelay int

	Counters map[string]int

	EmebdsToSend []*discordgo.MessageEmbed

	AddResponseReactionNames []string

	FixedOutput string
	// contains filtered or unexported fields
}

func NewContext

func NewContext(gs *dstate.GuildState, cs *dstate.ChannelState, ms *dstate.MemberState) *Context

func (*Context) Execute

func (c *Context) Execute(source string) (string, error)

func (*Context) IncreaseCheckCallCounter added in v0.29.1

func (c *Context) IncreaseCheckCallCounter(key string, limit int) bool

IncreaseCheckCallCounter Returns true if key is above the limit

func (*Context) Parse added in v1.14.0

func (c *Context) Parse(source string) (*template.Template, error)

type ContextSetupFunc

type ContextSetupFunc func(ctx *Context)

type SDict added in v1.15.1

type SDict struct {
	// contains filtered or unexported fields
}

func StringKeyDictionary added in v1.4.1

func StringKeyDictionary(values ...interface{}) (*SDict, error)

func (*SDict) Get added in v1.15.1

func (d *SDict) Get(key string) interface{}

func (*SDict) MarshalJSON added in v1.15.1

func (d *SDict) MarshalJSON() ([]byte, error)

func (*SDict) Set added in v1.15.1

func (d *SDict) Set(key string, value interface{}) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL