Skip to content

Instantly share code, notes, and snippets.

@jeffreyolchovy
Created May 29, 2017 13:53
Show Gist options
  • Save jeffreyolchovy/744966a1e8c9fa14369359a3daeab46b to your computer and use it in GitHub Desktop.
Save jeffreyolchovy/744966a1e8c9fa14369359a3daeab46b to your computer and use it in GitHub Desktop.
// The one input task that will be available to our plugin users, by default
tweeterTweet := {
val log = streams.value.log
val tweet = spaceDelimited("<text of tweet>").parsed.mkString(" ")
val consumerKey = tweeterConsumerKey.value
val consumerSecret = tweeterConsumerSecret.value
val accessToken = tweeterAccessToken.value
val accessTokenSecret = tweeterAccessTokenSecret.value
val client = TweeterService(consumerKey, consumerSecret, accessToken, accessTokenSecret)
client.post(tweet) match {
case Success(tweetId) => log.info(s"""Successfully tweeted: "$tweet" ($tweetId)"""); tweetId
case Failure(e) => sys.error("An error was encountered when trying to tweet: " + ErrorHandling.reducedToString(e))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment