mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-28 08:06:24 -07:00
Add http requests and await/async to Lua plugins
This commit is contained in:
parent
08fc8d5507
commit
8f9e64eb8e
3 changed files with 10 additions and 0 deletions
2
go.mod
2
go.mod
|
@ -23,6 +23,8 @@ require (
|
|||
)
|
||||
|
||||
require (
|
||||
github.com/CuberL/glua-async v0.0.0-20190614102843-43f22221106d // indirect
|
||||
github.com/cjoudrey/gluahttp v0.0.0-20201111170219-25003d9adfa9 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
|
|
4
go.sum
4
go.sum
|
@ -1,3 +1,5 @@
|
|||
github.com/CuberL/glua-async v0.0.0-20190614102843-43f22221106d h1:lGZoWyUkx8m8e0LsP9hSv0zcK/f5ffJEEYo+B0RIJFM=
|
||||
github.com/CuberL/glua-async v0.0.0-20190614102843-43f22221106d/go.mod h1:9LzvPuiPyVXXFvHZCKOCvXxy1KkFADRmePZJDFuuFgE=
|
||||
github.com/Eggbertx/durationutil v1.0.0 h1:/DJo6z/9tac/1KTwa/RGjpg5Q8Rrnx3p5w4OxKdeTkw=
|
||||
github.com/Eggbertx/durationutil v1.0.0/go.mod h1:eOfcV0W5B4qoKsEtjhOYUTsTm6KnrWVkfgOmMTC4XnY=
|
||||
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
|
||||
|
@ -18,6 +20,8 @@ github.com/cheggaaa/pb/v3 v3.0.5/go.mod h1:X1L61/+36nz9bjIsrDU52qHKOQukUQe2Ge+Yv
|
|||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/cjoudrey/gluahttp v0.0.0-20201111170219-25003d9adfa9 h1:rdWOzitWlNYeUsXmz+IQfa9NkGEq3gA/qQ3mOEqBU6o=
|
||||
github.com/cjoudrey/gluahttp v0.0.0-20201111170219-25003d9adfa9/go.mod h1:X97UjDTXp+7bayQSFZk2hPvCTmTZIicUjZQRtkwgAKY=
|
||||
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"plugin"
|
||||
"reflect"
|
||||
|
||||
"github.com/cjoudrey/gluahttp"
|
||||
"github.com/gochan-org/gochan/pkg/config"
|
||||
"github.com/gochan-org/gochan/pkg/events"
|
||||
"github.com/gochan-org/gochan/pkg/gcsql"
|
||||
|
@ -21,6 +22,7 @@ import (
|
|||
"github.com/gochan-org/gochan/pkg/server/serverutil"
|
||||
"github.com/rs/zerolog"
|
||||
|
||||
async "github.com/CuberL/glua-async"
|
||||
luaFilePath "github.com/vadv/gopher-lua-libs/filepath"
|
||||
luaStrings "github.com/vadv/gopher-lua-libs/strings"
|
||||
lua "github.com/yuin/gopher-lua"
|
||||
|
@ -126,6 +128,8 @@ func luaEventRegisterHandlerAdapter(l *lua.LState, fn *lua.LFunction) events.Eve
|
|||
func preloadLua() {
|
||||
luaFilePath.Preload(lState)
|
||||
luaStrings.Preload(lState)
|
||||
lState.PreloadModule("http", gluahttp.NewHttpModule(&http.Client{}).Loader)
|
||||
async.Init(lState)
|
||||
|
||||
lState.PreloadModule("config", func(l *lua.LState) int {
|
||||
t := l.NewTable()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue