Пример #1
-1
func Secrets() Config {
	filename := "secrets.yaml"
	var config Config

	source, err := ioutil.ReadFile(filename)
	iffy.PanicIf(err)

	err = yaml.Unmarshal(source, &config)
	iffy.PanicIf(err)

	return config
}
Пример #2
-1
func RetrieveTweets(db *sql.DB) (beetTweets []BeetTweet) {
	query := fmt.Sprintf("SELECT * FROM tweet where NOTIFIED = false AND NOTIFICATIONTIME <= '%s';", time.Now().UTC().Format(time.RFC3339))

	rows, err := db.Query(query)

	beetTweets = []BeetTweet{}

	if err != nil {
		return
	}

	defer rows.Close()

	for rows.Next() {
		bt := BeetTweet{}

		err = rows.Scan(&bt.Id,
			&bt.ScreenName,
			&bt.Name,
			&bt.Hours,
			&bt.MentionTime,
			&bt.NotificationTime,
			&bt.Notified)

		iffy.PanicIf(err)

		bt.Name = strings.TrimSpace(bt.Name)
		bt.ScreenName = strings.TrimSpace(bt.ScreenName)
		beetTweets = append(beetTweets, bt)
	}
	return
}
Пример #3
-1
func GetMentions(api *anaconda.TwitterApi, db *sql.DB) (retrieved_tweets []anaconda.Tweet) {
	var lastMention int64
	v := url.Values{}
	v.Add("count", "200")
	v.Add("include_rts", "1")
	err := db.QueryRow("SELECT ID FROM tweet ORDER BY ID DESC LIMIT 1;").Scan(&lastMention)

	if err == nil {
		lastMentionStr := strconv.FormatInt(lastMention, 10)
		v.Add("since_id", lastMentionStr)
	}

	retrieved_tweets, err = api.GetMentionsTimeline(v)
	iffy.PanicIf(err)
	return
}
Пример #4
-1
func SetupDB() *sql.DB {
	db, err := sql.Open("postgres", connectionString())
	iffy.PanicIf(err)

	return db
}