mirror of
https://github.com/arnaucube/argos.git
synced 2026-02-07 02:56:41 +01:00
added sleep pause of 1 min when followRandom and unfollowAll, to avoid twitter api limitation
This commit is contained in:
BIN
build/argos
BIN
build/argos
Binary file not shown.
@@ -6,6 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/dghubble/go-twitter/twitter"
|
"github.com/dghubble/go-twitter/twitter"
|
||||||
)
|
)
|
||||||
@@ -43,6 +44,10 @@ func followRandom(client *twitter.Client, nFollow int, screenName string) {
|
|||||||
userToFollow := getUserToFollowFromUser(client, screenName)
|
userToFollow := getUserToFollowFromUser(client, screenName)
|
||||||
followUser(client, userToFollow)
|
followUser(client, userToFollow)
|
||||||
screenName = userToFollow
|
screenName = userToFollow
|
||||||
|
//wait to avoid the twitter api limitation
|
||||||
|
fmt.Println("waiting 1 min to avoid twitter api limitation")
|
||||||
|
fmt.Println(time.Now().Local())
|
||||||
|
time.Sleep(1 * time.Minute)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/dghubble/go-twitter/twitter"
|
"github.com/dghubble/go-twitter/twitter"
|
||||||
)
|
)
|
||||||
@@ -17,12 +18,13 @@ func printUserFollowsData(user *twitter.User) {
|
|||||||
c.Cyan(strconv.Itoa(user.FriendsCount))
|
c.Cyan(strconv.Itoa(user.FriendsCount))
|
||||||
}
|
}
|
||||||
func unfollowUser(client *twitter.Client, screenName string) {
|
func unfollowUser(client *twitter.Client, screenName string) {
|
||||||
_, httpResp, _ := client.Friendships.Destroy(&twitter.FriendshipDestroyParams{
|
user, httpResp, _ := client.Friendships.Destroy(&twitter.FriendshipDestroyParams{
|
||||||
ScreenName: screenName,
|
ScreenName: screenName,
|
||||||
})
|
})
|
||||||
if httpResp.Status != "200 OK" {
|
if httpResp.Status != "200 OK" {
|
||||||
c.Red(httpResp.Status)
|
c.Red(httpResp.Status)
|
||||||
}
|
}
|
||||||
|
c.Green(user.ScreenName)
|
||||||
}
|
}
|
||||||
func getFollowingUsers(client *twitter.Client, user *twitter.User) {
|
func getFollowingUsers(client *twitter.Client, user *twitter.User) {
|
||||||
following, httpResp, err := client.Friends.List(&twitter.FriendListParams{
|
following, httpResp, err := client.Friends.List(&twitter.FriendListParams{
|
||||||
@@ -35,9 +37,13 @@ func getFollowingUsers(client *twitter.Client, user *twitter.User) {
|
|||||||
if httpResp.Status != "200 OK" {
|
if httpResp.Status != "200 OK" {
|
||||||
c.Red(httpResp.Status)
|
c.Red(httpResp.Status)
|
||||||
}
|
}
|
||||||
fmt.Println(following)
|
//fmt.Println(following)
|
||||||
for _, k := range following.Users {
|
for _, k := range following.Users {
|
||||||
unfollowUser(client, k.ScreenName)
|
unfollowUser(client, k.ScreenName)
|
||||||
|
//wait to avoid the twitter api limitation
|
||||||
|
fmt.Println("waiting 1 min to avoid twitter api limitation")
|
||||||
|
fmt.Println(time.Now().Local())
|
||||||
|
time.Sleep(1 * time.Minute)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func optionUnfollowAll(client *twitter.Client) {
|
func optionUnfollowAll(client *twitter.Client) {
|
||||||
|
|||||||
Reference in New Issue
Block a user