cmd

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2022 License: MPL-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MsgNoUserFound   = "No user found with that name"
	MsgMoreUserFound = "Found more than one user with that name"
	MsgNoChanges     = "No changes made"
	MsgNoPermission  = "No permission to perform action"
	MsgInternalError = "Internal error prevented correct execution"
)

Messages

Variables

View Source
var Placeholders = map[string]Replacer{
	"%CMD%": func(m string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string {
		return t.Cmd
	},
	"%RAW%": func(m string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string {
		return strings.Join(t.Raw, "")
	},
	"%ARGS%": func(m string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string {
		return strings.Join(t.Arg, " ")
	},
	"%NARGS%": func(m string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string {
		return fmt.Sprintf("%d", len(t.Arg))
	},
	"%UID%": func(m string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string {
		return t.User.ID
	},
	"%USTR%": func(m string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string {
		return t.User.Name
	},
	"%ULVL%": func(m string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string {
		return t.User.Access.String()
	},
	"%GWID%": func(m string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string {
		return gw.ID()
	},
	"%GWDIS%": func(m string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string {
		return gw.Discriminator()
	},
	"%GWDEL%": func(m string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string {
		return gateway.Delimiter
	},
	"%RARG000%": func(m string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string {
		idx, err := strconv.Atoi(replacersInt.FindString(m))
		if err != nil || idx <= 0 || len(t.Raw) <= idx {
			return m
		}
		return t.Raw[idx-1]
	},
	"%..RARG000%": func(m string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string {
		idx, err := strconv.Atoi(replacersInt.FindString(m))
		if err != nil || idx <= 0 || len(t.Raw) <= idx {
			return m
		}
		return strings.Join(t.Raw[:idx-1], "")
	},
	"%RARG000..%": func(m string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string {
		idx, err := strconv.Atoi(replacersInt.FindString(m))
		if err != nil || idx <= 0 || len(t.Raw) <= idx {
			return m
		}
		return strings.Join(t.Raw[idx-1:], "")
	},
	"%ARG000%": func(m string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string {
		idx, err := strconv.Atoi(replacersInt.FindString(m))
		if err != nil || idx <= 0 || len(t.Arg) <= idx {
			return m
		}
		return t.Arg[idx-1]
	},
	"%..ARG000%": func(m string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string {
		idx, err := strconv.Atoi(replacersInt.FindString(m))
		if err != nil || idx <= 0 || len(t.Arg) <= idx {
			return m
		}
		return strings.Join(t.Arg[:idx-1], " ")
	},
	"%ARG000..%": func(m string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string {
		idx, err := strconv.Atoi(replacersInt.FindString(m))
		if err != nil || idx <= 0 || len(t.Arg) <= idx {
			return m
		}
		return strings.Join(t.Arg[idx-1:], " ")
	},
}

Placeholders map

Functions

func Replace added in v0.10.0

func Replace(s string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string

Replace all placeholders

Types

type Alias

type Alias struct {
	Cmd
	Exe            string
	Arg            []string
	ArgExpected    int
	WithPriviledge gateway.AccessLevel
}

Alias abbreviates a command

func (*Alias) Execute

func (c *Alias) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

type Ban

type Ban struct {
	Cmd
	AccessProtect  gateway.AccessLevel
	AccessOverride gateway.AccessLevel
}

Ban user

func (*Ban) Execute

func (c *Ban) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

type Cmd

type Cmd struct {
	Disabled   bool
	Priviledge gateway.AccessLevel
}

Cmd is command base struct that implements Command.CanExecute

func (*Cmd) CanExecute

func (c *Cmd) CanExecute(t *gateway.Trigger) bool

CanExecute returns true if t.Access >= c.Access

type Commands

type Commands struct {
	Trigger    Trigger
	Whoami     Whoami
	Whois      Whois
	Settings   Settings
	List       List
	Echo       Echo
	Say        Say
	SayPrivate SayPrivate
	Set        Set
	Kick       Kick
	Ban        Ban
	Unban      Unban
	Where      Where
	Who        Who
	Ping       Ping
	Time       Time
	Uptime     Uptime
}

Commands listing

func (*Commands) AddTo

func (c *Commands) AddTo(g *goop.Goop) error

AddTo goop

type Echo added in v0.9.11

type Echo struct{ Cmd }

Echo input

func (*Echo) Execute added in v0.9.11

func (c *Echo) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

type Kick

type Kick struct {
	Cmd
	AccessProtect  gateway.AccessLevel
	AccessOverride gateway.AccessLevel
}

Kick user

func (*Kick) Execute

func (c *Kick) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

type List

type List struct{ Cmd }

List users for a given access level

func (*List) Execute

func (c *List) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

type Ping

type Ping struct{ Cmd }

Ping user

func (*Ping) Execute

func (c *Ping) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

type Replacer added in v0.10.0

type Replacer func(m string, t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) string

Replacer callback

type Say

type Say struct{ Cmd }

Say input in channel

func (*Say) Execute

func (c *Say) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

type SayPrivate

type SayPrivate struct{ Cmd }

SayPrivate forwards input to user in private

func (*SayPrivate) Execute

func (c *SayPrivate) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

type Set

type Set struct {
	Cmd
	DefaultAccess gateway.AccessLevel
}

Set accesslevel for user

func (*Set) Execute

func (c *Set) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

type Settings

type Settings struct{ Cmd }

Settings management

func (*Settings) Execute

func (c *Settings) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

type Time

type Time struct {
	Cmd
	Format string
}

Time prints current time

func (*Time) Execute

func (c *Time) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

type Trigger

type Trigger struct{ Cmd }

Trigger outputs the command trigger for gateway

func (*Trigger) Execute

func (c *Trigger) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

type Unban

type Unban struct {
	Cmd
	AccessProtect  gateway.AccessLevel
	AccessOverride gateway.AccessLevel
}

Unban user

func (*Unban) Execute

func (c *Unban) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

type Uptime

type Uptime struct{ Cmd }

Uptime prints time since start

func (*Uptime) Execute

func (c *Uptime) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

type Where

type Where struct{ Cmd }

Where prints connected gateways

func (*Where) Execute

func (c *Where) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

type Who added in v0.10.0

type Who struct{ Cmd }

Who prints who is in channel

func (*Who) Execute added in v0.10.0

func (c *Who) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

type Whoami

type Whoami struct{ Cmd }

Whoami displays user info

func (*Whoami) Execute

func (c *Whoami) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

type Whois

type Whois struct{ Cmd }

Whois displays user info

func (*Whois) Execute

func (c *Whois) Execute(t *gateway.Trigger, gw gateway.Gateway, g *goop.Goop) error

Execute command

Jump to

Keyboard shortcuts

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