if there is a link, is not read

This commit is contained in:
arnaucode
2017-05-16 21:47:30 +02:00
parent 80d0e254f7
commit 0b2521f2a8
4 changed files with 20 additions and 3 deletions

View File

@@ -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)
}
}
}

View File

@@ -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)

Binary file not shown.

16
utils.go Normal file
View File

@@ -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, " ")
}