-
Posts
10 -
Joined
-
Last visited
Posts posted by lll
-
-
constructor(details, db) { this.user = new SteamUser({ machineIdType: 3 }); this.community = new SteamCommunity({ request: this.request, userAgent }); this.manager = new TradeOfferManager({ steam: this.user, community: this.community, domain: process.env.logInDomain, language: 'en' }); this._jar = this.community._jar; this._logInDetails = details; this.user.on('error', () => { this.logOut(); }); this.user.on('loginKey', loginKey => db.update('Bots', { accountName: details.accountName }, { loginKey })); this.community.on('sessionExpired', () => this.completeLogin(false)); }
"steam-tradeoffer-manager": "^2.10.2"
"steam-user": "^4.16.2"
"steamcommunity": "^3.41.4"
-
This topic https://dev.doctormckay.com/topic/365-cookies/#user-cookieusage says
Quotecalling setCookies on the TradeOfferManager will also call setCookies on the SteamCommunity, and therefore you need not call setCookies on SteamCommunity (although it doesn't hurt anything, either)
after authorization (webSession emit) i call my method to set cookie:
setCookies(cookies) { return util .promisify(this.manager.setCookies) .call(this.manager, cookies); }
and then it sometimes happens when I try to call this.community.acceptConfirmationForObject:
D:\projects\terminal\node_modules\steamcommunity\components\confirmations.js:247 throw new Error("Must be logged in before trying to do anything with confirmations"); ^ Error: Must be logged in before trying to do anything with confirmations at request (D:\projects\terminal\node_modules\steamcommunity\components\confirmations.js:247:9) at SteamCommunity.getConfirmations (D:\projects\terminal\node_modules\steamcommunity\components\confirmations.js:17:2) at doConfirmation (D:\projects\terminal\node_modules\steamcommunity\components\confirmations.js:182:8) at D:\projects\terminal\node_modules\steamcommunity\components\confirmations.js:170:4 at IncomingMessage.<anonymous> (D:\projects\terminal\node_modules\steamcommunity\node_modules\steam-totp\index.js:129:4)
1. How can I handle such error messages?
2. This is fixed if you add cookies to the community yourself, I.E.
setCookies(cookies) { this.community.setCookies(cookies); return util .promisify(this.manager.setCookies) .call(this.manager, cookies); }
but it contradicts that topic
-
After I log out hrough my method
logOut() { this.manager.shutdown(); this.user.logOff(); }
there is one non-closed timer on
- (43200000 ~ 12 hr) (anonymous) @ ...\steamcommunity\components\confirmations.js:172
and therefore my program does not exit correctly
-
-
16 hours ago, Dr. McKay said:
Probably because it needs to be this.jar = request.jar()
no, this class field is not initialized through the constructor, so this is not needed
this code is equivalent of
export default class Bot { constructor(details, db) { this.jar = request.jar(); this.request = request.defaults({ jar: this.jar, headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36' } }); this.community = new SteamCommunity({ request: this.request }); } }
-
and another question, why the cookie jar is not used, which is passed in request.defaults
export default class Bot { jar = request.jar(); request = request.defaults({ jar: this.jar, headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36' } }); constructor(details, db) { this.community = new SteamCommunity({ request: this.request }); } }
after login and several requests, I can’t get Steam cookies in jar
-
request has been deprecated, so is planned to switch to another requests lib?
-
This logic will be written in the constructor. Something like this :
constructor(accountName) { this.setCookies = util.promisify(this.manager.setCookies).bind(this.manager); this.user.on('error', this.logOut); this.user.on('loginKey', loginKey => db.findOne('bot', { accountName }, { loginKey })); }
-
I have a Bot class and an async method for logIn, are there any better way for writing this method?
completeLogin(botDetails, useLoginKey) { this.user.logOn(this.details(botDetails, useLoginKey)); return new Promise((done, reject) => { const cxt = this; async function success(_, cookies) { try { await cxt.setCookies(cookies); cxt.user.off('error', failed); done(); } catch(err) { reject(err); } } function failed(err) { cxt.user.off('webSession', success); reject(err); } cxt.user.once('webSession', success); cxt.user.once('error', failed); }); }
Strange behavior of setCookies
in node-steam-tradeoffer-manager
Posted
This definitely happens after login, and most likely has something to do with the change of public IP(before relogin)