You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2 KiB

  1. package main
  2. import (
  3. "fmt"
  4. "strconv"
  5. "github.com/dghubble/go-twitter/twitter"
  6. )
  7. func replyTweet(client *twitter.Client, text string, inReplyToStatusID int64) {
  8. tweet, httpResp, err := client.Statuses.Update(text, &twitter.StatusUpdateParams{
  9. InReplyToStatusID: inReplyToStatusID,
  10. })
  11. if err != nil {
  12. fmt.Println(err)
  13. }
  14. if httpResp.Status != "200 OK" {
  15. c.Red("error: " + httpResp.Status)
  16. c.Purple("maybe twitter has blocked the account, CTRL+C, wait 15 minutes and try again")
  17. }
  18. fmt.Print("tweet posted: ")
  19. c.Green(tweet.Text)
  20. }
  21. func postTweet(client *twitter.Client, text string) {
  22. tweet, httpResp, err := client.Statuses.Update(text, nil)
  23. if err != nil {
  24. fmt.Println(err)
  25. }
  26. if httpResp.Status != "200 OK" {
  27. c.Red("error: " + httpResp.Status)
  28. c.Purple("maybe twitter has blocked the account, CTRL+C, wait 15 minutes and try again")
  29. }
  30. fmt.Print("tweet posted: ")
  31. c.Green(tweet.Text)
  32. }
  33. func tweetFromFlock(flock Flock, text string) {
  34. fmt.Println("Starting to publish tweet: " + text)
  35. fmt.Println(strconv.Itoa(len(flock.Clients)))
  36. for i := 0; i < len(flock.Clients); i++ {
  37. fmt.Print("tweeting from: ")
  38. c.Cyan("@" + flock.ScreenNames[i])
  39. postTweet(flock.Clients[i], text)
  40. //waitTime(1)
  41. }
  42. }