lure-updater/internal/builtins/register.go

50 lines
1.5 KiB
Go
Raw Normal View History

2023-06-09 17:54:15 +00:00
/*
* LURE Updater - Automated updater bot for LURE packages
* Copyright (C) 2023 Elara Musayelyan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2023-06-09 17:48:46 +00:00
package builtins
import (
"net/http"
2023-10-08 00:35:22 +00:00
"lure.sh/lure-updater/internal/config"
2023-06-09 17:48:46 +00:00
"go.etcd.io/bbolt"
"go.starlark.net/starlark"
"go.starlark.net/starlarkjson"
)
type Options struct {
Name string
DB *bbolt.DB
Config *config.Config
Mux *http.ServeMux
}
func Register(sd starlark.StringDict, opts *Options) {
sd["run_every"] = starlark.NewBuiltin("run_every", runEvery)
sd["sleep"] = starlark.NewBuiltin("sleep", sleep)
sd["http"] = httpModule
sd["regex"] = regexModule
sd["store"] = storeModule(opts.DB, opts.Name)
sd["updater"] = updaterModule(opts.Config)
sd["log"] = logModule(opts.Name)
sd["json"] = starlarkjson.Module
2023-06-22 21:53:42 +00:00
sd["utils"] = utilsModule
2023-06-25 20:07:38 +00:00
sd["html"] = htmlModule
2023-06-09 17:48:46 +00:00
sd["register_webhook"] = registerWebhook(opts.Mux, opts.Config, opts.Name)
}