package main import ( luar "github.com/layeh/gopher-luar" lua "github.com/yuin/gopher-lua" "gopkg.in/telegram-bot-api.v4" ) func preloadTG(L *lua.LState) { L.PreloadModule("telegram", loadTelegram) } var tgapi = map[string]lua.LGFunction{ "newMessage": tgNewMessage, } func loadTelegram(L *lua.LState) int { t := L.NewTable() L.SetFuncs(t, tgapi) L.Push(t) return 1 } func tgNewMessage(L *lua.LState) int { chatid := L.CheckInt64(1) text := L.CheckString(2) L.Push(luar.New(L, tgbotapi.NewMessage(chatid, text))) return 1 }