@@ -36,6 +36,7 @@ func main() {
|
||||
addr string
|
||||
mdbf string
|
||||
public string
|
||||
img string
|
||||
// discord
|
||||
tokenFile string
|
||||
apiRoute string
|
||||
@@ -47,6 +48,7 @@ func main() {
|
||||
flag.StringVar(&addr, "http", ":13669", "`address` to bind HTTP server")
|
||||
flag.StringVar(&mdbf, "mdb", "", "`path` to master.mdb")
|
||||
flag.StringVar(&public, "public", "", "`dir`ectory containing the website to serve")
|
||||
flag.StringVar(&img, "img", "", "`dir`ectory to save and serve images")
|
||||
flag.StringVar(&tokenFile, "token", "", "`file` containing the Discord bot token")
|
||||
flag.StringVar(&apiRoute, "route", "/interactions/callback", "`path` to serve Discord HTTP API calls")
|
||||
flag.StringVar(&pubkey, "key", "", "Discord public key")
|
||||
@@ -86,6 +88,17 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if img != "" {
|
||||
// Ensure the img directory is in fact a directory
|
||||
// before we start trying to fill it out.
|
||||
err := os.MkdirAll(img, 0777)
|
||||
if err != nil {
|
||||
slog.Error("img", slog.Any("err", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
go saveImgs(ctx, db, img)
|
||||
}
|
||||
|
||||
var client *bot.Client
|
||||
if tokenFile != "" {
|
||||
skills, err := mdb.Skills(ctx, db)
|
||||
@@ -128,6 +141,9 @@ func main() {
|
||||
if public != "" {
|
||||
mux.Handle("GET /", httpmiddle.Compress(5)(http.FileServerFS(os.DirFS(public))))
|
||||
}
|
||||
if img != "" {
|
||||
mux.Handle("GET /img/", http.StripPrefix("/img", http.FileServerFS(os.DirFS(img))))
|
||||
}
|
||||
mux.Handle("GET /api/global/affinity", httpmiddle.Compress(5)(dataroute(ctx, db, mdb.AffinitySummary)))
|
||||
mux.Handle("GET /api/global/affinity-detail", httpmiddle.Compress(5)(dataroute(ctx, db, mdb.AffinityDetail)))
|
||||
mux.Handle("GET /api/global/character", httpmiddle.Compress(5)(dataroute(ctx, db, mdb.Characters)))
|
||||
|
||||
Reference in New Issue
Block a user