added some command flags and parsing for them

added log package
master
Zachary Epps 4 years ago
parent 08af79e03c
commit 82eee17d11
  1. 33
      main.go

@ -7,6 +7,8 @@ import (
"github.com/turnage/graw"
"github.com/turnage/graw/reddit"
"strings"
"log"
"flag"
)
type Crossposter struct {
@ -15,8 +17,9 @@ type Crossposter struct {
func (p *Crossposter) Post(post *reddit.Post) error {
if post.NSFW && !post.IsSelf {
// this is where we post to mastodon
fmt.Println(post.Title)
// this is where we download the image if we can and post to mastodon
// if it isn't a direct image link then we just post the link with the title
} else {
return nil
@ -26,12 +29,32 @@ func (p *Crossposter) Post(post *reddit.Post) error {
}
func main() {
redditBot, err := reddit.NewBotFromAgentFile("poster.agent", 0)
var ClientSecret, ClientKey, AccessToken, MastoConfigFile, RedditConfigFile string
flag.StringVar(&MastoConfigFile, "mc", "", "relative file path to file containing mastodon client/user tokens")
flag.StringVar(&RedditConfigFile, "rc", "", "relative file path to file containing reddit client tokens")
if MastoConfigFile == "" {
flag.StringVar(&ClientSecret, "ms", "",
"mastodon client secret, needs to be supplied if mastodon config file isn't specified")
flag.StringVar(&ClientKey, "mk", "",
"mastodon client key, needs to be supplied if mastodon config file isn't specified")
} else {
// parse mastodon config file here
}
if err != nil {
fmt.Println("failed to create reddit bot")
if RedditConfigFile == "" || ClientSecret == "" || ClientKey == "" {
flag.Usage()
return
}
if redditBot, err := reddit.NewBotFromAgentFile(RedditConfigFile, 0); err != nil {
log.Fatal("failed to create the reddit bot")
} else {
redditCfg := graw.Config{Subreddits: []string{"Overwatch_Porn"}}
}

Loading…
Cancel
Save