-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
executable file
·35 lines (29 loc) · 1.2 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env node
import covfefe from 'covfefe'
import figlet from 'figlet'
import chalk from 'chalk'
import fs from 'fs-extra'
import tokenExists from './lib/tokenExist'
import makeNewToken from './lib/newtoken'
import generateTwit from './lib/twit'
const log = console.log;
const isNewLogin = () => fs.pathExists('./data.json')
const donaldTrump = async () => {
log(chalk.cyan(figlet.textSync('covfefe', {horizontalLayout: 'full'})))
let answer = await isNewLogin() ? await tokenExists() : await makeNewToken()
let access_token = await fs.readJson('./data.json', { throws: false })
try {
let T = await generateTwit(access_token)
let covfefedText = covfefe(answer.status)
let result = await T.post('statuses/update', {status: covfefedText})
let userInfo = result.data.user
log(chalk.bold("\nJust sent the tweet! ") + chalk.cyan(`${userInfo.name}: "${result.data.text}"`))
log(chalk.bgBlack(`https://twitter.com/${userInfo.screen_name}/status/${result.data.id_str}`))
process.exit(0)
} catch (e) {
console.error("Failed to update your status: ", e)
console.log(result.data)
process.exit(0)
}
}
donaldTrump()