Build out structure

This commit is contained in:
Dustin Pianalto
2020-09-29 19:36:45 -08:00
parent 0258e0910f
commit 76e448f5a3
11 changed files with 165 additions and 12 deletions
+11 -6
View File
@@ -4,19 +4,24 @@ import (
"log"
"github.com/dghubble/go-twitter/twitter"
oauth "github.com/dustinpianalto/overpass/internal/oauth2"
"github.com/dustinpianalto/overpass/internal/oauth1"
)
type Tweet struct {
twitter.Tweet
}
func Connect() *twitter.Client {
httpClient := oauth.GetClient()
httpClient := oauth1.GetClient()
return twitter.NewClient(httpClient)
}
func StartUserScanner(client *twitter.Client, userID string) (chan *twitter.Tweet, *twitter.Stream) {
func StartUserScanner(client *twitter.Client, userID string, tweetChan chan *Tweet) *twitter.Stream {
demux := twitter.NewSwitchDemux()
tweetChan := make(chan *twitter.Tweet, 10)
demux.Tweet = func(tweet *twitter.Tweet) {
tweetChan <- tweet
if tweet.User.IDStr == userID {
tweetChan <- &Tweet{*tweet}
}
}
demux.StatusDeletion = func(deletion *twitter.StatusDeletion) {
log.Printf("%#v\n", deletion)
@@ -40,5 +45,5 @@ func StartUserScanner(client *twitter.Client, userID string) (chan *twitter.Twee
log.Println(err)
}
go demux.HandleChan(stream.Messages)
return tweetChan, stream
return stream
}