MCPcopy Create free account
hub / github.com/chanify/chanify / DoCall

Method DoCall

logic/plugin.go:160–186  ·  view source on GitHub ↗
(l *lua.LState)

Source from the content-addressed store, hash-verified

158}
159
160func (w *Webhook) DoCall(l *lua.LState) error {
161 if w.lfunc == nil {
162 return ErrNotFound
163 }
164 lfunc := w.lfunc.lfunc
165 if lfunc == nil {
166 return ErrNotFound
167 }
168 initLua(l)
169 if ctx, ok := l.GetGlobal("ctx").(*lua.LUserData); ok {
170 if mtbl, ok := ctx.Metatable.(*lua.LTable); ok {
171 if ftbl, ok := mtbl.RawGetString("__index").(*lua.LTable); ok {
172 ftbl.RawSetString("env", l.NewFunction(func(ll *lua.LState) int {
173 key := strings.ToLower(ll.CheckString(2))
174 if val, ok := w.env[key]; ok {
175 ll.Push(luaInterface2LValue(val))
176 return 1
177 }
178 ll.Push(lua.LNil)
179 return 1
180 }))
181 }
182 }
183 }
184 l.Push(l.NewFunctionFromProto(lfunc))
185 return l.PCall(0, lua.MultRet, nil)
186}

Callers 2

TestWebHookDoCallFunction · 0.95
handlePostWebhookMethod · 0.80

Calls 3

initLuaFunction · 0.85
luaInterface2LValueFunction · 0.85
PushMethod · 0.65

Tested by 1

TestWebHookDoCallFunction · 0.76