Snow Posted August 24, 2021 Report Posted August 24, 2021 (edited) I am using express.js and try to log all my bots in according to requests made from my python server. I can successfully make my bots logged into steam but can't get returned message (it just returns undefined) to send back to server. My code looks like this: const accounts = [] function addAccount(username, password, twoFactorCode){ const client = new SteamUser(); const community = new SteamCommunity(); const manager = new TradeOfferManager({ steam: client, community: community, language: 'en', cancelTime: 300000, pendingCancelTime: 30000 }); const logOnOptions = { accountName: username, password: password, twoFactorCode: SteamTotp.generateAuthCode(twoFactorCode), }; client.logOn(logOnOptions); client.on('loggedOn', ()=> { //console.log("success") }) client.on('webSession', (sessionid, cookies) => { console.log(sessionid, cookies); manager.setCookies(cookies, function(err){ if (err) { console.log(err); return err }else{ console.log("Got API key: " + manager.apiKey); return "success"; } }); community.setCookies(cookies); }); community.on('sessionExpired', () => { client.webLogOn(); }); accounts.push({"client":client, "community":community, "manager": manager}) } app.post('/log', (req, res) => { if (accounts.length === 0){ var json_data = req.body json_data.forEach(element => { var answer = addAccount(element["user_name"], element["password"], element["secret"]) }) }else{ } res.json({ "answer": answer }) }) Edited August 24, 2021 by Snow Quote
Dr. McKay Posted August 26, 2021 Report Posted August 26, 2021 (edited) accounts is always going to be empty when your /log listener executes, so no accounts will get added and nothing will be returned. I misread the code. Edited September 1, 2021 by Dr. McKay Quote
Snow Posted September 1, 2021 Author Report Posted September 1, 2021 On 8/26/2021 at 8:52 PM, Dr. McKay said: accounts is always going to be empty when your /log listener executes, so no accounts will get added and nothing will be returned. I am still using express js and can get accounts array without a problem. What would you suggest instead of adding them to array ? Quote
Dr. McKay Posted September 1, 2021 Report Posted September 1, 2021 I misread your code the first time. Looks like your problem is actually that addAccount doesn't return anything. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.