Exemplo n.º 1
0
// 自分のTimelineを表示する。
func GetHomeTimeline(api *anaconda.TwitterApi, v url.Values) {
	tweets, err := api.GetHomeTimeline(v)
	check(err)
	for _, tweet := range tweets {
		PrintTweet(tweet)
	}
}
Exemplo n.º 2
0
func checkForTweets(api anaconda.TwitterApi) error {
	searchResult, err := api.GetHomeTimeline()
	if err != nil {
		log.Print("error fetching timeline: %v", err)
		return err
	}
	//Assume that we haven't tweeted at each other more than 10 times since the last check
	//Knowing us, this is a very bad assumption.

	log.Printf("We have %d results", len(searchResult))
	//Iterate over the tweets in chronological order (the reverse order from what is returned)
	for i := len(searchResult) - 1; i >= 0; i-- {
		tweet := searchResult[i]
		if TweetMentionsATarget(tweet) {
			if err := retweetAndLog(api, tweet); err != nil {
				log.Print("error when retweeting %v", err)
				continue
			}
			log.Print(tweet.Text)
		} else {
			//log.Printf("Skipping tweet %v", tweet.Text)
		}
	}
	return nil
}
Exemplo n.º 3
0
func updateTimeline(api *an.TwitterApi) []an.Tweet {
	v := url.Values{}
	home, err := api.GetHomeTimeline(v)
	if err != nil {
		fmt.Println("error: ", err)
	}
	return home
}
Exemplo n.º 4
0
func showTimeLine(api *anaconda.TwitterApi, v url.Values) {
	tweets, err := api.GetHomeTimeline(v)
	if err != nil {
		panic(err)
	}
	for _, tweet := range tweets {
		fmt.Println("tweet: ", tweet.Text)
		fmt.Println("id: ", tweet.Id)
	}
}