arnaucube
arnaucube/flock-botnetPublic Self-hosted repository
flock-botnet/tweetFromFlock.go
tweetFromFlock.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 postTweet(client *twitter.Client, text string) {
14	tweet, httpResp, err := client.Statuses.Update(text, nil)
15	if err != nil {
16		fmt.Println(err)
17	}
18	if httpResp.Status != "200 OK" {
19		c.Red("error: " + httpResp.Status)
20		c.Purple("maybe twitter has blocked the account, CTRL+C, wait 15 minutes and try again")
21	}
22	fmt.Print("tweet posted: ")
23	c.Green(tweet.Text)
24}
25func tweetFromFlock(flock Flock, text string) {
26	fmt.Println("Starting to publish tweet: " + text)
27	fmt.Println(strconv.Itoa(len(flock.Clients)))
28	for i := 0; i < len(flock.Clients); i++ {
29		fmt.Print("tweeting from: ")
30		c.Cyan("@" + flock.ScreenNames[i])
31		postTweet(flock.Clients[i], text)
32		//waitTime(1)
33	}
34
35}
36
37func optionTweetFromFlock(flock Flock) {
38
39	fmt.Print("entry tweet content: ")
40	newcommand := bufio.NewReader(os.Stdin)
41	text, _ := newcommand.ReadString('\n')
42	text = strings.TrimSpace(text)
43	fmt.Print("tweet content: ")
44	c.Purple(text)
45
46	c.Red("Are you sure? [y/n]")
47	newcommand = bufio.NewReader(os.Stdin)
48	answer, _ := newcommand.ReadString('\n')
49	answer = strings.TrimSpace(answer)
50	switch answer {
51	case "y":
52		fmt.Println("ok, you are sure")
53		tweetFromFlock(flock, text)
54		break
55	default:
56		fmt.Println("Operation cancelled")
57		break
58	}
59}