Jump to content
McKay Development

Recommended Posts

Posted

Hi Doc and all other forum members!

I'm currently implementing an feature which changes the steam bot account every 30 minutes.

const SteamUser = require("steam-user");
const SteamCommunity = require("steamcommunity");
const TradeOfferManager = require("steam-tradeoffer-manager");
const SteamTotp = require("steam-totp");

// Setup Steam Tradeoffer Manager
const client = new SteamUser();
const community = new SteamCommunity();
const manager = new TradeOfferManager({
  steam: client,
  community,
  language: "en",
  pollInterval: 30000
});

let BOT_CREDENTIALS = {};

// Start the bot switcher
async function startSwitcher() {
  BOT_CREDENTIALS = { username: "...1", password: "...1", sharedSecret: "...1", identitySecret: "...2" };
  login();
  
  // Main switcher interval
  setInterval(() => {
    // Set the new bot credentials
    BOT_CREDENTIALS = { username: "...2", password: "...2", sharedSecret: "...2", identitySecret: "...2" };

    // Logout current bot
    client.logOff();
  }, 1800000);
}

// Login the bot
async function login() {
  // Login to steam
  client.logOn({
    accountName: BOT_CREDENTIALS.username,
    password: BOT_CREDENTIALS.password,
    twoFactorCode: SteamTotp.generateAuthCode(BOT_CREDENTIALS.sharedSecret)
  });
}

// Listen for logouts
client.on("disconnected", () => {
  // If this was intentional (logout call) login with the new bot
  community.stopConfirmationChecker();
  login();
});

// Client requests session
client.on("webSession", (sessionid, cookies) => {
  manager.setCookies(cookies);
  community.setCookies(cookies);
  community.startConfirmationChecker(10000, BOT_CREDENTIALS.identitySecret); // I know this is deprecated, but couldn't find any documentation on how to do it otherwise :/
});

// Listen for new offers
manager.on("newOffer", async offer => {
  console.log("new offer!"); // This fires, while the first bot account is logged on. When switched to the second account, it stops receiving new events.
});

However, with this configuration I can't seem to make it work (the new bot will log on, but the event listeners do not fire). Do you guys have any ideas if this is possible, and if so, how would you approach this?

Thank you in advance!

Posted

Firstly, look into using acceptConfirmationForObject in place of the confirmation checker.

Secondly, you have a potential bug in using the disconnected event to log into a new account. The disconnected event can also be emitted if the connection to Steam drops temporarily but will be automatically re-established. You should probably set a flag when you call logOff() so you know if the disconnected event was in response to that.

Finally, to your main question, you should call manager.shutdown() when you log out of an account before logging into a new one. That should solve your problems.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...