command

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MustPlayerConnected = iota
	MustNickIs
)

Variables

View Source
var NotFoundChat *chat.ChatBuilder
View Source
var SimiularFoundMSG *string

Functions

func Boot

func Boot()

Função que é chamada pelo inicializador do RakStar

func Builder

func Builder() *commandBuilder

func HandlePlayerCommandText

func HandlePlayerCommandText(player natives.Player, cmdtext string) bool

Função que deve ser chamada na callback "OnPlayerCommand"

func RegisterCommand

func RegisterCommand(command *Command) (bool, error)

func RegisterInterceptor

func RegisterInterceptor(commandName string, interceptor CommandInterceptorHandler)

func SetConfig

func SetConfig(notFoundChat *chat.ChatBuilder, similarFoundMsg string)

seta as mensagens que são executadas qunado um comando similar é encontrado, ou quando nenhum é encontrado.

Exemplo:

cb := chat.builder()

cb.Message("nenhum comando encontrado")

similarFound := "comando similar"

SetConfig(cb, similarFound)

# Resultado:

  • *Jogador digita "/command", mas não existe:

    > chat: nenhum comando foi encontrado

  • *Jogador digita "/aujad", e similar foi encontrado: "ajuda"

    > chat: comando similar: ajuda

Types

type ArgHandler

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

func (*ArgHandler) GetInput

func (self *ArgHandler) GetInput() *string

func (*ArgHandler) Next

func (self *ArgHandler) Next(defaultValues ...string) *string

func (*ArgHandler) NextFloat

func (self *ArgHandler) NextFloat(defaultValues ...float64) *float64

func (*ArgHandler) NextInt

func (self *ArgHandler) NextInt(defaultValues ...int) *int

func (*ArgHandler) Restore

func (self *ArgHandler) Restore()

type Command

type Command struct {
	Name         string
	Handler      CommandHandler
	Interceptors []CommandInterceptorHandler
	Description  string
	RequireLogin bool
	Aliases      []string
	Roles        []string
	// contains filtered or unexported fields
}

func SearchCommand

func SearchCommand(inputName string) (*Command, int)

type CommandContext

type CommandContext struct {
	Player     *natives.Player
	ArgHandler *ArgHandler
}

type CommandHandler

type CommandHandler func(context *CommandContext)

type CommandInterceptorContext

type CommandInterceptorContext struct {
	Player     *natives.Player
	ArgHandler *ArgHandler
	// contains filtered or unexported fields
}

func (*CommandInterceptorContext) Next

func (self *CommandInterceptorContext) Next()

type CommandInterceptorHandler

type CommandInterceptorHandler func(context *CommandInterceptorContext)

type TPlayer

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

func (*TPlayer) End

func (tp *TPlayer) End() *conditionalsBuilder

func (*TPlayer) EndConditionals

func (tp *TPlayer) EndConditionals() *commandBuilder

func (*TPlayer) MustConnected

func (tp *TPlayer) MustConnected() *TPlayer

func (*TPlayer) MustNickIs

func (tp *TPlayer) MustNickIs(nick string) *TPlayer

Jump to

Keyboard shortcuts

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