Created
June 28, 2014 04:33
-
-
Save akira093/49f9eb50d115f08692ad to your computer and use it in GitHub Desktop.
This file contains 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 ( | |
"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