Skip to content

Instantly share code, notes, and snippets.

@akira093
Created June 28, 2014 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akira093/49f9eb50d115f08692ad to your computer and use it in GitHub Desktop.
Save akira093/49f9eb50d115f08692ad to your computer and use it in GitHub Desktop.
package main
import (
"errors"
"flag"
"fmt"
"github.com/ChimeraCoder/anaconda"
"net/url"
"runtime"
"sync"
)
func favbomb(api *anaconda.TwitterApi, v url.Values) {
wg := new(sync.WaitGroup)
tws, err := api.GetUserTimeline(v)
if err != nil {
panic(err)
}
for _, tw := range tws {
wg.Add(1)
go func(tw anaconda.Tweet) {
defer wg.Done()
_, err = api.Favorite(tw.Id)
if err != nil {
fmt.Println(err)
} else {
fmt.Println("favorited: ", tw.Text)
}
}(tw)
}
wg.Wait()
}
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
target := flag.String("t", "", "target name")
count := flag.Int("c", 10, "favo count")
flag.Parse()
if *target == "" {
panic(errors.New("target name is not assigned"))
}
//anacondaのdoc見て TwitterApiを作る
v := url.Values{}
v.Set("screen_name", *target)
v.Set("count", string(*count))
v.Set("include_rts", "0")
favbomb(api, v)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment