From ded8e336779afc489b90c3c58b9107c2a6a0edf4 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Fri, 22 Jan 2016 17:25:10 -0500 Subject: [PATCH] Skip tweeting pages with "HTMLhouse" title Plus add #web hashtag --- construction.go | 2 +- twitter.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/construction.go b/construction.go index 008454d..bb4037b 100644 --- a/construction.go +++ b/construction.go @@ -126,7 +126,7 @@ func addPublicAccess(app *app, houseID, html string) error { } // Tweet about it - tweet(app, houseID, fmt.Sprintf("\"%s\" on #HTMLhouse - %s/%s.html #html #website", title, app.cfg.HostName, houseID)) + tweet(app, houseID, title) return nil } diff --git a/twitter.go b/twitter.go index 4c988a0..1887235 100644 --- a/twitter.go +++ b/twitter.go @@ -6,7 +6,12 @@ import ( "github.com/ChimeraCoder/anaconda" ) -func tweet(app *app, houseID, text string) { +func tweet(app *app, houseID, title string) { + // Check for blacklisted titles + if title == "HTMLhouse" { + return + } + // Check if this has already been tweeted var tweetID int64 err := app.db.QueryRow("SELECT tweet_id FROM tweetedhouses WHERE house_id = ?", houseID).Scan(&tweetID) @@ -20,6 +25,8 @@ func tweet(app *app, houseID, text string) { } // Post to Twitter + text := fmt.Sprintf("\"%s\" on #HTMLhouse - %s/%s.html #html #web #website", title, app.cfg.HostName, houseID) + anaconda.SetConsumerKey(app.cfg.TwitterConsumerKey) anaconda.SetConsumerSecret(app.cfg.TwitterConsumerSecret) api := anaconda.NewTwitterApi(app.cfg.TwitterToken, app.cfg.TwitterTokenSecret)