Skip to content

Commit

Permalink
Adjust dockerfile, fetch only 10 tweets at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
MagnificRogue committed Aug 2, 2021
1 parent 13d9450 commit af1bbb0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion go/twitterbot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ RUN chmod +x /app/bin/main

FROM base as runtime

COPY --from=builder /app/bin/main .
COPY --from=builder /app/bin/main .

CMD /app/main -tweet-query=${TWEET_QUERY} -groupme-bot-id=${GROUPME_BOT_ID} -twitter-app-key=${TWITTER_APP_KEY} -twitter-app-secret=${TWITTER_APP_SECRET}
2 changes: 1 addition & 1 deletion go/twitterbot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ run:
go run cmd/main.go -tweet-query=${TWEET_QUERY} -groupme-bot-id=${GROUPME_BOT_ID} -twitter-app-key=${TWITTER_APP_KEY} -twitter-app-secret=${TWITTER_APP_SECRET}

container:
docker build -t groupme/twitter-bot .
docker build -t groupme/twitterbot .
5 changes: 2 additions & 3 deletions go/twitterbot/twitter_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func NewTwitterPoster(tc *twitter.Client, bc *BotClient, tags ...string) (*Twitt
twitterClient: tc,
botclient: bc,
tags: tags,
// Initialize twitter stream with 200 tweets
tweetStream: make(chan twitter.Tweet, 200),
// initializing the size of the tweet stream equal to the count we anticipate an individual request to have
tweetStream: make(chan twitter.Tweet, 10),
stop: make(chan bool),
}, nil
}
Expand Down Expand Up @@ -77,7 +77,6 @@ func (tp *TwitterPoster) fetchTweets() {
log.Printf("Fetching tweets since %d\n", tp.sinceIdHorizon)
// https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets
payload, response, err := tp.twitterClient.Search.Tweets(&twitter.SearchTweetParams{
Count: 100,
Query: strings.Join(tp.tags, " OR "),
SinceID: tp.sinceIdHorizon,
ResultType: "recent",
Expand Down

0 comments on commit af1bbb0

Please sign in to comment.