Documentation
¶
Index ¶
- Constants
- func ClientHelp()
- func OnEvent(event string, tag string, run func(), repeat bool) bool
- func RaiseEvent(event string)
- func RemoveHandler(event string, tag string)
- type Client
- func (c *Client) AddAction(rs string, cmd func(*Trigger)) *Trigger
- func (c *Client) AddActionCmd(t *Trigger)
- func (c *Client) AddActionString(rs string, cmd string) *Trigger
- func (c *Client) AddActionTrigger(t *Trigger)
- func (c *Client) AddAlias(rs string, cmd func(*Trigger)) *Trigger
- func (c *Client) AddAliasCmd(t *Trigger)
- func (c *Client) AddAliasString(rs string, cmd string) *Trigger
- func (c *Client) AddAliasTrigger(t *Trigger)
- func (c *Client) AddCommand(name string, r string, f func(*Trigger), sh string, lh string) *Command
- func (c *Client) AddFunction(name string, f func(t *Trigger))
- func (c *Client) BaseActionCmd(t *Trigger)
- func (c *Client) BaseAliasCmd(t *Trigger)
- func (c *Client) CaptureCmd(t *Trigger)
- func (c *Client) ChatCmd(t *Trigger)
- func (c *Client) CheckCommand(text string)
- func (c *Client) CheckTriggers(list []*Trigger, text string) []*Trigger
- func (c *Client) ClearWindow(window string)
- func (c *Client) Close()
- func (c *Client) ConnectCmd(t *Trigger)
- func (c *Client) FuncCmd(t *Trigger)
- func (c *Client) GetWindowSize(name string) (int, int)
- func (c *Client) LoadPlugin(name string, p *Config)
- func (c *Client) LoopCmd(t *Trigger)
- func (c *Client) MatchCmd(t *Trigger)
- func (c *Client) MemStatsCmd(t *Trigger)
- func (c *Client) NewTrigger(re string, cmd func(*Trigger)) *Trigger
- func (c *Client) Parse(text string)
- func (c *Client) Print(text string)
- func (c *Client) PrintBytesTo(window string, b []byte)
- func (c *Client) PrintTimestamp(w, s string)
- func (c *Client) PrintTo(window string, text string)
- func (c *Client) ReadConfigCmd(path string)
- func (c *Client) Run()
- func (c *Client) SendNow(text string)
- func (c *Client) UnactionCmd(t *Trigger)
- func (c *Client) UnaliasCmd(t *Trigger)
- func (c *Client) Write(b []byte) (int, error)
- type Command
- type Config
- type Grid
- type GzLogger
- type TUI
- type Trigger
- type Window
Constants ¶
const BUFFERSIZE = 1024 * 1024
const (
DEADLINE = time.Millisecond * 10
)
const MAX_CONTENT = 2000
number of lines to save
Variables ¶
This section is empty.
Functions ¶
func ClientHelp ¶
func ClientHelp()
func OnEvent ¶
OnEvent executes the function f when the event with the corresponding string is raised. If tag is not "" then the function is only added if the tag is not already in the list. Returns true if the event is added, false if already in the queue. Tags must be unique.
func RaiseEvent ¶
func RaiseEvent(event string)
RaiseEvent executes all enabled handlers for the given event. If a handler is marked to repeat it is re-added.
func RemoveHandler ¶
Types ¶
type Client ¶
type Client struct { // Publicly available variables Ignore bool Gag bool RawLine []byte TextLine []byte Var map[string]string MatchCount int // contains filtered or unexported fields }
Client stores state and provides methods for interacting with the client application.
func NewClient ¶
func NewClient() *Client
Returns a new client with default configuration and initialized variables
func (*Client) AddAction ¶
AddAction adds an action to the client based on the provided regex `rs` and the function to execute `cmd`
func (*Client) AddActionCmd ¶
func (*Client) AddActionTrigger ¶
AddActionTrigger adds an action to the client based on the provided trigger
func (*Client) AddAliasCmd ¶
func (*Client) AddAliasTrigger ¶
func (*Client) AddCommand ¶
NewCommand adds a command to the client. The command starts with the defined metacharacter, default '#'. Each command provides a name which is a single word that follows the metacharacter, a list of strings that will be converted into regular expressions that will be run against the command arguments, a short help string and a long help string. Returns nil on error. Pass "" as regex for no arguments.
func (*Client) AddFunction ¶
AddFunction maps a string to a function so that you can call the function from the mud with #function <name>
func (*Client) BaseActionCmd ¶
func (*Client) BaseAliasCmd ¶
func (*Client) CaptureCmd ¶
func (*Client) CheckCommand ¶
If the leading character of a string is the metaCharacter then we check for a valid command
func (*Client) CheckTriggers ¶
func (*Client) ClearWindow ¶
func (*Client) ConnectCmd ¶
ConnectCmd takes a string from the user and attempts to ConnectCmd to the mud server. If the connection is successful then a goroutine is launched to handle the connection.
func (*Client) LoadPlugin ¶
func (*Client) MemStatsCmd ¶
func (*Client) NewTrigger ¶
NewAction provides a pointer to an action and ensures that all variables are initialized. Returns nil if the provided regex is invalid.
func (*Client) PrintBytesTo ¶
func (*Client) PrintTimestamp ¶
func (*Client) ReadConfigCmd ¶
func (*Client) UnactionCmd ¶
func (*Client) UnaliasCmd ¶
type Command ¶
type Command struct { Name string // contains filtered or unexported fields }
A command is a special string parsed from the input line that executes client functionality instead of being parsed as an alias or being passed directly to the MUD
type Config ¶
type Config struct { Actions map[string]string `yaml:"actions"` // Actions to be registered Aliases map[string]string `yaml:"aliases"` // Aliases to be registered Grid Grid `yaml:"grid"` Windows map[string]Window `yaml:"windows"` // Windows to be registered Functions map[string]func(*Trigger) CredentialFile string `yaml:"credentialfile"` AutoLogin string `yaml:"autologin"` }
func ReadConfig ¶
Load a plugin from a YAML config file
type TUI ¶
type TUI struct { Windows map[string]*window // contains filtered or unexported fields }
func (*TUI) ClearWindow ¶
func (*TUI) FixInputLine ¶
func (*TUI) PrintBytes ¶
type Trigger ¶
type Trigger struct { *regexp.Regexp // Results map named groups to the values captured in the group Results map[string]string // Matches contains a list of matches and group matches Matches []string // Enabled determines if the action is compared to incoming text or skipped Enabled bool // contains filtered or unexported fields }
Trigger is the base struct used for Actions and Aliases. It matches against text and executes a function when there is a match. It provides convenience functions to enable or disable itself as well as gathering named groups from the regex into a map.
var FuncTrigger *Trigger