Something went wrong. Try again.
Your trusty automation assistant in TLE Community misadventures!
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738import readline from 'readline'
import lacuna from './client'import call from './call'import log from './log'
/** * Fetch a captcha and prompt for the answer on stdin, then solve it. Replaces * `lacuna.captcha.prompt`. * * A no-op in the browser - the web config screen (`task-configs/helpers/captcha.vue` * + `stores/captcha.js`) handles captchas there. * * @return {Promise<void>} */export default function captchaPrompt() { if (typeof window === 'object') { return Promise.resolve() }
return call(() => lacuna.captcha.fetch()).then((captcha) => { log.info(`Please solve captcha from url: ${captcha.url}`)
return new Promise((resolve, reject) => { const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
rl.question('Captcha answer: ', (answer) => { rl.close()
// NOTE: getting the answer wrong kills the whole script. Whatever. call(() => lacuna.captcha.solve({ guid: captcha.guid, solution: answer })) .then(resolve) .catch(reject) }) }) })}