homescript

package
v0.0.26-beta-rc.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitLogger

func InitLogger(logger *logrus.Logger)

func RunById

func RunById(username string, homescriptId string) (string, int, error)

Types

type Executor

type Executor struct {
	ScriptName string
	Username   string
	Output     string
}

func (*Executor) AddPerm

func (self *Executor) AddPerm(username string, permission string) error

func (*Executor) AddUser

func (self *Executor) AddUser(username string, password string, forename string, surname string) error

Adds a new user to the system If the user already exists, an error is returned

func (*Executor) DelPerm

func (self *Executor) DelPerm(username string, permission string) error

func (*Executor) DelUser

func (self *Executor) DelUser(username string) error

Deletes

func (Executor) Exec

func (self Executor) Exec(homescriptId string) (string, error)

Executes another Homescript based on its Id

func (*Executor) GetDate

func (self *Executor) GetDate() (int, int, int, int, int, int)

Returns the current time variables

func (*Executor) GetTemperature

func (self *Executor) GetTemperature() (int, error)

TODO: Will later be implemented, should return the temperature in Celsius

func (*Executor) GetUser

func (self *Executor) GetUser() string

Returns the name of the user who is currently running the script

func (*Executor) GetWeather

func (self *Executor) GetWeather() (string, error)

TODO: Will later be implemented, should return the weather as a human-readable string

func (*Executor) Log

func (self *Executor) Log(
	title string,
	description string,
	level interpreter.LogLevel,
) error

Adds a log entry to the internal logging system

func (*Executor) Notify

func (self *Executor) Notify(
	title string,
	description string,
	level interpreter.LogLevel,
) error

Sends a notification to the user who issues this command

func (*Executor) Play

func (self *Executor) Play(server string, mode string) error

Sends a mode request to a given radiGo server TODO: implement this feature

func (*Executor) Print

func (self *Executor) Print(args ...string)

Emulates printing to the console Instead, appends the provided message to the output of the executor Exists in order to return the script's output to the user

func (*Executor) Switch

func (self *Executor) Switch(switchId string, powerOn bool) error

Changes the power state of an arbitrary switch Checks if the switch exists, if the user is allowed to interact with switches and if the user has the matching switch-permission If a check fails, an error is returned

func (*Executor) SwitchOn

func (self *Executor) SwitchOn(switchId string) (bool, error)

Returns a boolean if the requested switch is on or off Returns an error if the provided switch does not exist

type HomescriptError

type HomescriptError struct {
	ErrorType string   `json:"errorType"`
	Location  Location `json:"location"`
	Message   string   `json:"message"`
}

func Run

func Run(username string, scriptLabel string, scriptCode string) (string, int, []HomescriptError)

Executes a given homescript as a given user, returns the output and a possible error slice

type Location

type Location struct {
	Filename string `json:"filename"`
	Line     uint   `json:"line"`
	Column   uint   `json:"column"`
	Index    uint   `json:"index"`
}

Jump to

Keyboard shortcuts

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