feat!: poll/hops configurable
So, `-p` went away! Also drop unused Config option (KeyPair).
This commit is contained in:
parent
4a3064a750
commit
8902009d92
|
@ -38,11 +38,15 @@ feed: https://openrss.org/opencollective.com/secure-scuttlebutt-consortium/updat
|
||||||
# the RSS feed profile avatar URL (will be converted to blob)
|
# the RSS feed profile avatar URL (will be converted to blob)
|
||||||
avatar: https://images.opencollective.com/secure-scuttlebutt-consortium/676f245/logo/256.png
|
avatar: https://images.opencollective.com/secure-scuttlebutt-consortium/676f245/logo/256.png
|
||||||
|
|
||||||
|
# RSS feed poll frequency (minutes)
|
||||||
|
poll: 5
|
||||||
|
|
||||||
# the internal go-sbot configuration options
|
# the internal go-sbot configuration options
|
||||||
addr: localhost
|
addr: localhost
|
||||||
port: 8008
|
port: 8008
|
||||||
ws-port: 8989
|
ws-port: 8989
|
||||||
shs-cap: "1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s="
|
shs-cap: "1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s="
|
||||||
|
hops: 1
|
||||||
```
|
```
|
||||||
|
|
||||||
Run it:
|
Run it:
|
||||||
|
@ -58,7 +62,7 @@ for reading & sharing with the broader SSB ecosystem.
|
||||||
|
|
||||||
`rss-butt-plug` generates an invite every time it runs which you can use to
|
`rss-butt-plug` generates an invite every time it runs which you can use to
|
||||||
invite clients with. Feeds will be polled every 5 minutes by default, you can
|
invite clients with. Feeds will be polled every 5 minutes by default, you can
|
||||||
configure this with `-p`.
|
configure this.
|
||||||
|
|
||||||
## Limitations :stop_sign:
|
## Limitations :stop_sign:
|
||||||
|
|
||||||
|
|
|
@ -32,14 +32,15 @@ import (
|
||||||
|
|
||||||
// Config is a rss-butt-plug config file.
|
// Config is a rss-butt-plug config file.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
DataDir string `yaml:"data-dir"`
|
DataDir string `yaml:"data-dir"`
|
||||||
Feed string `yaml:"feed"`
|
Feed string `yaml:"feed"`
|
||||||
Addr string `yaml:"addr"`
|
Addr string `yaml:"addr"`
|
||||||
Port string `yaml:"port"`
|
Port string `yaml:"port"`
|
||||||
WsPort string `yaml:"ws-port"`
|
WsPort string `yaml:"ws-port"`
|
||||||
ShsCap string `yaml:"shs-cap"`
|
ShsCap string `yaml:"shs-cap"`
|
||||||
KeyPair ssb.KeyPair `yaml:"key-pair,omitempty"`
|
Hops uint `yaml:"hops"`
|
||||||
Avatar string `yaml:"avatar,omitempty"`
|
Poll int `yaml:"poll"`
|
||||||
|
Avatar string `yaml:"avatar,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Post is a ssb post message.
|
// Post is a ssb post message.
|
||||||
|
@ -64,6 +65,8 @@ addr: localhost
|
||||||
port: 8008
|
port: 8008
|
||||||
ws-port: 8989
|
ws-port: 8989
|
||||||
shs-cap: "1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s="
|
shs-cap: "1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s="
|
||||||
|
hops: 1
|
||||||
|
poll: 5
|
||||||
avatar: https://images.opencollective.com/secure-scuttlebutt-consortium/676f245/logo/256.png
|
avatar: https://images.opencollective.com/secure-scuttlebutt-consortium/676f245/logo/256.png
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
@ -72,7 +75,6 @@ Arguments:
|
||||||
Options:
|
Options:
|
||||||
-h output help
|
-h output help
|
||||||
-c path to config file
|
-c path to config file
|
||||||
-p feed poll frequency in minutes
|
|
||||||
`
|
`
|
||||||
|
|
||||||
// maxPostLength is a post limit set by rss-butt-plug which is smaller than the
|
// maxPostLength is a post limit set by rss-butt-plug which is smaller than the
|
||||||
|
@ -83,13 +85,11 @@ const maxPostLength = 7000
|
||||||
var helpFlag bool
|
var helpFlag bool
|
||||||
var debugFlag bool
|
var debugFlag bool
|
||||||
var configFlag string
|
var configFlag string
|
||||||
var pollFrequencyFlag int
|
|
||||||
|
|
||||||
// handleCliFlags parses CLI flags.
|
// handleCliFlags parses CLI flags.
|
||||||
func handleCliFlags() error {
|
func handleCliFlags() error {
|
||||||
flag.BoolVar(&helpFlag, "h", false, "output help")
|
flag.BoolVar(&helpFlag, "h", false, "output help")
|
||||||
flag.StringVar(&configFlag, "c", "rss-butt-plug.yaml", "config file")
|
flag.StringVar(&configFlag, "c", "rss-butt-plug.yaml", "config file")
|
||||||
flag.IntVar(&pollFrequencyFlag, "p", 5, "feed poll frequency in minutes")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -287,7 +287,7 @@ func newSbot(cfg Config) (*sbot.Sbot, error) {
|
||||||
sbot.EnableAdvertismentBroadcasts(true),
|
sbot.EnableAdvertismentBroadcasts(true),
|
||||||
sbot.EnableAdvertismentDialing(true),
|
sbot.EnableAdvertismentDialing(true),
|
||||||
sbot.LateOption(sbot.WithUNIXSocket()),
|
sbot.LateOption(sbot.WithUNIXSocket()),
|
||||||
sbot.WithHops(2),
|
sbot.WithHops(cfg.Hops),
|
||||||
sbot.WithListenAddr(fmt.Sprintf(":%s", cfg.Port)),
|
sbot.WithListenAddr(fmt.Sprintf(":%s", cfg.Port)),
|
||||||
sbot.WithRepoPath(dataDir),
|
sbot.WithRepoPath(dataDir),
|
||||||
sbot.WithWebsocketAddress(fmt.Sprintf(":%s", cfg.WsPort)),
|
sbot.WithWebsocketAddress(fmt.Sprintf(":%s", cfg.WsPort)),
|
||||||
|
@ -555,7 +555,6 @@ func main() {
|
||||||
|
|
||||||
log.Print("main: bootstrapped internally managed go-sbot")
|
log.Print("main: bootstrapped internally managed go-sbot")
|
||||||
|
|
||||||
cfg.KeyPair = pub.KeyPair
|
|
||||||
feed, err := parseRSSFeed(cfg.Feed)
|
feed, err := parseRSSFeed(cfg.Feed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
@ -601,8 +600,8 @@ func main() {
|
||||||
log.Printf("main: pub invite: %s", token)
|
log.Printf("main: pub invite: %s", token)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
log.Printf("main: going to sleep for %d minutes...", pollFrequencyFlag)
|
log.Printf("main: going to sleep for %d minutes...", cfg.Poll)
|
||||||
time.Sleep(time.Duration(pollFrequencyFlag) * time.Minute)
|
time.Sleep(time.Duration(cfg.Poll) * time.Minute)
|
||||||
log.Printf("main: waking up to poll %s for new posts", cfg.Feed)
|
log.Printf("main: waking up to poll %s for new posts", cfg.Feed)
|
||||||
|
|
||||||
posts, err := messagesFromLog(pub)
|
posts, err := messagesFromLog(pub)
|
||||||
|
|
Loading…
Reference in New Issue