mirror of
https://github.com/arnaucube/argos.git
synced 2026-02-07 19:16:40 +01:00
reorganization and a little bit of code robustness, and implemented TweetRandom functionallity
This commit is contained in:
71
optionDeleteTweets.go
Normal file
71
optionDeleteTweets.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"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) {
|
||||
tweets := getTweets(client, user.ScreenName, iterationsCount)
|
||||
count := 0
|
||||
//fmt.Println(tweets)
|
||||
for _, v := range tweets {
|
||||
c.Red("deleting: [id: " + v.IDStr + "] " + v.Text)
|
||||
deleted, _, _ := client.Statuses.Destroy(v.ID, nil)
|
||||
c.Green("DELETED: [id: " + deleted.IDStr + "] " + deleted.Text)
|
||||
count++
|
||||
}
|
||||
c.Red("Deleted " + strconv.Itoa(count) + " tweets")
|
||||
}
|
||||
func optionDeleteTweets(client *twitter.Client) {
|
||||
fmt.Println("Getting user data...")
|
||||
user := getUserData(client)
|
||||
printUserData(user)
|
||||
fmt.Println("")
|
||||
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)
|
||||
switch answer {
|
||||
case "y":
|
||||
fmt.Println("ok, you are sure")
|
||||
deleteTweets(client, user)
|
||||
user = getUserData(client)
|
||||
printUserData(user)
|
||||
break
|
||||
default:
|
||||
fmt.Println("Operation cancelled")
|
||||
break
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user