Jump to content
McKay Development

Vizzy

Member
  • Posts

    8
  • Joined

  • Last visited

Posts posted by Vizzy

  1. I'm doing something very simple but I always get HTTP error 404 when calling `offer#cancel`.

    Snippet

            this.manager.getOffer(offer.id, (err: unknown, offer: any) => {
              if (err) {
                logger.error(err);
                return logger.info('Failed to obtain offer, it cannot be cancelled.');
              }
    
              logger.info(`Obtained offer ${offer.id} for cancellation.`);
    
              offer.cancel((err: unknown) => {
                if (err) {
                  logger.error(err);
                  return logger.info(`Offer ${offer.id} failed to cancel.`);
                }
    
                logger.info(`Offer ${offer.id} has been cancelled.`);
              });
            });

    Is steam broken? Package outdated? Am I doing something wrong? 

    Error

    error: HTTP error 404 - Error: HTTP error 404
        at SteamCommunity._checkHttpError (C:\Users\Martijn\Desktop\coding\trade-bot\node_modules\steamcommunity\components\http.js:108:9)
        at Request._callback (C:\Users\Martijn\Desktop\coding\trade-bot\node_modules\steamcommunity\components\http.js:50:61)
        at Request.self.callback (C:\Users\Martijn\Desktop\coding\trade-bot\node_modules\request\request.js:185:22)
        at Request.emit (events.js:315:20)
        at Request.<anonymous> (C:\Users\Martijn\Desktop\coding\trade-bot\node_modules\request\request.js:1154:10)
        at Request.emit (events.js:315:20)
        at IncomingMessage.<anonymous> (C:\Users\Martijn\Desktop\coding\trade-bot\node_modules\request\request.js:1076:12)
        at Object.onceWrapper (events.js:421:28)
        at IncomingMessage.emit (events.js:327:22)
        at endReadableNT (_stream_readable.js:1327:12)

     

  2. I've made a thread about this a few months ago but back then I managed to get it working. However, I now need to implement the same thing and I cannot get it to work. I'm simply trying to refresh the session after it has expired. I'm attempting this by manually invalidating the cookies, the event is never called.

    Code

    const SteamUser = require('steam-user');
    const SteamCommunity = require('steamcommunity');
    const SteamTotp = require('steam-totp');
    const TradeOfferManager = require('steam-tradeoffer-manager');
    
    const client = new SteamUser();
    const community = new SteamCommunity();
    const manager = new TradeOfferManager({
      community: this.community,
      language: 'en',
    });
    
    client.logOn({ ... })
    
    client.on('loggedOn', () => {
      console.log('bot has logged into steam.');
      client.setPersona(SteamUser.EPersonaState.Online);
    });
    
    client.on('webSession', (session, cookies) => {
      manager.setCookies(cookies);
      community.setCookies(cookies);
    
      console.log('websession established');
    });
    
    client.on('error', (err) => console.log(err));
    
    community.on('sessionExpired', () => {
      console.log('session has expired');
    });
    
    setTimeout(function () {
      console.log('attempting to kill session');
      community.setCookies(['sessionid=1||invalid', 'steamLogin=1||invalid', 'steamLoginSecure=1||invalid']);
      manager.setCookies(['sessionid=1||invalid', 'steamLogin=1||invalid', 'steamLoginSecure=1||invalid']);
    
      // make void call to trigger sessionExpired
      community.getNotifications((err, notifications) => console.log(err ? 'sessionExpired should be triggered now' : notifications));
    }, 10 * 1000);

    What am I missing? I would presume after calling getNotifications (for testing purposes) the sessionExpired event would be fired.

  3. Hi, I'm running a couple of steambots but when one of the bots receives an error like TooManyRequests or LogonSessionReplaced the application crashes. I would like it not to crash, as I have a couple of other bots running as well (process.exit() is being used in the modules?).

    How can I stop this from happening?

  4. 6 hours ago, Dr. McKay said:

    Have you tried making any requests after you set your cookies to invalid values? It can't know the session has expired until it tries to make an authenticated request and Steam redirects us back to the login page.

    Huge facepalm right there, I even remember reading about it on the docs. Thanks, that's it, I never initiated anything to trigger the event.

  5. Hi,
    I'm trying to forcefully kill the cookies so that it will trigger the sessionExpired event. However, this does not seem to happen. I cannot get the sessionExpired event to trigger and after some digging around I'm unsure what I could have done wrongly.

    Code
     

    // Scripts
    const config = require('../config');
    
    // Modules
    const fs = require('fs');
    const SteamCommunity = require('steamcommunity');
    const SteamTotp = require('steam-totp');
    const TradeOfferManager = require('steam-tradeoffer-manager');
    const SteamUser = require('steam-user');
    
    // States
    let community = new SteamCommunity();
    let client = new SteamUser();
    let manager = new TradeOfferManager({
      steam: client,
      pollInterval: 5000,
      community
    });
    
    let { username, password, secret } = config.settings.platforms.steam.authentication;
    let options = {
      accountName: username,
      password,
      twoFactorCode: SteamTotp.generateAuthCode(secret.shared)
    }
    
    client.logOn(options);
    
    client.on('loggedOn', () => {
      console.log('bot has logged in');
    
      client.gamesPlayed(730);
      client.setPersona(SteamUser.EPersonaState.Online);
    });
    
    client.on('webSession', (session, cookies) => {
      manager.setCookies(cookies, function(err) {
        if(err) console.error(err);
        console.log('got api key');
      });
      community.setCookies(cookies);
    });
    
    // sessionexpired never
    community.on('sessionExpired', (err) => {
      console.log('SESSION EXPIRED');
    
      // do webLogOn with delay
    });
    
    // manual kill the session
    setTimeout(function() {
      console.log('killing session..');
      community.setCookies(["sessionid=1||invalid", "steamLogin=1||invalid", "steamLoginSecure=1||invalid"]);
    }, 35 * 1000);

     

×
×
  • Create New...