Skip to content

Instantly share code, notes, and snippets.

@178inaba
Created December 27, 2016 03:13
Show Gist options
  • Select an option

  • Save 178inaba/a0e7a725f005d59466ffdde096cca696 to your computer and use it in GitHub Desktop.

Select an option

Save 178inaba/a0e7a725f005d59466ffdde096cca696 to your computer and use it in GitHub Desktop.
Funny tweet for every day from "dayukoume".
package main
import (
"fmt"
"net/url"
"os"
"github.com/ChimeraCoder/anaconda"
log "github.com/Sirupsen/logrus"
)
func main() {
anaconda.SetConsumerKey("your-consumer-key")
anaconda.SetConsumerSecret("your-consumer-secret")
api := anaconda.NewTwitterApi("your-access-token", "your-access-token-secret")
v := url.Values{}
v.Set("screen_name", "dayukoume")
v.Set("count", "200")
v.Set("trim_user", "t")
v.Set("contributor_details", "false")
v.Set("include_rts", "false")
for {
tweets, err := api.GetUserTimeline(v)
if err != nil {
log.Fatal(err)
}
if len(tweets) == 0 {
os.Exit(0)
return
}
var maxID int64
for _, tweet := range tweets {
var isPrint bool
var htIndex int
for _, v := range tweet.Entities.Hashtags {
if v.Text == "まいにちチクショー" {
isPrint = true
htIndex = v.Indices[0]
}
}
if isPrint == true {
fmt.Println("--------------------------------------------------")
runes := []rune(tweet.Text)
fmt.Println(string(runes[:htIndex-1]))
}
maxID = tweet.Id
}
v.Set("max_id", fmt.Sprint(maxID-1))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment