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