plugin

package module
v0.0.0-...-e1719c2 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCache

func GetCache(key string) ([]byte, error)

GetCache retrieves a value from the cache by key

func GetStore

func GetStore(key string) ([]byte, error)

GetStore retrieves a value from the store by key (deprecated, use Storage().Get() instead)

func ListDirectory

func ListDirectory(path string) ([]string, error)

ListDirectory lists the contents of a directory within the plugin's data directory

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile reads a file from the host and returns its contents as bytes

func RegisterPlugin

func RegisterPlugin(p Plugin)

RegisterPlugin registers a plugin instance with the framework. This should be called from the plugin's main function.

func SendImage

func SendImage(recipient, imagePath string) error

SendImage sends an image to a recipient via WhatsApp

func SetCache

func SetCache(key string, value []byte) error

SetCache stores a value in the cache with the given key

func SetStore

func SetStore(key string, value []byte) error

SetStore stores a value in the store with the given key (deprecated, use Storage().Set() instead)

Types

type CLIInput

type CLIInput struct {
	Args []string `json:"args"`
}

CLIInput represents the input data passed to a plugin's CLI handler.

type CLIOutput

type CLIOutput struct {
	Success bool   `json:"success"`
	Output  string `json:"output,omitempty"`
	Error   string `json:"error,omitempty"`
}

CLIOutput represents the response from a plugin's CLI handler.

type CLIPlugin

type CLIPlugin interface {
	Plugin
	HandleCLI(input CLIInput) CLIOutput
}

CLIPlugin is an optional interface plugins can implement to expose CLI commands.

type ExecCommandRequest

type ExecCommandRequest struct {
	Command string `json:"command"`
	Stdin   string `json:"stdin,omitempty"`
}

ExecCommandRequest is the request payload for ExecCommand.

type ExecCommandResponse

type ExecCommandResponse struct {
	Success  bool   `json:"success"`
	Stdout   string `json:"stdout,omitempty"`
	Stderr   string `json:"stderr,omitempty"`
	ExitCode int    `json:"exit_code"`
	Error    string `json:"error,omitempty"`
}

ExecCommandResponse is the response from ExecCommand.

func ExecCommand

func ExecCommand(command, stdin string) (*ExecCommandResponse, error)

ExecCommand executes a whitelisted command on the host with optional stdin.

type HelpOutput

type HelpOutput struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Usage       string   `json:"usage"`
	Examples    []string `json:"examples"`
	Category    string   `json:"category"`
}

HelpOutput contains help information for a plugin

func NewHelpOutput

func NewHelpOutput(name, description, usage string, examples []string, category string) HelpOutput

NewHelpOutput creates a new HelpOutput with the given parameters

type Input

type Input struct {
	Message string      `json:"message"`
	Sender  string      `json:"sender"`
	Info    MessageInfo `json:"info"`
}

Input represents the input data passed to a plugin

type ListDirectoryResponse

type ListDirectoryResponse struct {
	Success bool     `json:"success"`
	Files   []string `json:"files,omitempty"`
	Error   string   `json:"error,omitempty"`
}

type MessageInfo

type MessageInfo struct {
	ID        string `json:"id"`
	Timestamp int64  `json:"timestamp"`
	PushName  string `json:"push_name"`
	IsGroup   bool   `json:"is_group"`
}

MessageInfo contains information about the incoming message

type Output

type Output struct {
	Success bool   `json:"success"`
	Error   string `json:"error,omitempty"`
	Reply   string `json:"reply,omitempty"`
}

Output represents the response from a plugin

func Error

func Error(message string) Output

Error creates an error output with an error message

func Success

func Success(reply string) Output

Success creates a successful output with a reply message

type Plugin

type Plugin interface {
	Name() string
	Topics() []string
	HandleMessage(input Input) Output
	GetHelp() HelpOutput
	GetRequiredEnvVars() []string
	Version() string
}

Plugin interface that plugin authors must implement

type Store

type Store interface {
	Get(key string) ([]byte, error)
	Set(key string, value []byte) error
	List(prefix string) ([]string, error)
}

Store interface for plugin storage operations

func Storage

func Storage() Store

Storage returns a Store interface for plugin storage operations

Jump to

Keyboard shortcuts

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