mirror of
https://github.com/arnaucube/argos.git
synced 2026-02-07 02:56:41 +01:00
started implementation of functionallity to delete tweets, implemented better colors println
This commit is contained in:
37
color.go
Normal file
37
color.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Color struct{}
|
||||
|
||||
var c Color
|
||||
|
||||
func (c Color) Cyan(t string) {
|
||||
fmt.Print("\x1b[36;1m") //cyan
|
||||
fmt.Println(t)
|
||||
fmt.Print("\x1b[0m") //defaultColor
|
||||
}
|
||||
|
||||
func (c Color) Red(t string) {
|
||||
fmt.Print("\x1b[31;1m") //red
|
||||
fmt.Println(t)
|
||||
fmt.Print("\x1b[0m") //defaultColor
|
||||
}
|
||||
|
||||
func (c Color) Green(t string) {
|
||||
fmt.Print("\x1b[32;1m") //green
|
||||
fmt.Println(t)
|
||||
fmt.Print("\x1b[0m") //defaultColor
|
||||
}
|
||||
|
||||
func (c Color) Blue(t string) {
|
||||
fmt.Print("\x1b[34;1m") //blue
|
||||
fmt.Println(t)
|
||||
fmt.Print("\x1b[0m") //defaultColor
|
||||
}
|
||||
|
||||
func (c Color) Purple(t string) {
|
||||
fmt.Print("\x1b[35;1m") //purple
|
||||
fmt.Println(t)
|
||||
fmt.Print("\x1b[0m") //defaultColor
|
||||
}
|
||||
66
deleteTweetsAndFavs.go
Normal file
66
deleteTweetsAndFavs.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/dghubble/go-twitter/twitter"
|
||||
)
|
||||
|
||||
func getAndPrintUserData(client *twitter.Client) *twitter.User {
|
||||
// Verify Credentials
|
||||
verifyParams := &twitter.AccountVerifyParams{
|
||||
SkipStatus: twitter.Bool(true),
|
||||
IncludeEmail: twitter.Bool(true),
|
||||
}
|
||||
user, _, _ := client.Accounts.VerifyCredentials(verifyParams)
|
||||
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)
|
||||
}
|
||||
c.Cyan("user created on: " + 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)
|
||||
for _, v := range tweets {
|
||||
c.Red("deleting: [id: " + v.IDStr + "] " + v.Text)
|
||||
deleted, _, _ := client.Statuses.Destroy(v.ID, nil)
|
||||
c.Green("deleting: [id: " + deleted.IDStr + "] " + deleted.Text)
|
||||
}
|
||||
}
|
||||
func deleteFavs(client *twitter.Client) {
|
||||
|
||||
}
|
||||
func deleteTweetsAndFavs(client *twitter.Client) {
|
||||
fmt.Println("Getting user data...")
|
||||
user := getAndPrintUserData(client)
|
||||
fmt.Println("")
|
||||
fmt.Println("Are you sure you want to delete you tweets? [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")
|
||||
deleteTweets(client, user)
|
||||
deleteFavs(client)
|
||||
user = getAndPrintUserData(client)
|
||||
break
|
||||
default:
|
||||
fmt.Println("Operation cancelled")
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -37,8 +37,8 @@ func getUserTweets(client *twitter.Client) {
|
||||
fmt.Print("enter username: @")
|
||||
username, _ := newcommand.ReadString('\n')
|
||||
username = strings.TrimSpace(username)
|
||||
fmt.Println("user selected: \x1b[36;1m@" + username)
|
||||
fmt.Print("\x1b[0m") //defaultColor
|
||||
fmt.Print("user selected: ")
|
||||
c.Cyan("@" + username)
|
||||
fmt.Println("-----------------------")
|
||||
|
||||
//get tweets
|
||||
@@ -77,5 +77,7 @@ func getUserTweets(client *twitter.Client) {
|
||||
fmt.Println(" ")
|
||||
fmt.Println("Total of " + strconv.Itoa(len(tweets)) + " tweets analyzed")
|
||||
fmt.Println(" ")
|
||||
fmt.Println("User @" + username + " analysis finished")
|
||||
fmt.Print("User @")
|
||||
c.Cyan(username)
|
||||
fmt.Println(" analysis finished")
|
||||
}
|
||||
|
||||
7
main.go
7
main.go
@@ -27,6 +27,7 @@ func main() {
|
||||
fmt.Print("Please select command number")
|
||||
options := `
|
||||
1 - Analyze username
|
||||
2 - Delete Tweets
|
||||
0 - Exit script
|
||||
option to select: `
|
||||
for {
|
||||
@@ -41,10 +42,8 @@ option to select: `
|
||||
getUserTweets(client)
|
||||
break
|
||||
case "2":
|
||||
fmt.Println("selected 2 - Delete all Favs")
|
||||
break
|
||||
case "3":
|
||||
fmt.Println("selected 3 - Delete all Tweets and Favs")
|
||||
fmt.Println("selected 2 - Delete Tweets")
|
||||
deleteTweetsAndFavs(client)
|
||||
break
|
||||
case "0":
|
||||
fmt.Println("selected 0 - exit script")
|
||||
|
||||
Reference in New Issue
Block a user