chore: use XT_URI for seed
This commit is contained in:
parent
a3e6fc0c0f
commit
62229deec5
25
app.go
25
app.go
@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
@ -68,13 +70,24 @@ func run(ctx context.Context, c *console.C[args]) error {
|
||||
ctx, span := otel.Span(ctx)
|
||||
defer span.End()
|
||||
|
||||
f, err := os.Open(a.baseFeed)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
var inFile io.Reader
|
||||
|
||||
twtfile, err := lextwt.ParseFile(f, &types.Twter{
|
||||
if a.baseFeed != "" {
|
||||
f, err := os.Open(a.baseFeed)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
} else {
|
||||
res, err := http.Get(a.URI)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
inFile = res.Body
|
||||
defer res.Body.Close()
|
||||
}
|
||||
|
||||
twtfile, err := lextwt.ParseFile(inFile, &types.Twter{
|
||||
Nick: a.Nick,
|
||||
URI: a.URI,
|
||||
})
|
||||
|
2
main.go
2
main.go
@ -26,7 +26,7 @@ func main() {
|
||||
ctx, console := console.New(args{
|
||||
dbtype: env.Default("XT_DBTYPE", "sqlite3"),
|
||||
dbfile: env.Default("XT_DBFILE", "file:twt.db"),
|
||||
baseFeed: env.Default("XT_BASE_FEED", "feed"),
|
||||
baseFeed: env.Default("XT_BASE_FEED", ""),
|
||||
Nick: env.Default("XT_NICK", "xuu"),
|
||||
URI: env.Default("XT_URI", "https://txt.sour.is/user/xuu/twtxt.txt"),
|
||||
Listen: env.Default("XT_LISTEN", ":8080"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user