arnaucube
arnaucube/argosPublic Self-hosted repository
argos/optionAnalyzeTweet.go
optionAnalyzeTweet.goRaw
 1package main
 2
 3import (
 4	"bufio"
 5	"fmt"
 6	"os"
 7	"strconv"
 8	"strings"
 9
10	"github.com/dghubble/go-twitter/twitter"
11)
12
13func optionAnalyzeTweet(client *twitter.Client) {
14	newcommand := bufio.NewReader(os.Stdin)
15	fmt.Print("enter link of the tweet: ")
16	link, _ := newcommand.ReadString('\n')
17	link = strings.TrimSpace(link)
18	fmt.Print("link selected: ")
19	c.Cyan(link)
20	fmt.Println("-----------------------")
21	linkParam := strings.Split(link, "/")
22	tweetIdStr := linkParam[len(linkParam)-1]
23	c.Cyan(tweetIdStr)
24	tweetId, err := strconv.ParseInt(tweetIdStr, 10, 64)
25	if err != nil {
26		fmt.Println(err)
27	}
28	tweets := getRetweets(client, tweetId)
29	for _, tweet := range tweets {
30		source := strings.Split(strings.Split(tweet.Source, ">")[1], "<")[0]
31		fmt.Println(tweet.CreatedAt + " @" + tweet.User.ScreenName + ", source: " + source)
32	}
33	fmt.Print("total of: ")
34	fmt.Println(len(tweets))
35}