package main

import (
	"fmt"
	"github.com/jzelinskie/geddit"
	"github.com/nlopes/slack"
	"io/ioutil"
)

func getSlackToken() string {
	dat, err := ioutil.ReadFile("slack-token")
	if err != nil {
		fmt.Println("Cannot read slack token")
		panic(err)
	}
	return string(dat)
}

func main() {
	session, err := geddit.NewLoginSession("login", "password", "gedditAgent v1")
	fmt.Println(session)
	fmt.Println(err)

	subOpts := geddit.ListingOptions{
		Limit: 10,
	}
	nnFeed, err := session.SubredditSubmissions("neuralnetworks", geddit.NewSubmissions, subOpts)
	fmt.Println(nnFeed)
}

package main

import (
	"fmt"
	"github.com/mgadzhi/slack-pechkin/reddit"
	"github.com/nlopes/slack"
	"io/ioutil"
	"strings"
)

func getSlackToken() string {
	dat, err := ioutil.ReadFile("slack-token")
	if err != nil {
		fmt.Println("Cannot read slack token")
		panic(err)
	}
	return strings.TrimSpace(string(dat))
}

func main() {
	r := reddit.NewReddit()
	submissions := r.GetLastSubmissions("programming")

	slackToken := getSlackToken()
	fmt.Println(slackToken)
	api := slack.New(slackToken)
	fmt.Println(api)
	postParams := slack.PostMessageParameters{
		AsUser: true,
	}
	for i, s := range submissions {
		fmt.Println(i, s)
		channelID, timestamp, err := api.PostMessage("main", s, postParams)
		fmt.Println(channelID, timestamp, err)
	}

}

Send 10 newest links from r/programming to slack
Send 10 newest links from r/programming to slack
