Skip to content

Instantly share code, notes, and snippets.

@av
Created November 22, 2019 11:53
Show Gist options
  • Save av/3dc8dd83f9023aa991c1969454762912 to your computer and use it in GitHub Desktop.
Save av/3dc8dd83f9023aa991c1969454762912 to your computer and use it in GitHub Desktop.
Now: twi-bot, twitter service
const Twitter = require('twitter-lite');
const {
CONSUMER_KEY,
CONSUMER_SECRET,
ACCESS_TOKEN_KEY,
ACCESS_TOKEN_SECRET,
} = process.env;
const client = new Twitter({
subdomain: 'api',
consumer_key: CONSUMER_KEY,
consumer_secret: CONSUMER_SECRET,
access_token_key: ACCESS_TOKEN_KEY,
access_token_secret: ACCESS_TOKEN_SECRET
});
module.exports = {
tweet
};
/**
* Tweets given tween on behalf of user configured
* by env variables
*
* @param {String} status
* @returns {Promise}
*/
async function tweet(status) {
return client.post('statuses/update', { status });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment