customcommands

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2018 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxCommands     = 100
	MaxUserMessages = 20
)

Variables

This section is empty.

Functions

func CheckLimits

func CheckLimits(in ...string) bool

func CheckMatch

func CheckMatch(globalPrefix string, cmd *CustomCommand, msg string) (match bool, stripped string, args []string)

CheckMatch returns true if the given cmd matches, as well as the arguments following the command trigger (arg 0 being the message up to, and including, the trigger).

func Dir

func Dir(useLocal bool, name string) http.FileSystem

Dir returns a http.Filesystem for the embedded assets on a given prefix dir. If useLocal is true, the filesystem's contents are instead used.

func ExecuteCustomCommand

func ExecuteCustomCommand(cmd *CustomCommand, cmdArgs []string, stripped string, client *redis.Client, s *discordgo.Session, m *discordgo.MessageCreate) (resp string, tmplCtx *templates.Context, err error)

func FS

func FS(useLocal bool) http.FileSystem

FS returns a http.Filesystem for the embedded assets. If useLocal is true, the filesystem's contents are instead used.

func FSByte

func FSByte(useLocal bool, name string) ([]byte, error)

FSByte returns the named file from the embedded assets. If useLocal is true, the filesystem's contents are instead used.

func FSMustByte

func FSMustByte(useLocal bool, name string) []byte

FSMustByte is the same as FSByte, but panics if name is not present.

func FSMustString

func FSMustString(useLocal bool, name string) string

FSMustString is the string version of FSMustByte.

func FSString

func FSString(useLocal bool, name string) (string, error)

FSString is the string version of FSByte.

func HandleCommands

func HandleCommands(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)

func HandleDeleteCommand

func HandleDeleteCommand(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)

func HandleMessageCreate

func HandleMessageCreate(evt *eventsystem.EventData)

func HandleNewCommand

func HandleNewCommand(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)

func HandleUpdateCommand

func HandleUpdateCommand(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)

func KeyCommands

func KeyCommands(guildID int64) string

func RegisterPlugin

func RegisterPlugin()

func StringCommands

func StringCommands(ccs []*CustomCommand) string

Types

type CommandTriggerType

type CommandTriggerType int
const (
	CommandTriggerCommand CommandTriggerType = iota
	CommandTriggerStartsWith
	CommandTriggerContains
	CommandTriggerRegex
	CommandTriggerExact
)

func TriggerTypeFromForm

func TriggerTypeFromForm(str string) CommandTriggerType

func (CommandTriggerType) String

func (t CommandTriggerType) String() string

type CustomCommand

type CustomCommand struct {
	TriggerType     CommandTriggerType `json:"trigger_type"`
	TriggerTypeForm string             `json:"-" schema:"type"`
	Trigger         string             `json:"trigger" schema:"trigger" valid:",1,1000"`
	// TODO: Retire the legacy Response field.
	Response      string   `json:"response,omitempty" schema:"response" valid:",3000"`
	Responses     []string `json:"responses" schema:"responses" valid:",3000"`
	CaseSensitive bool     `json:"case_sensitive" schema:"case_sensitive"`
	ID            int      `json:"id"`

	// If set, then the following channels are required, otherwise they are ignored
	RequireChannels bool    `json:"require_channels" schema:"require_channels"`
	Channels        []int64 `json:"channels" schema:"channels"`

	// If set, then one of the following channels are required, otherwise they are ignored
	RequireRoles bool    `json:"require_roles" schema:"require_roles"`
	Roles        []int64 `json:"roles" schema:"roles"`
}

func FindCommands

func FindCommands(ccs []*CustomCommand, data *dcmd.Data) (foundCCS []*CustomCommand, provided bool)

func GetCommands

func GetCommands(client *redis.Client, guild int64) ([]*CustomCommand, int, error)

func (*CustomCommand) Migrate added in v0.29.1

func (cc *CustomCommand) Migrate() *CustomCommand

Migrate modifies a CustomCommand to remove legacy fields.

func (*CustomCommand) RunsForUser

func (cc *CustomCommand) RunsForUser(m *discordgo.Member) bool

func (*CustomCommand) RunsInChannel

func (cc *CustomCommand) RunsInChannel(channel int64) bool

func (*CustomCommand) Save

func (cc *CustomCommand) Save(client *redis.Client, guildID int64) error

type CustomCommandSlice

type CustomCommandSlice []*CustomCommand

func (CustomCommandSlice) Len

func (c CustomCommandSlice) Len() int

Len is the number of elements in the collection.

func (CustomCommandSlice) Less

func (c CustomCommandSlice) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (CustomCommandSlice) Swap

func (c CustomCommandSlice) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type Plugin

type Plugin struct{}

func (*Plugin) InitBot

func (p *Plugin) InitBot()

func (*Plugin) InitWeb

func (p *Plugin) InitWeb()

func (*Plugin) Name

func (p *Plugin) Name() string

Jump to

Keyboard shortcuts

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