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));
}