arnaucube
arnaucube/twitterReaderPublic Self-hosted repository
if there is a link, is not read
arnaucode idoctnef@openmailbox.org
Tue, 16 May 2017 21:47:30 +0200
commit

0b2521f2a848df1e6641a4453e0edcf2feaed0b9

parent

80d0e254f70f62b4f82e902c8f56857d5d5560e6

4 files changed, 20 insertions(+), 3 deletions(-)

jump to
M main.go → main.go

@@ -7,10 +7,11 @@ tweets := getTimeline(client)

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) } } }
M timeline.go → timeline.go

@@ -6,7 +6,7 @@ )

func getTimeline(client *twitter.Client) []twitter.Tweet { homeTimelineParams := &twitter.HomeTimelineParams{ - Count: 4, + Count: 50, } tweets, _, _ := client.Timelines.HomeTimeline(homeTimelineParams) return (tweets)
A 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, " ") +}