Browse Source

if there is a link, is not read

master
arnaucode 7 years ago
parent
commit
0b2521f2a8
4 changed files with 20 additions and 3 deletions
  1. +3
    -2
      main.go
  2. +1
    -1
      timeline.go
  3. BIN
      twitterReader
  4. +16
    -0
      utils.go

+ 3
- 2
main.go

@ -7,10 +7,11 @@ func main() {
for i := 0; i < len(tweets); i++ {
c.Cyan(tweets[i].User.ScreenName + ": " + tweets[i].Text)
c.Green(tweets[i].Lang)
content := removeLinks(tweets[i].Text)
if tweets[i].Lang == "en" {
festivalEn(tweets[i].User.ScreenName + ": " + tweets[i].Text)
festivalEn(tweets[i].User.ScreenName + ": " + content)
} else {
festivalCa(tweets[i].User.ScreenName + ": " + tweets[i].Text)
festivalCa(tweets[i].User.ScreenName + ": " + content)
}
}
}

+ 1
- 1
timeline.go

@ -6,7 +6,7 @@ import (
func getTimeline(client *twitter.Client) []twitter.Tweet {
homeTimelineParams := &twitter.HomeTimelineParams{
Count: 4,
Count: 50,
}
tweets, _, _ := client.Timelines.HomeTimeline(homeTimelineParams)
return (tweets)

BIN
twitterReader


+ 16
- 0
utils.go

@ -0,0 +1,16 @@
package main
import "strings"
func removeLinks(text string) string {
words := strings.Split(text, " ")
var cleaned []string
for i := 0; i < len(words); i++ {
if strings.Contains(words[i], "http") {
} else {
cleaned = append(cleaned, words[i])
}
}
return strings.Join(cleaned, " ")
}

Loading…
Cancel
Save