Send Tweet from Kit, provides a way to send a tweet directly from Kit. When the script is run it will ask you to enter a tweet then it will run sentiment analysis on the tweet. If the tweet is positive it will be posted, if it's negative you will be prompted to confirm the send.

// Shortcut: opt t
let Twitter = await npm('twitter-lite');
let Sent = await npm('sentiment');
let envOptions = {
hint: md(
`You need to [create an app](https://developer.twitter.com/en/apps) to get these keys/tokens`,
),
ignoreBlur: true,
secret: true,
}
let client = new Twitter({
consumer_key: await env('TWITTER_CONSUMER_KEY', envOptions),
consumer_secret: await env('TWITTER_CONSUMER_SECRET', envOptions),
access_token_key: await env('TWITTER_ACCESS_TOKEN_KEY', envOptions),
access_token_secret: await env('TWITTER_ACCESS_TOKEN_SECRET', envOptions),
});
const sentiment = new Sent();
let tweet = await arg("what's on your mind?");
const { score } = sentiment.analyze(tweet);
const isNeg = score < 0;
let shouldPost = await arg("Thats a little 🧂y", [
{ name: "yeah I know sean anyway", value: true },
{name: "oh yeah don't post that", value: false },
])
if (shouldPost) {
await client.post('statuses/update', {
status: `Random thought: ${tweet}`,
}).catch(error => console.log(error));
}