oxdisaster

package module
v0.0.0-...-79a785b Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRouteNotFound = errors.New("Error: Router not found")
)

list for available error

Functions

This section is empty.

Types

type Args

type Args []string

Args is the type for commands arguments

func ParseArgs

func ParseArgs(str string) Args

ParseArgs parse posible arguments from a string

type Context

type Context struct {
	Route  *Route
	Routes []*Route

	Session *discordgo.Session // discordgo session
	Event   interface{}        // discordgo event
	Args    Args               // list of available commands arguments

	// Optional variables for the context using mutex
	Mut  sync.RWMutex
	Vars map[string]interface{}
}

Context is the router context that's stores certain data for the handler

func NewContext

func NewContext(ses *discordgo.Session, evt interface{}, route *Route, routes []*Route, args Args) *Context

NewContext create new router context by the given value

func (*Context) Get

func (c *Context) Get(key string) interface{}

Get get the value by it's key from the context

func (*Context) Set

func (c *Context) Set(key string, value interface{})

Set set a new key:value pair to the context

type HandlerFunc

type HandlerFunc func(*Context)

HandlerFunc is the handler function for the router

type MiddlewareFunc

type MiddlewareFunc func(HandlerFunc) HandlerFunc

MiddlewareFunc is the middleware function for the router

type Route

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

Route is object of the router

func NewRouter

func NewRouter(prefix string) *Route

NewRouter create and return fresh Route object

func (*Route) Cat

func (r *Route) Cat() string

Cat get the router category

func (*Route) HandleFunc

func (r *Route) HandleFunc(name string, handler HandlerFunc) *Route

HandleFunc register new router and the handler

func (*Route) Handler

func (r *Route) Handler() HandlerFunc

Handler get the handler

func (*Route) Listen

func (r *Route) Listen(ses *discordgo.Session, evt interface{}) error

Listen start listening to incoming event

func (*Route) MatchCat

func (r *Route) MatchCat(cat string) []*Route

MatchCat get all available route by category

func (*Route) MatchName

func (r *Route) MatchName(name string) *Route

MatchName get available route by name

func (*Route) MatchType

func (r *Route) MatchType(ty string) []*Route

MatchType get all available route by types

func (*Route) Name

func (r *Route) Name() string

Name get the router name

func (*Route) NewRoute

func (r *Route) NewRoute() *Route

NewRoute register an empty route

func (*Route) Prefix

func (r *Route) Prefix() string

Prefix get the router prefix

func (*Route) Routes

func (r *Route) Routes() []*Route

Routes get all available router

func (*Route) SetCat

func (r *Route) SetCat(cat string) *Route

SetCat set the router category

func (*Route) SetHandler

func (r *Route) SetHandler(handler HandlerFunc) *Route

SetHandler set the router handler

func (*Route) SetName

func (r *Route) SetName(name string) *Route

SetName set the router name

func (*Route) SetType

func (r *Route) SetType(ty string) *Route

SetType set the router event types

func (*Route) SetUsage

func (r *Route) SetUsage(usage string) *Route

SetUsage set the router usage

func (*Route) Type

func (r *Route) Type() string

Type get the category types

func (*Route) Usage

func (r *Route) Usage() string

Usage get the router usage

func (*Route) Use

func (r *Route) Use(mwf ...MiddlewareFunc)

Use appends appends a MiddlewareFunc tonthe chain

Jump to

Keyboard shortcuts

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