Jump to content
McKay Development

nickmura aka bobby

Member
  • Posts

    9
  • Joined

  • Last visited

Posts posted by nickmura aka bobby

  1. I've upgraded to the latest package and my types say that the steamTradeOfferManagerr does not have the `useAccessToken` property. Any ideas? The event listener just literally doesn't listen for new trades all of a sudden lmfao

    On 4/4/2024 at 1:14 PM, loganWP said:

    You need to update package to latest version and add useAccessToken: true to your constructor :)

    Like this 

     

    this.steamTradeofferManager = new steamTradeofferManager({
            domain: "localhost",
            language: "en",
            community: this.steamcommunity,
            pollInterval: steamTradeofferManagerPollInterval,
            useAccessToken: true
        });

     

  2. 2 hours ago, Dr. McKay said:

    You need to provide the asset owner's SteamID as well. The linked repository only indicates that S is optional because you need either S or M (M is used for market listings).

    Okay, that individual item endpoint works, but now I realize a bulk method is more important as iteratively calling this endpoint is quite inefficient, and can take up to 5 minutes with an extremely large inventory, so I require the actual steam inspect link via the /bulk POST endpoint.

    What I did was replace the %owner_steamid% , and %assetid% keywords in the inspect link, so instead of it looking like 

     

    steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S%owner_steamid%A%assetid%D10281089380224386840


    it now looks like
     

    steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S76561198107078290A36862217483D10281089380224386840

     

     

    now it works beautifully. Thanks!


  3.  

    I am intending to append the float value for each item in a CEconItem[], and I needed the inspect link in order to access this data, for the https://github.com/csfloat/inspect repository. It states that we need the A, D properties in order to call the endpoint, or a valid inspect link.


    However, the inspect link returns a value like this from the .actions[] array,

    steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S%owner_steamid%A%assetid%D9405817623045777193


    the S, and A properties are just filled in with a placeholder, which results in an invalid inspect link and I'm wondering how to resolve this.

    I tried to derive the A property from the a assetid property on CEconItem (having A & D properties seems to be sufficient) , however the link was still not valid using the tool mentioned above. WIth a valid inspect link


    Let me know what you think

     

     

  4. On 11/13/2023 at 8:14 PM, Dr. McKay said:

    ISteamEconomy/GetAssetClassInfo includes owner_descriptions, which will tell you when an item becomes tradable.

    To reiterate OP, would this be a sufficient method to call for each item in an inventory? Would it be expensive to call this endpoint, 700 times while iterating an inventory? Wouldn't I get rate limited? We want a property to identify the trade hold duration for each item if there is one.

     

    Edit: Fixed, missing property on getInventroyContents, `tradableOnly` was set to true, 😭
     

  5. I'm trying to make a function called getKeyBalance, which should return the the amount of a specific item a user has in their inventory.

     

    export const getKeyBalance = (manager:TradeOfferManager) => { // returns bots key balance
        const TF2_KEY_CLASSID = '101785959'
        let keys = 0
        manager.getInventoryContents(TF2_APPID, INV_CONTEXT_ID, true, (err, inv) => {
            if (!err) {
                for (let i = 0; i != inv.length; i++) {
                    let item = inv[i]
                    if (String(item.classid) == TF2_KEY_CLASSID) keys++;
                } console.log('manager.getInventoryContents() keys value:', keys)
                return keys
            } else {
                console.log('getUserKeyBalance error:', err)
                return 0
            }
        });
    }

    I'm calling it in another function, called `sendBuyOffer()`,

     

    export const sendBuyOffer = async (manager:TradeOfferManager, withdraw:any) => {
        const keys = getKeyBalance(manager);
        console.log('getKeyBalance returns', keys)
        if (Number(keys) <= withdraw.keys) {
            createTradeOffer(manager, withdraw)
        }
    }
    
    const createTradeOffer = (manager:TradeOfferManager, withdraw:any) => {
        const offer = manager.createOffer(withdraw.steamid)
        manager.getInventoryContents(TF2_APPID, INV_CONTEXT_ID, true, (err, inv) => {
            if (!err) {
                let keys = 0
                for (let i = 0; i != inv.length; i++) {
                    let item = inv[i]
                    if (String(item.classid) == '101785959') {
                        offer.addMyItem(item);
                        keys++;
                    } if (keys == withdraw.keys) break
                }
                offer.send((err, status) => {
                    if (err) {
                        console.log(err);
                        return false;
                    } else {
                        console.log(`Sent offer. Status: ${status}.`);
                        return true
                    }
                });
            } return false
        });
    }



    However, the condition below the `getKeyBalance()` call never runs, because the function doesn't return a value in time. 

    image.png.4de2edd9021bc4d593153505cbce0f53.png

    As you can see, the returned value for `getKeyBalance()` is undefined, because the manager.getInventoryContents() doesn't return a value in time.

    Why isn't this method asynchronous? It would fix this problem entirely. 
    How else can I fix this, without running all the logic at once?



     

  6. 7 minutes ago, Dr. McKay said:

    Using steam-user in a serverless environment is really not a good idea, unless your environment runs very infrequently.

    the logOff() method isn't doing anything for you because you're calling it synchronously right after logOn(). logOff() does nothing if not already logged on. You'd need to call client.logOff() inside your doTradeStuff method, at the end after everything has been done.

    The test successfully logs in, and logOff is not an asynchronous method I thought?
    Anyways, your opinion is much better than mine, and if it's not a good idea to have a serverless backend, then I don't need to log out I guess. do you think you could you elaborate a bit on why it's bad? Thx

  7. Hello, I'm trying to refactor my service in Svelte-kit, and I've been running into quite tedious errors when testing and initializing a user.

    Here is a quick test when a user sends a post request, which would initialize the user, run some business logic, and then log off. 

    I've ran essentially the same code in an express environment, with the same environment variables, which worked fine.

    export const POST = async ({request:request}) => {
      //TODO
    
      const client = new SteamUser();
      const community = new SteamCommunity();
      const manager = new TradeOfferManager({
        steam: client,
        community: community,
        language: 'en',
      });
    
      const cred = {
        accountName: STEAM_NAME,
        password: STEAM_PASS,
        twoFactorCode: SteamTotp.generateAuthCode(STEAM_SHARED),
        logonID: 12345
      };
    
    
      client.logOn(cred); // logging on 
      client.on('loggedOn', async () => {
        console.log('logged into steam');
        client.setPersona(SteamUser.EPersonaState.Online)
      })
    
      client.on('webSession', (sessionid, cookies) => {
        manager.setCookies(cookies);
        community.setCookies(cookies);
        community.startConfirmationChecker(12500, STEAM_IDENTITY);
      })
      
      async function doTradeStuff() {
        //TODO
      } //await doTradeStuff()
      
      client.logOff(); // logging off
    
      client.on('disconnected', async (eresult, msg) => {
        console.log('logged off steam', eresult, msg)
      })
    
      return json({place: 'holder'})
    }

    Firstly, in all of the iterations I've made, I keep getting this `Error: LogonSessionReplaced 34`, which your documentation states could be mitigated / prevented by the logonID property when using the logOn method https://github.com/DoctorMcKay/node-steam-user#logondetails. However the issue still persists.

     

    Secondly, the logOff method never runs in the serverless environment, as I do not get a disconnected event. https://github.com/DoctorMcKay/node-steam-user#disconnected

     

    So, I'm looking for any guidance / hint as to where to look,  where I'm going wrong, if there's better practice, what to be aware about if I'm trying to run this in a serverless environment, etc. Thanks for your libraries. 

  8. I'm getting a similar issue but it's a 404 error. is the identity secret a bit ephemeral? Don't know exactly what it represents but, getting a 404 error.

    This code was approving confirmations just fine a month ago.

     

    client.on('webSession', (sessionid, cookies) => {
    manager.setCookies(cookies);
    community.setCookies(cookies);
    community.startConfirmationChecker(30000, process.env.STEAM_IDENTITY)
    community.on('debug', console.log);
     
    })

    Screenshot 2023-07-27 at 10.21.21 AM.png

    Screenshot 2023-07-27 at 10.24.22 AM.png

    EDIT: I updated my packages, and it's back to working normally. Fixed. Thanks!

×
×
  • Create New...