customcommands

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2018 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxCommands     = 100
	MaxUserMessages = 20
)

Variables

View Source
var (
	RegexCache *ccache.Cache
)

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 ExecuteCustomCommand

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

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(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(ms *dstate.MemberState) bool

func (*CustomCommand) RunsInChannel

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

func (*CustomCommand) Save

func (cc *CustomCommand) Save(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) AddCommands added in v1.4.1

func (p *Plugin) AddCommands()

func (*Plugin) BotInit added in v1.4.1

func (p *Plugin) BotInit()

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