Browse Source

half implemented followRandom and UnfollowAll

master
arnaucode 7 years ago
parent
commit
a86377a594
8 changed files with 156 additions and 26 deletions
  1. +15
    -8
      README.md
  2. +0
    -0
      argos.jpg
  3. BIN
      build/argos
  4. +12
    -11
      deleteTweets.go
  5. +68
    -0
      followRandom.go
  6. +1
    -1
      getUserTweets.go
  7. +16
    -6
      main.go
  8. +44
    -0
      unfollowAll.go

+ 15
- 8
README.md

@ -1,27 +1,34 @@
# goTweetsAnalyze
# argos
twitter analyzer written in Go lang, insipired on the Python tweets_analyzer by x0rz https://github.com/x0rz/tweets_analyzer
#### Argus Panoptes
#### Argos Panoptes
https://en.wikipedia.org/wiki/Argus_Panoptes
https://en.wikipedia.org/wiki/Panopticon
![Argus](https://raw.githubusercontent.com/arnaucode/argus/master/argus.jpg "argus")
![Argos](https://raw.githubusercontent.com/arnaucode/argos/master/argos.jpg "argos")
[under development]
#### Current features
- User analyzer
1. User analyzer
- word count
- weekly activity distribution
- daily activity distribution
- devices used
- Delete Tweets and Favs
- hashtags most used count
- user mentions coun [not implemented yet]
2. Delete Tweets and Favs
3. Unfollow all [not implemented yet]
4. Random follow [not implemented yet]
- selects n number of accounts to follow, and follows n random accounts
5. Random tweet [not implemented yet]
- post a tweet with random content (from newspaper)
![screen](https://raw.githubusercontent.com/arnaucode/argus/master/screen3.png "screen")
![screen](https://raw.githubusercontent.com/arnaucode/argos/master/screen3.png "screen")
![screen](https://raw.githubusercontent.com/arnaucode/argus/master/screen2.png "screen")
![screen](https://raw.githubusercontent.com/arnaucode/argos/master/screen2.png "screen")
needs a twitterConfig.json file on the /build folder with the content:
```
@ -39,6 +46,6 @@ to run it:
- open terminal
- execute the script with:
```
./argus
./argos
```
- follow the instructions that appears on the terminal

argus.jpg → argos.jpg


BIN
build/argus → build/argos


deleteTweetsAndFavs.go → deleteTweets.go

@ -10,13 +10,16 @@ import (
"github.com/dghubble/go-twitter/twitter"
)
func getAndPrintUserData(client *twitter.Client) *twitter.User {
func getUserData(client *twitter.Client) *twitter.User {
// Verify Credentials
verifyParams := &twitter.AccountVerifyParams{
SkipStatus: twitter.Bool(true),
IncludeEmail: twitter.Bool(true),
}
user, _, _ := client.Accounts.VerifyCredentials(verifyParams)
return user
}
func printUserData(user *twitter.User) {
fmt.Print("username: ")
c.Cyan(user.Name + " @" + user.ScreenName)
if user.Email != "" {
@ -27,11 +30,11 @@ func getAndPrintUserData(client *twitter.Client) *twitter.User {
fmt.Print("Location: ")
c.Red(user.Location)
}
c.Cyan("user created on: " + user.CreatedAt)
fmt.Print("user created on: ")
c.Cyan(user.CreatedAt)
fmt.Print("number of tweets: ")
c.Purple(strconv.Itoa(user.StatusesCount))
return user
}
func deleteTweets(client *twitter.Client, user *twitter.User) {
tweets := getTweets(client, user.ScreenName, iterationsCount)
@ -45,14 +48,12 @@ func deleteTweets(client *twitter.Client, user *twitter.User) {
}
c.Red("Deleted " + strconv.Itoa(count) + " tweets")
}
func deleteFavs(client *twitter.Client) {
}
func deleteTweetsAndFavs(client *twitter.Client) {
func optionDeleteTweets(client *twitter.Client) {
fmt.Println("Getting user data...")
user := getAndPrintUserData(client)
user := getUserData(client)
printUserData(user)
fmt.Println("")
fmt.Println("Are you sure you want to delete you tweets? [y/n]")
c.Red("Are you sure you want to delete you tweets? [y/n]")
newcommand := bufio.NewReader(os.Stdin)
answer, _ := newcommand.ReadString('\n')
answer = strings.TrimSpace(answer)
@ -60,8 +61,8 @@ func deleteTweetsAndFavs(client *twitter.Client) {
case "y":
fmt.Println("ok, you are sure")
deleteTweets(client, user)
deleteFavs(client)
user = getAndPrintUserData(client)
user = getUserData(client)
printUserData(user)
break
default:
fmt.Println("Operation cancelled")

+ 68
- 0
followRandom.go

@ -0,0 +1,68 @@
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
"github.com/dghubble/go-twitter/twitter"
)
/*func getUserByScreenName(ScreenName string) *twitter.User{
}*/
func getUserFollower(client *twitter.Client) string {
ScreenName := "username"
return ScreenName
}
func followUser(client *twitter.Client, ScreenName string) {
}
func followRandom(client *twitter.Client, nFollow int, ScreenName string) {
fmt.Println("Starting to follow " + strconv.Itoa(nFollow) + " users")
for i := 0; i < nFollow; i++ {
ScreenName = getUserFollower(client)
followUser(client, ScreenName)
}
}
func optionFollowRandom(client *twitter.Client) {
c.Red("how many accounts to follow?")
newcommand := bufio.NewReader(os.Stdin)
answer, _ := newcommand.ReadString('\n')
answer = strings.TrimSpace(answer)
fmt.Print("Number of users to follow: ")
c.Purple(answer)
nFollow, err := strconv.Atoi(answer)
if err != nil {
fmt.Println("incorrect entry, need a positive number")
}
fmt.Print("entry @username of a user, to get a 1st user to follow, that will be a user that the 1st user is following, and the 2nd user will be a user that the 3rd user is following): @")
newcommand = bufio.NewReader(os.Stdin)
firstScreenName, _ := newcommand.ReadString('\n')
firstScreenName = strings.TrimSpace(firstScreenName)
fmt.Print("first user to follow: @")
c.Purple(answer)
c.Red("Are you sure? [y/n]")
newcommand = bufio.NewReader(os.Stdin)
answer, _ = newcommand.ReadString('\n')
answer = strings.TrimSpace(answer)
switch answer {
case "y":
fmt.Println("ok, you are sure")
followRandom(client, nFollow, firstScreenName)
break
default:
fmt.Println("Operation cancelled")
break
}
}

+ 1
- 1
getUserTweets.go

@ -32,7 +32,7 @@ func getTweets(client *twitter.Client, username string, iterations int) []twitte
return tweets
}
func getUserTweets(client *twitter.Client) {
func optionGetUserTweets(client *twitter.Client) {
newcommand := bufio.NewReader(os.Stdin)
fmt.Print("enter username: @")
username, _ := newcommand.ReadString('\n')

+ 16
- 6
main.go

@ -13,10 +13,10 @@ const minNumHashtag = 2
const iterationsCount = 3
func main() {
c.DarkGray("Argus Panoptes")
c.Yellow("Argos Panoptes")
fmt.Println("---------------")
c.Cyan("argus initialized")
c.Purple("https://github.com/arnaucode/argus")
c.Cyan("argos initialized")
c.Purple("https://github.com/arnaucode/argos")
fmt.Println("version " + version)
fmt.Println("Reading twitterConfig.json file")
client := readConfigTokensAndConnect()
@ -25,7 +25,9 @@ func main() {
fmt.Print("Please select command number")
options := `
1 - Analyze username
2 - Delete Tweets
2 - Delete Tweets & Rretweets
3 - Unfollow all
4 - Follow random
0 - Exit script
option to select: `
for {
@ -37,11 +39,19 @@ option to select: `
switch option {
case "1":
fmt.Println("selected 1 - Analyze username")
getUserTweets(client)
optionGetUserTweets(client)
break
case "2":
fmt.Println("selected 2 - Delete Tweets")
deleteTweetsAndFavs(client)
optionDeleteTweets(client)
break
case "3":
fmt.Println("selected 3 - Unfollow all")
optionUnfollowAll(client)
break
case "4":
fmt.Println("selected 4 - Follow random")
optionFollowRandom(client)
break
case "0":
fmt.Println("selected 0 - exit script")

+ 44
- 0
unfollowAll.go

@ -0,0 +1,44 @@
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
"github.com/dghubble/go-twitter/twitter"
)
func printUserFollowsData(user *twitter.User) {
fmt.Print("followers: ")
c.Cyan(strconv.Itoa(user.FollowersCount))
fmt.Print("following: ")
c.Cyan(strconv.Itoa(user.FriendsCount))
}
func unfollowFollowingUsers(client *twitter.Client, user *twitter.User) {
following, _, _ := client.Friends.List(&twitter.FriendListParams{
ScreenName: user.ScreenName,
Count: 200,
})
fmt.Println(following)
}
func optionUnfollowAll(client *twitter.Client) {
fmt.Println("Getting user data...")
user := getUserData(client)
printUserFollowsData(user)
fmt.Println("")
c.Red("Are you sure you want to unfollow all? [y/n]")
newcommand := bufio.NewReader(os.Stdin)
answer, _ := newcommand.ReadString('\n')
answer = strings.TrimSpace(answer)
switch answer {
case "y":
fmt.Println("ok, you are sure")
unfollowFollowingUsers(client, user)
break
default:
fmt.Println("Operation cancelled")
break
}
}

Loading…
Cancel
Save