add doc for schema generation
This commit is contained in:
@ -16,27 +16,65 @@ const NoLimit FeedLimit = -1
|
||||
type FeedURL []string
|
||||
|
||||
type FeedCfg struct {
|
||||
Name string `yaml:"name"`
|
||||
Channel string `yaml:"channel"`
|
||||
Rhash string `yaml:"rhash"`
|
||||
Url FeedURL `yaml:"url"`
|
||||
Cron string `yaml:"cron"`
|
||||
Proxy string `yaml:"proxy"`
|
||||
Type parser.FeedType `yaml:"type"`
|
||||
Title string `yaml:"title"`
|
||||
FTL *int `yaml:"first_time_limit"`
|
||||
FirstTimeLimit FeedLimit `yaml:"-"`
|
||||
// Unique identifier for the feed. Used as filename, so keep it simple
|
||||
Name string `yaml:"name" jsonschema:"required"`
|
||||
|
||||
// Telegram channel name in the form "@foobar" or "-1004242442" (private)
|
||||
Channel string `yaml:"channel" jsonschema:"required"`
|
||||
|
||||
// Telegram instant view rhash id, see https://instantview.telegram.org/#publishing-templates
|
||||
Rhash string `yaml:"rhash" jsonschema:"default="`
|
||||
|
||||
// Feed Url, string or array of strings
|
||||
// If array, all entries are merged, e.g ["https://example.com/blog/tag/foo/feed", "https://example.com/blog/tag/bar/feed" ]
|
||||
Url FeedURL `yaml:"url" jsonschema:"required,oneof_type=string;array"`
|
||||
|
||||
// Cron expression, see https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format
|
||||
Cron string `yaml:"cron" jsonschema:"required"`
|
||||
|
||||
// Proxy for this feed if different from global
|
||||
Proxy string `yaml:"proxy" jsonschema:"default=<global proxy>"`
|
||||
|
||||
// Rss or Atom feed
|
||||
Type parser.FeedType `yaml:"type" jsonschema:"required,enum=rss,enum=atom"`
|
||||
|
||||
// Text of the link sent to telegram,
|
||||
Title string `yaml:"title" jsonschema:"default=Link"`
|
||||
|
||||
// Number of entries to process when the feed is seen for the first time
|
||||
FTL *int `yaml:"first_time_limit" jsonschema:"default=<global value>"`
|
||||
|
||||
FirstTimeLimit FeedLimit `yaml:"-"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Proxy string `yaml:"proxy"`
|
||||
TelegramProxy string `yaml:"telegram_proxy"`
|
||||
TelegramAuthToken string `yaml:"telegram_auth_token"` //TODO: read from credential file
|
||||
DataDir string `yaml:"data_dir"`
|
||||
LastSuccessPath string `yaml:"last_loaded_path"`
|
||||
DbDir string `yaml:"db_dir"`
|
||||
FTL *int `yaml:"first_time_limit"`
|
||||
Feeds []FeedCfg `yaml:"feeds"`
|
||||
// default proxy url that http.Client can understand
|
||||
// or socks5://unix/path/to/sock for socks proxy over unix socket
|
||||
// empty for no proxy
|
||||
Proxy string `yaml:"proxy" jsonschema:"default="`
|
||||
|
||||
// proxy for telegram if different from default
|
||||
// NONE to not use global default
|
||||
TelegramProxy string `yaml:"telegram_proxy" jsonschema:"default=<global proxy>"`
|
||||
|
||||
// Auth token for telegram in the form of 424242424:AB02132skdcjlisjkjflewjlfkjslkfHHXX
|
||||
TelegramAuthToken string `yaml:"telegram_auth_token" jsonschema:"required"` //TODO: read from credential file
|
||||
|
||||
// Base directory to write feed data and schedule file
|
||||
DataDir string `yaml:"data_dir" jsonschema:"default=./"`
|
||||
|
||||
// Path to the file where last success time for each feed is saved
|
||||
LastSuccessPath string `yaml:"last_loaded_path" jsonschema:"default=<datadir>/last_success.yml"`
|
||||
|
||||
// Path to the directory where feed content is saved
|
||||
DbDir string `yaml:"db_dir" jsonschema:"default=<datadir>/feed_data"`
|
||||
|
||||
// Number of entries to process when the feed is seen for the first time
|
||||
// -1 means no limit
|
||||
FTL *int `yaml:"first_time_limit" jsonschema:"default=-1"`
|
||||
|
||||
// Feed config
|
||||
Feeds []FeedCfg `yaml:"feeds" jsonschema:"required"`
|
||||
}
|
||||
|
||||
func ParseConfig(configPath string) (*Config, error) {
|
||||
|
Reference in New Issue
Block a user