feat: finish YAML
ci/woodpecker/push/goreleaser Pipeline was successful Details
ci/woodpecker/pr/goreleaser Pipeline failed Details

Signed-off-by: jolheiser <john.olheiser@gmail.com>
pull/7/head
jolheiser 2022-11-07 22:12:57 -06:00
parent 84e3f0840a
commit 0b8f4b85bd
Signed by: jolheiser
GPG Key ID: B853ADA5DA7BBF7A
5 changed files with 41 additions and 31 deletions

View File

@ -38,7 +38,7 @@ type SubReddit struct {
BodyBlocklist []string `yaml:"body_blocklist"`
BodyBlocklistRe []*regexp.Regexp `yaml:"-"`
BodyLimit int `yaml:"body_limit"`
Webhook string `yaml:"webhook"`
Webhooks []string `yaml:"webhooks"`
}
func (r *RedditConfig) UserAgent() string {

View File

@ -15,5 +15,5 @@ type Filter struct {
FollowStrict bool `yaml:"follow_strict"`
Locations []string `yaml:"locations"`
Tracks []string `yaml:"tracks"`
Webhook string `yaml:"webhook"`
Webhooks []string `yaml:"webhooks"`
}

View File

@ -8,11 +8,10 @@ import (
"strings"
"time"
"github.com/rs/zerolog/log"
"github.com/turnage/graw"
"go.jolheiser.com/lurk/config"
"github.com/rs/zerolog/log"
"github.com/turnage/graw"
"github.com/turnage/graw/reddit"
"go.jolheiser.com/disco"
)
@ -69,26 +68,23 @@ func (r *Reddit) Post(p *reddit.Post) error {
},
}
if sub.Webhook == "" {
log.Error().Msgf("no webhook for %s", p.Subreddit)
return nil
}
for _, webhook := range sub.Webhooks {
req, err := e.Request(context.Background(), webhook)
if err != nil {
log.Err(err).Msg("")
continue
}
req, err := e.Request(context.Background(), sub.Webhook)
if err != nil {
log.Err(err).Msg("")
return nil
}
resp, err := httpClient.Do(req)
if err != nil {
log.Err(err).Msg("")
continue
}
resp, err := httpClient.Do(req)
if err != nil {
log.Err(err).Msg("")
return nil
}
if resp.StatusCode != http.StatusNoContent {
log.Error().Msgf(resp.Status)
return nil
if resp.StatusCode != http.StatusNoContent {
log.Error().Msgf(resp.Status)
continue
}
}
return nil

View File

@ -3,12 +3,12 @@ package handler
import (
"context"
"fmt"
"github.com/rs/zerolog/log"
"net/http"
"go.jolheiser.com/lurk/config"
"github.com/dghubble/go-twitter/twitter"
"github.com/rs/zerolog/log"
"go.jolheiser.com/disco"
)
@ -57,7 +57,22 @@ func (t *Twitter) Tweet(tweet *twitter.Tweet) {
AvatarURL: tweet.User.ProfileImageURLHttps,
Content: fmt.Sprintf("https://twitter.com/%d/status/%d", tweet.User.ID, tweet.ID),
}
if _, err := w.Send(context.Background(), t.Filter.Webhook); err != nil {
log.Err(err).Msg("")
for _, webhook := range t.Filter.Webhooks {
req, err := w.Request(context.Background(), webhook)
if err != nil {
log.Err(err).Msg("")
continue
}
resp, err := httpClient.Do(req)
if err != nil {
log.Err(err).Msg("")
continue
}
if resp.StatusCode != http.StatusNoContent {
log.Error().Msgf(resp.Status)
continue
}
}
}

View File

@ -8,15 +8,14 @@ import (
"syscall"
"time"
"github.com/peterbourgon/ff/v3"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"go.jolheiser.com/lurk/config"
"go.jolheiser.com/lurk/handler"
"github.com/dghubble/go-twitter/twitter"
"github.com/dghubble/oauth1"
"github.com/peterbourgon/ff/v3"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/turnage/graw/reddit"
)