Example #1
0
//Retweet the tweet and store the fact that this has been done in Redis
//If the tweet has already been retweeted before, do nothing
func retweetAndLog(api anaconda.TwitterApi, tweet anaconda.Tweet) (err error) {
	already_retweeted, err := alreadyRetweeted(tweet)
	if err != nil {
		return err
	}

	//Only retweet (and log) if the tweet has not already been retweeted
	if !already_retweeted {
		if _, err = api.Retweet(tweet.Id, true); err != nil {
			return
		}

		if _, err = c.Do("SET", tweet.Id_str, strconv.FormatInt(time.Now().Unix(), 10)); err != nil {
			return
		}
		log.Printf("Set %s in redis", tweet.Id_str)

		return
	}

	return
}