Created
December 27, 2016 03:13
-
-
Save 178inaba/a0e7a725f005d59466ffdde096cca696 to your computer and use it in GitHub Desktop.
Funny tweet for every day from "dayukoume".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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