Skip to content

Instantly share code, notes, and snippets.

@chiepomme
Created August 21, 2016 14:11
Show Gist options
  • Save chiepomme/f68d2af76a224b0cac72d0f10ca7b6fd to your computer and use it in GitHub Desktop.
Save chiepomme/f68d2af76a224b0cac72d0f10ca7b6fd to your computer and use it in GitHub Desktop.
自分のツイッターでフォローしている人の中でティアに参加しそうな名前の人を抜き出します
package main
import (
"fmt"
"regexp"
"github.com/ChimeraCoder/anaconda"
)
func main() {
anaconda.SetConsumerKey("consumer-key")
anaconda.SetConsumerSecret("consumer-secret")
api := anaconda.NewTwitterApi("access-token", "access-token-secret")
res := api.GetFriendsIdsAll(nil)
idMap := map[int64]bool{}
for page := range res {
if page.Error != nil {
panic(page.Error)
}
for _, id := range page.Ids {
idMap[id] = true
}
}
ids := make([]int64, 0, len(idMap))
for id := range idMap {
ids = append(ids, id)
}
r := regexp.MustCompile(`.*(ティア|てぃあ|TIA|ティア).*[A-ZA-Zあ-んア-ンア-ン][0-90-9]{1,2}[abABabAB].*`)
for i := 0; i < len(ids); i += 100 {
begin := i
end := i + 100
if end > len(ids) {
end = len(ids)
}
queryingIds := ids[begin:end]
users, err := api.GetUsersLookupByIds(queryingIds, nil)
if err != nil {
panic(err)
}
for _, user := range users {
if r.Match([]byte(user.Name)) {
fmt.Println(user.ScreenName + " " + user.Name)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment