Jump to content
McKay Development


  • Posts

  • Joined

  • Last visited

Everything posted by Barak

  1. Hey McKay, loving the work that you've done for the steam and JS communities. I've been using your `steamcommunity` package, but I've ran into this weird problem. I want to use the `getSteamUser` method on the community class. My user is logged in via a Passport Steam strategy and that returns an object after the user logs in that looks like this: this is my account. Right, so I deserialize this data in a session and work with the `steamid` property since that is the only one I need to perform actions etc. But, when trying to use `getSteamUser` with this steamId it throws `Cannot find user`. I realize that it wants a steamID object or a URL as specified here id - Either a SteamID object or a user's URL (the part after /id/)\ but even when calling by my URL which in the above case it's `psychoqt` manually I get this back: Now as you can see the steamID object is filled with universe type etc, but the accountID is different. It is not the steam ID. Even if I compose this object myself, I would be missing the accountid from the previous payload. The only solution I can see here is to parse `profileurl` and take everything right from `/id/` but it seems kinda hacky and inconsistent. Is there any other way I could go around this? Thanks,, Filip
  2. Fixed it, apparently I've been initializing a new SteamCommunity object in my main file. Thanks anyway, explaining this to someone really cleared my mind up Cheers!
  3. Thanks for the prompt response. I'm making the withdraw request from a website. When a user clicks on an item it withdraws it from the bot's inventory, which should mean the steam user is logged on. Here's a log: {"message":"Logged into steam as **********","level":"info"} {"message":"Currently 0,09€ Steam Wallet credit. ","level":"info"} {"message":"Is limited: false. Is cBanned false.\n Can Invite Friends: true, Is Locked: false","level":"info"} {"message":"Client Connected as WEBSITE_USER.","level":"debug"} {"message":"User WEBSITE_USER has a wallet of 45 eur","level":"info"} {"message":"Session Initialized.","level":"debug"} {"message":"Cookies, sessionid=5***,steamLogin=7****,steamLoginSecure=7****","level":"debug"} {"message":"Trade cookies set. API KEY: 5*****","level":"info"} {"message":"Updating Inventory collection...","level":"debug"} {"message":"Length of __BOT__ items: 439","level":"debug"} {"message":"Updated Inventory for Bot with id: 7****","level":"info"} WEBSITE_USER wants to withdraw assetid {"message":"TradeOffer: 3811117774 true","level":"debug"} Error: Must be logged in before trying to do anything with confirmations The withdraw happened a while (30sec?) after I started the server. This is how I set the cookies: this.client.on('webSession', (sessionid: any, cookies: any) => { logger.debug('Session Initialized.'); logger.debug(`Cookies, ${cookies}`); this.manager.setCookies(cookies, (err: any) => { /* Cannot set cookies on, as it is still limited account */ if (err) { logger.error(`Unable to set trade cookies: ${err}`); return; // process.exit(1); } logger.info(`Trade cookies set. API KEY: ${this.manager.apiKey}`); /* Gets all of the Bot's inventory and stores it into inventory Collection Momentarily only for the Bot's Dota 2 inventory. */ this.fillInventoryOnInit(); /* Accepts all friend requests. Logs unfriends. */ this.initFriendRequestListener(); /* Listens to a chat message from a user. Currently supports only !help */ this.onFriendMessageListener(); /* Accepts all pending requests and logs all messages that occured while bot was offline */ this.checkFriendsAndMessagesWhileOffline(); /* Logs all new offers, and accepts only if its a donation or the trader is the admin*/ this.initNewOfferListener(); }); this.community.setCookies(cookies); this.community.startConfirmationChecker(10000, process.env.STEAM_IDENTITY_SECRET); }); and this is the withdraw implementation public sendWithdrawTrade(partner: any, credits: any, assetid: any, gameid: any, cb: Function) { console.log(assetid, gameid); const offer = this.manager.createOffer(partner); this.manager.getInventoryContents(gameid, RequestConfig.contextid.GAMES, true, (err: any, inv: any) => { if (err) { return logger.error(`Failed while fetching inventory with ${err}`); } const foundItem = inv.find((item: any) => item.assetid === assetid); if (foundItem) { offer.addMyItem(foundItem); offer.setMessage('Withdraw item.'); offer.send((offerError: any, status: any) => { cb(offerError, (status === 'sent' || status === 'pending'), offer.id, foundItem); }); } else { return cb(new Error('Could not find item'), false); } }); } Maybe it has something to do with the web request not sending the cookies through the socket, but I doubt it... This also fires (as it appears in the log above): /* Fires if succesfully logged in */ this.client.on('loggedOn', () => { logger.info(`Logged into steam as ${this.client.steamID}`); // Sets the Bot status to 'Looking To Trade' this.client.setPersona(EPersonaState.LookingToTrade); // game.id(570) = Dota 2; // Can set only free games. Or paid games that Bot Owns. this.client.gamesPlayed(RequestConfig.appid.DOTA2); }); Sorry for the long reply, don't really know where to go from here. One thing to mention is that the offers are stuck on `Waiting Mobile Confirmation` or something when I check them manually through Steam. Thanks!
  4. Hi McKay, great fan of your work. I've recently encountered a problem which I do not know how to solve (maybe I'm not informed well enough on how Steam works). Here's the full stack of the problem: Error: Must be logged in before trying to do anything with confirmations at request (/home/f/code/f/node_modules/steamcommunity/components/confirmations.js:247:9) at SteamCommunity.getConfirmations (/home/f/code/f/node_modules/steamcommunity/components/confirmations.js:17:2) at doConfirmation (/home/f/code/f/node_modules/steamcommunity/components/confirmations.js:182:8) at /home/f/code/f/node_modules/steamcommunity/components/confirmations.js:170:4 I am logged in for sure, as I'm trying to trade from the web site I am creating. This is more or less the code for withdraw: socket.on('withdraw', (data: ItemData) => { console.log(`${userObject.personaname} wants to withdraw ${data.assetid}`); bot.sendWithdrawTrade(userObject.steamid, userObject.wallet, data.assetid, data.appid, (err: any, status: any, tradeOffer: TradeOffer, foundItem: Item) => { if (err && !status) { logger.error(`Error getting withdraw trade from ${userObject.personaname} because ${err}`); socket.emit('withdraw', { error: err, }); } else { if (status) { community.acceptConfirmationForObject(process.env.STEAM_IDENTITY_SECRET, tradeOffer.id, (offerError: any) => { if (err) { logger.error(`Error Accepting ${offerError}`); } else { // Update inventory for given item. } }); } else if (status === 'success') { // Update inventory } logger.debug(`TradeOffer: ${tradeOffer} ${status}`); socket.emit('withdraw', { tradeOffer }); } }); }); I'm not really sure what's going on here. I am very much logged in like so: const loginOptions = { accountName: process.env.STEAM_USER_NAME, password: process.env.STEAM_USER_PASSWORD, twoFactorCode: SteamTotp.generateAuthCode(process.env.STEAM_SHARED_SECRET) }; and the logged in functionalities have never been a problem until now. Thanks for any help and sorry for taking your time. Barak
  • Create New...