mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-24 02:48:04 +00:00
feat: restructure plugin system, add Lua plugin support, update docs
This commit is contained in:
24
internal/plugin/dynamic_lua.go
Normal file
24
internal/plugin/dynamic_lua.go
Normal file
@ -0,0 +1,24 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
sdk "gitcode.com/JianFeeeee/HomeAgent/internal/sdk"
|
||||
)
|
||||
|
||||
// tryLoadLua 从插件目录加载 main.lua(Lua 插件)。
|
||||
// 返回 nil,nil 表示目录中没有 main.lua。
|
||||
func tryLoadLua(dir, name string, config map[string]interface{}) (sdk.Plugin, error) {
|
||||
luaPath := filepath.Join(dir, luaEntry)
|
||||
if _, err := os.Stat(luaPath); os.IsNotExist(err) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
plg, err := newLuaPlugin(luaPath, name)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("lua plugin %s: %w", name, err)
|
||||
}
|
||||
return plg, nil
|
||||
}
|
||||
Reference in New Issue
Block a user