Jump to content
McKay Development

Recommended Posts

Posted

Hello I am having an issue when using steam-user. I am getting stuck in a loop with steamguard. It seems to work fine for non-steamguard accounts but after entering the steamguard code it will simply send me another email and prompt me for another steamguard code. I have an example script that I created and tried to upload however I just get an error message "You aren't permitted to upload this kind of file"

Hopefully someone has an idea what I'm doing wrong and/or can post an example code.

 

gtK8HWO.png

Posted (edited)

Thanks for your reply here is my code:

var fs = require("fs"),
Steam = require("steam"),
SteamUser = require("steam-user"),
//SteamID = require("steamid"),
SteamClients = {},
SteamUsers = {},
SteamFriends = {};

var text = fs.readFileSync("accounts.json").toString();
var accounts = JSON.parse(text)["accounts"];

accounts.forEach(doTheStuff);

function doTheStuff(element,indexElement,array) {
  //console.log(element["username"] + ": " + element["password"]);
  SteamClients[indexElement] = new Steam.SteamClient();
  SteamUsers[indexElement] = new SteamUser(SteamClients[indexElement]);
  SteamFriends[indexElement] = new Steam.SteamFriends(SteamClients[indexElement]);


  SteamClients[indexElement].on("connected", function(){
      SteamUsers[indexElement].logOn(
        {
          accountName: element["username"],
          password: element["password"]
        }
      );
  });

  SteamClients[indexElement].on("logOnResponse", function(res){
    if (res.eresult == Steam.EResult.OK) {
			console.log("Successfully logged on as " + element["username"])
			//Set state to offline
			SteamFriends[indexElement].setPersonaState(Steam.EPersonaState.Offline);
			//Playing CSGO
			SteamUsers[indexElement].gamesPlayed(
        {
          games_played: [{
            game_id: 730
          }]
        }
      );
    }
		else if (res.eresult == Steam.EResult.AccountLogonDenied) {
				console.log("SteamGuard Error");
		} else {
      console.log("Steam client can't connect to " + element["username"] + "\n");
      console.log(res);
      SteamClients[indexElement].disconnect();
    }
  });

    SteamClients[indexElement].on("error", function(err){
    console.log("Error! " + element["username"] + "\n");
    console.log(err);
	});

  SteamUsers[indexElement].on("error", function(err){
      console.log("Error! " + element["username"] + "\n");
      console.log(err);
  });

	SteamClients[indexElement].connect();
}

accounts.json example (it works for non-steamguard accts):

{"accounts":[
  {"username":"exampleaccount", "password":"password123"},
  {"username":"exampleaccount2", "password":"321drowssap"}
]}

Edited by sexydog
Posted

You're not really doing it right. steam-user includes everything from steam (and SteamFriends). You don't need to create SteamClient or SteamFriends objects yourself. Additionally, steam-user automatically prompts for Steam Guard codes so you don't need to handle that case yourself (although things are going to get messy if you're starting up multiple bots at the same time that need codes).

Posted (edited)

You're not really doing it right. steam-user includes everything from steam (and SteamFriends). You don't need to create SteamClient or SteamFriends objects yourself. Additionally, steam-user automatically prompts for Steam Guard codes so you don't need to handle that case yourself (although things are going to get messy if you're starting up multiple bots at the same time that need codes).

 

So just using steam-user by itself should allow this to work? Originally I was trying to use node-steam directly which is why that case is in there and I thought I did everything right but I was getting this same steamguard loop which is what led me to steam-user. I'm going to try rewriting my code without the extra seishun stuff and see if it works. Thanks for your advice.

 

EDIT: It works now, thank's dr. mckay. For anybody who comes across this thread on a google search here's the updated code:

var fs = require("fs"),
Steam = require("steam"),
SteamUser = require("steam-user"),
SteamID = require("steamid"),
readLine = require('readline-sync'),
SteamClients = {},
SteamUsers = {},
SteamFriends = {};

var text = fs.readFileSync("accounts.json").toString();
var accounts = JSON.parse(text)["accounts"];

accounts.forEach(doTheStuff);

function doTheStuff(element,indexElement,array) {
  //console.log(element["username"] + ": " + element["password"]);
  SteamUsers[indexElement] = new SteamUser();
  SteamUsers[indexElement].setOption('promptSteamGuardCode', false);
  SteamUsers[indexElement].setOption('dataDirectory', './sentry')

  SteamUsers[indexElement].on('steamGuard', function(domain, callback, lastCodeWrong){
    var code = readLine.question("Enter steamguard code from " + element["username"] + '(' + domain + ')');
    callback(code);
  });

  SteamUsers[indexElement].on("loggedOn", function(details, parental) {
    console.log("Logged on as " + element["username"] + " successfully");
    console.log(details);
    console.log(parental);
  });

  SteamUsers[indexElement].on("error", function(err){
      console.log("Error! " + element["username"]);
      console.log(err);
  });

  SteamUsers[indexElement].on("disconnect", function(err) {
    console.log("Disconnected from " + element["username"]);
    console.log(err);
  });

  SteamUsers[indexElement].logOn(
    {
      accountName: element["username"],
      password: element["password"]
    }
  );
}

Edited by sexydog

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...