tjs.loginAsync(username, password).done( // success! function (result) { if (!result.authToken) { console.error("Login failed!".red); process.exit(1); } var token = JSON.stringify(result.body); if (token) { console.log("Login " + "Successfull.".green); // console.log("OAuth token is: " + token.green); fs.writeFileSync('.token', token, 'utf8'); console.log('Auth token saved!'); } }, // failure! function (error) { console.error(error); } );
_connect() { this._debug("Connecting...") this.afterConnected = new Promise((fulfill, reject) => { this._refreshToken().then(() => { this._refreshWebsocket().then(() => { fulfill() }, reject) }, reject) }) this.afterConnected.done(() => { this.ready = true this.emit('connect') this._stopSelfHeal() if (["iex", "cryptoquote", "fxcm"].includes(this.options.provider)) { this._refreshChannels() } }, () => { this.ready = false this._trySelfHeal() }) return this.afterConnected }