mirror of
https://github.com/arnaucube/argos.git
synced 2026-02-06 18:46:40 +01:00
implemented delete favs (likes), and organized better code in files
This commit is contained in:
BIN
build/argos
BIN
build/argos
Binary file not shown.
12
color.go
12
color.go
@@ -2,46 +2,54 @@ package main
|
|||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
|
//Color struct, defines the color
|
||||||
type Color struct{}
|
type Color struct{}
|
||||||
|
|
||||||
var c Color
|
var c Color
|
||||||
|
|
||||||
|
//DarkGray color
|
||||||
func (c Color) DarkGray(t string) {
|
func (c Color) DarkGray(t string) {
|
||||||
fmt.Print("\x1b[30;1m") //red
|
fmt.Print("\x1b[30;1m") //dark gray
|
||||||
fmt.Println(t)
|
fmt.Println(t)
|
||||||
fmt.Print("\x1b[0m") //defaultColor
|
fmt.Print("\x1b[0m") //defaultColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Red color
|
||||||
func (c Color) Red(t string) {
|
func (c Color) Red(t string) {
|
||||||
fmt.Print("\x1b[31;1m") //red
|
fmt.Print("\x1b[31;1m") //red
|
||||||
fmt.Println(t)
|
fmt.Println(t)
|
||||||
fmt.Print("\x1b[0m") //defaultColor
|
fmt.Print("\x1b[0m") //defaultColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Green color
|
||||||
func (c Color) Green(t string) {
|
func (c Color) Green(t string) {
|
||||||
fmt.Print("\x1b[32;1m") //green
|
fmt.Print("\x1b[32;1m") //green
|
||||||
fmt.Println(t)
|
fmt.Println(t)
|
||||||
fmt.Print("\x1b[0m") //defaultColor
|
fmt.Print("\x1b[0m") //defaultColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Yellow color
|
||||||
func (c Color) Yellow(t string) {
|
func (c Color) Yellow(t string) {
|
||||||
fmt.Print("\x1b[33;1m") //green
|
fmt.Print("\x1b[33;1m") //yellow
|
||||||
fmt.Println(t)
|
fmt.Println(t)
|
||||||
fmt.Print("\x1b[0m") //defaultColor
|
fmt.Print("\x1b[0m") //defaultColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Blue color
|
||||||
func (c Color) Blue(t string) {
|
func (c Color) Blue(t string) {
|
||||||
fmt.Print("\x1b[34;1m") //blue
|
fmt.Print("\x1b[34;1m") //blue
|
||||||
fmt.Println(t)
|
fmt.Println(t)
|
||||||
fmt.Print("\x1b[0m") //defaultColor
|
fmt.Print("\x1b[0m") //defaultColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Purple color
|
||||||
func (c Color) Purple(t string) {
|
func (c Color) Purple(t string) {
|
||||||
fmt.Print("\x1b[35;1m") //purple
|
fmt.Print("\x1b[35;1m") //purple
|
||||||
fmt.Println(t)
|
fmt.Println(t)
|
||||||
fmt.Print("\x1b[0m") //defaultColor
|
fmt.Print("\x1b[0m") //defaultColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Cyan color
|
||||||
func (c Color) Cyan(t string) {
|
func (c Color) Cyan(t string) {
|
||||||
fmt.Print("\x1b[36;1m") //cyan
|
fmt.Print("\x1b[36;1m") //cyan
|
||||||
fmt.Println(t)
|
fmt.Println(t)
|
||||||
|
|||||||
86
getOperations.go
Normal file
86
getOperations.go
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/dghubble/go-twitter/twitter"
|
||||||
|
)
|
||||||
|
|
||||||
|
func getTweets(client *twitter.Client, username string, iterations int) []twitter.Tweet {
|
||||||
|
var tweets []twitter.Tweet
|
||||||
|
var maxid int64
|
||||||
|
for i := 0; i < iterations; i++ {
|
||||||
|
tweetsRaw, _, _ := client.Timelines.UserTimeline(&twitter.UserTimelineParams{
|
||||||
|
ScreenName: username,
|
||||||
|
Count: 200,
|
||||||
|
MaxID: maxid,
|
||||||
|
})
|
||||||
|
//if no tweets, stop getting tweets
|
||||||
|
if len(tweetsRaw) == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
maxid = tweetsRaw[len(tweetsRaw)-1].ID
|
||||||
|
|
||||||
|
for _, v := range tweetsRaw {
|
||||||
|
tweets = append(tweets, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tweets
|
||||||
|
}
|
||||||
|
|
||||||
|
func getFavs(client *twitter.Client, username string, iterations int) []twitter.Tweet {
|
||||||
|
var tweets []twitter.Tweet
|
||||||
|
var maxid int64
|
||||||
|
for i := 0; i < iterations; i++ {
|
||||||
|
tweetsRaw, _, _ := client.Favorites.List(&twitter.FavoriteListParams{
|
||||||
|
ScreenName: username,
|
||||||
|
Count: 200,
|
||||||
|
MaxID: maxid,
|
||||||
|
})
|
||||||
|
|
||||||
|
//if no tweets, stop getting tweets
|
||||||
|
if len(tweetsRaw) == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
maxid = tweetsRaw[len(tweetsRaw)-1].ID
|
||||||
|
|
||||||
|
for _, v := range tweetsRaw {
|
||||||
|
tweets = append(tweets, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tweets
|
||||||
|
}
|
||||||
|
|
||||||
|
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 != "" {
|
||||||
|
fmt.Print("Email ")
|
||||||
|
c.Red(user.Email)
|
||||||
|
}
|
||||||
|
if user.Location != "" {
|
||||||
|
fmt.Print("Location: ")
|
||||||
|
c.Red(user.Location)
|
||||||
|
}
|
||||||
|
fmt.Print("user created on: ")
|
||||||
|
c.Cyan(user.CreatedAt)
|
||||||
|
|
||||||
|
fmt.Print("number of tweets: ")
|
||||||
|
c.Purple(strconv.Itoa(user.StatusesCount))
|
||||||
|
|
||||||
|
fmt.Print("number of favs: ")
|
||||||
|
c.Purple(strconv.Itoa(user.FavouritesCount))
|
||||||
|
}
|
||||||
15
main.go
15
main.go
@@ -21,7 +21,13 @@ func main() {
|
|||||||
fmt.Println("version " + version)
|
fmt.Println("version " + version)
|
||||||
fmt.Println("Reading twitterConfig.json file")
|
fmt.Println("Reading twitterConfig.json file")
|
||||||
client := readConfigTokensAndConnect()
|
client := readConfigTokensAndConnect()
|
||||||
|
|
||||||
fmt.Println("---------------")
|
fmt.Println("---------------")
|
||||||
|
fmt.Println("Getting user data...")
|
||||||
|
user := getUserData(client)
|
||||||
|
printUserData(user)
|
||||||
|
fmt.Println("")
|
||||||
|
|
||||||
newcommand := bufio.NewReader(os.Stdin)
|
newcommand := bufio.NewReader(os.Stdin)
|
||||||
fmt.Print("Please select command number")
|
fmt.Print("Please select command number")
|
||||||
options := `
|
options := `
|
||||||
@@ -29,7 +35,8 @@ func main() {
|
|||||||
2 - Unfollow all
|
2 - Unfollow all
|
||||||
3 - Follow random
|
3 - Follow random
|
||||||
4 - Delete Tweets
|
4 - Delete Tweets
|
||||||
5 - Tweet Random
|
5 - Delete Favs (Likes)
|
||||||
|
6 - Tweet Random
|
||||||
0 - Exit script
|
0 - Exit script
|
||||||
option to select: `
|
option to select: `
|
||||||
for {
|
for {
|
||||||
@@ -41,7 +48,7 @@ option to select: `
|
|||||||
switch option {
|
switch option {
|
||||||
case "1":
|
case "1":
|
||||||
fmt.Println("selected 1 - Analyze username")
|
fmt.Println("selected 1 - Analyze username")
|
||||||
optionGetUserTweets(client)
|
optionAnalyzeUserTweets(client)
|
||||||
break
|
break
|
||||||
case "2":
|
case "2":
|
||||||
fmt.Println("selected 2 - Unfollow all")
|
fmt.Println("selected 2 - Unfollow all")
|
||||||
@@ -56,6 +63,10 @@ option to select: `
|
|||||||
optionDeleteTweets(client)
|
optionDeleteTweets(client)
|
||||||
break
|
break
|
||||||
case "5":
|
case "5":
|
||||||
|
fmt.Println("selected 5 - Delete Favs (Likes)")
|
||||||
|
optionDeleteFavs(client)
|
||||||
|
break
|
||||||
|
case "6":
|
||||||
fmt.Println("selected 5 - Tweet random")
|
fmt.Println("selected 5 - Tweet random")
|
||||||
optionTweetRandom(client)
|
optionTweetRandom(client)
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -10,29 +10,7 @@ import (
|
|||||||
"github.com/dghubble/go-twitter/twitter"
|
"github.com/dghubble/go-twitter/twitter"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getTweets(client *twitter.Client, username string, iterations int) []twitter.Tweet {
|
func optionAnalyzeUserTweets(client *twitter.Client) {
|
||||||
var tweets []twitter.Tweet
|
|
||||||
var maxid int64
|
|
||||||
for i := 0; i < iterations; i++ {
|
|
||||||
tweetsRaw, _, _ := client.Timelines.UserTimeline(&twitter.UserTimelineParams{
|
|
||||||
ScreenName: username,
|
|
||||||
Count: 200,
|
|
||||||
MaxID: maxid,
|
|
||||||
})
|
|
||||||
//if no tweets, stop getting tweets
|
|
||||||
if len(tweetsRaw) == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
maxid = tweetsRaw[len(tweetsRaw)-1].ID
|
|
||||||
|
|
||||||
for _, v := range tweetsRaw {
|
|
||||||
tweets = append(tweets, v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return tweets
|
|
||||||
}
|
|
||||||
func optionGetUserTweets(client *twitter.Client) {
|
|
||||||
newcommand := bufio.NewReader(os.Stdin)
|
newcommand := bufio.NewReader(os.Stdin)
|
||||||
fmt.Print("enter username: @")
|
fmt.Print("enter username: @")
|
||||||
username, _ := newcommand.ReadString('\n')
|
username, _ := newcommand.ReadString('\n')
|
||||||
44
optionDeleteFavs.go
Normal file
44
optionDeleteFavs.go
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/dghubble/go-twitter/twitter"
|
||||||
|
)
|
||||||
|
|
||||||
|
func deleteFavs(client *twitter.Client, user *twitter.User) {
|
||||||
|
tweets := getFavs(client, user.ScreenName, iterationsCount)
|
||||||
|
count := 0
|
||||||
|
for _, v := range tweets {
|
||||||
|
c.Red("deleting: [id: " + v.IDStr + "] " + v.Text)
|
||||||
|
deleted, _, _ := client.Favorites.Destroy(&twitter.FavoriteDestroyParams{
|
||||||
|
ID: v.ID,
|
||||||
|
})
|
||||||
|
c.Green("DELETED: [id: " + deleted.IDStr + "] " + deleted.Text)
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
c.Red("Deleted " + strconv.Itoa(count) + " favs")
|
||||||
|
}
|
||||||
|
|
||||||
|
func optionDeleteFavs(client *twitter.Client) {
|
||||||
|
c.Red("Are you sure you want to delete your favs? [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")
|
||||||
|
user := getUserData(client)
|
||||||
|
deleteFavs(client, user)
|
||||||
|
user = getUserData(client)
|
||||||
|
printUserData(user)
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
fmt.Println("Operation cancelled")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,32 +10,6 @@ import (
|
|||||||
"github.com/dghubble/go-twitter/twitter"
|
"github.com/dghubble/go-twitter/twitter"
|
||||||
)
|
)
|
||||||
|
|
||||||
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 != "" {
|
|
||||||
fmt.Print("Email ")
|
|
||||||
c.Red(user.Email)
|
|
||||||
}
|
|
||||||
if user.Location != "" {
|
|
||||||
fmt.Print("Location: ")
|
|
||||||
c.Red(user.Location)
|
|
||||||
}
|
|
||||||
fmt.Print("user created on: ")
|
|
||||||
c.Cyan(user.CreatedAt)
|
|
||||||
|
|
||||||
fmt.Print("number of tweets: ")
|
|
||||||
c.Purple(strconv.Itoa(user.StatusesCount))
|
|
||||||
}
|
|
||||||
func deleteTweets(client *twitter.Client, user *twitter.User) {
|
func deleteTweets(client *twitter.Client, user *twitter.User) {
|
||||||
tweets := getTweets(client, user.ScreenName, iterationsCount)
|
tweets := getTweets(client, user.ScreenName, iterationsCount)
|
||||||
count := 0
|
count := 0
|
||||||
@@ -52,7 +26,7 @@ func optionDeleteTweets(client *twitter.Client) {
|
|||||||
user := getUserData(client)
|
user := getUserData(client)
|
||||||
printUserData(user)
|
printUserData(user)
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
c.Red("Are you sure you want to delete you tweets? [y/n]")
|
c.Red("Are you sure you want to delete your tweets? [y/n]")
|
||||||
newcommand := bufio.NewReader(os.Stdin)
|
newcommand := bufio.NewReader(os.Stdin)
|
||||||
answer, _ := newcommand.ReadString('\n')
|
answer, _ := newcommand.ReadString('\n')
|
||||||
answer = strings.TrimSpace(answer)
|
answer = strings.TrimSpace(answer)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/dghubble/oauth1"
|
"github.com/dghubble/oauth1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//Config stores the data from json twitterConfig.json file
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Consumer_key string `json:"consumer_key"`
|
Consumer_key string `json:"consumer_key"`
|
||||||
Consumer_secret string `json:"consumer_secret"`
|
Consumer_secret string `json:"consumer_secret"`
|
||||||
|
|||||||
Reference in New Issue
Block a user