package plugins import lua "github.com/yuin/gopher-lua" /* Plugin hooks: - Pre local message - Post local message - Pre external message (received but not processed by default stuff) - Post external message (received, internal processing done) - Post new local account - Pre new remote account discovered - Post new remote account discovered */ type pluginHolder struct { meta *PluginMetadata table *lua.LTable // ---- Section hooks postLocalMessage *lua.LFunction postExternalMessage *lua.LFunction postNewLocalAccount *lua.LFunction postRemoteAccountDiscovered *lua.LFunction // preLocalMessage *lua.LFunction // preExternalMessage *lua.LFunction // Might not want this // preRemoteAccountDiscovered *lua.LFunction } type PluginMetadata struct { Name string `json:"name"` Version string `json:"version"` // Don't load major and minor versions from meta file, calc from full version instead Major int `json:"-"` Minor int `json:"-"` Source string `json:"source"` License string `json:"license"` Hashes map[string]string `json:"hashes"` EntryFile string `json:"entry"` HookNames map[string]string `json:"hook_names"` } const ( HookPostLocalMessage = "post-local-message" HookPostExternalMessage = "post-external-message" HookPostNewLocalAccount = "post-new-local-account" HookPostRemoteAccountDiscovered = "post-remote-account-discovered" ) // TODO: Figure out signature func (p *pluginHolder) PostLocalMessage(l *lua.LState) error { // Only act on the hook if a hook exists if p.postLocalMessage != nil { err := l.CallByParam(lua.P{ Fn: p.postLocalMessage, NRet: 1, // TODO: Adjust based on signature Protect: true, }) // TODO: Translate signature arguments into LValues and include here if err != nil { return err } // TODO: Translate args on stack back into whats expected from the signature panic("not implemented") } return nil }