cmdtable

package
v0.0.0-...-e2e6f4c Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package cmdtable implements tools to look up chat commands in a table.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandContext

type CommandContext[Executor any] struct {
	Command      commands.Command
	ArgValidator *regexp.Regexp
	Executor     Executor
	Tag          string // TODO: should probably be in ipc.Command
}

A CommandContext holds information on a command.

type Inserter

type Inserter[E any] struct {
	// contains filtered or unexported fields
}

An Inserter is used to insert multiple commands into the table in a single transaction.

func (*Inserter[E]) Insert

func (i *Inserter[E]) Insert(cmd []byte, cc *CommandContext[E])

type Table

type Table[Executor any] struct {
	// contains filtered or unexported fields
}

func New

func New[Executor any]() *Table[Executor]

func (*Table[E]) Command

func (tab *Table[E]) Command(cc *CommandContext[E])

func (*Table[E]) Commands

func (tab *Table[E]) Commands(ccs []*CommandContext[E])

func (*Table[E]) Dynamic

func (tab *Table[E]) Dynamic(f func(*Inserter[E]))

Dynamic replaces the current dynamically loaded commands in the table.

func (*Table[E]) Lookup

func (tab *Table[E]) Lookup(isprefix bool, payload string) (cc *CommandContext[E], argstart int)

Lookup returns the CommandContext entry if the given payload is a command.

Jump to

Keyboard shortcuts

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