route

package
v0.0.0-...-ff230d5 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Log = minori.GetLogger("route")

Functions

This section is empty.

Types

type Ctx

type Ctx struct {
	Prefix      string
	CleanPrefix string
	Session     *dg.Session
	Message     *dg.Message
	Flags       *Flags
	Route       *Route
}

func GetCtx

func GetCtx(pfx, cpfx string, s *dg.Session, m *dg.Message, routes []*Route) (*Ctx, error)

func (*Ctx) Reply

func (c *Ctx) Reply() *Reply

func (*Ctx) Run

func (c *Ctx) Run() error

func (*Ctx) Wait

func (c *Ctx) Wait(general Okay, specific Okay) chan *Ctx

func (*Ctx) WaitCancel

func (c *Ctx) WaitCancel(general Okay, specific Okay, cancel bool) chan *Ctx

type Flags

type Flags struct {
	*flag.FlagSet
	// contains filtered or unexported fields
}

func MkFlags

func MkFlags(ctx *Ctx, name string, args []string) *Flags

func (*Flags) Output

func (f *Flags) Output() string

func (*Flags) Parse

func (f *Flags) Parse() error

func (*Flags) Usage

func (f *Flags) Usage()

type Okay

type Okay func(*Ctx) bool
var BotOwner Okay = func(c *Ctx) bool {
	_f := "BotOwner"
	app, err := c.Session.Application("@me")
	if err != nil {
		errs.Wrap(&err, `c.Session.Application("@me")`)
		Log.Error(_f, err)
		return false
	}
	return app.Owner.ID == c.Message.Author.ID
}
var False Okay = func(*Ctx) bool {
	return false
}
var ServerOwner Okay = func(c *Ctx) bool {
	_f := "ServerOwner"
	gid := c.Message.GuildID
	guild, err := c.Session.Guild(gid)
	if err != nil {
		errs.Wrap(&err, `c.Session.Guild(gid)`)
		Log.Error(_f, err)
		return false
	}
	return guild.OwnerID == c.Message.Author.ID
}
var True Okay = func(*Ctx) bool {
	return true
}

func All

func All(chs ...Okay) Okay

func Any

func Any(chs ...Okay) Okay

func ContentMatch

func ContentMatch(pattern string) Okay

func SameAuthor

func SameAuthor(oc *Ctx) Okay

func SameChannelID

func SameChannelID(oc *Ctx) Okay

func UserInFunc

func UserInFunc(f func() ([]string, error)) Okay

type Reply

type Reply struct {
	*dg.MessageSend

	Session   *dg.Session
	ChannelID string
}

func (*Reply) Send

func (r *Reply) Send() (*dg.Message, error)

type Route

type Route struct {
	Name  string
	Match string
	Cat   string
	Desc  string
	Okay  Okay
	Func  func(*Ctx) error
}

type Wait

type Wait struct {
	General  Okay
	Specific Okay
	Return   chan *Ctx
	Cancel   *func()
}

func (*Wait) Handle

func (w *Wait) Handle(s *dg.Session, m *dg.MessageCreate)

Jump to

Keyboard shortcuts

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