quer / the-steam-awards

Steam multi account module/event (get updates when event for steam)
96 stars 13 forks source link

Adding steam accounts info from a txt ? #18

Closed SENPAY98K closed 3 years ago

SENPAY98K commented 3 years ago

Is there any possibility to request accounts from a text file with the format username:password:sharedsecret instead of manually filling config everytime.

quer commented 3 years ago

Hey, I have create a small script to convert the typed you sayed into the config file.

const fs = require('fs');
const data = fs.readFileSync('./test.txt', {encoding:'utf8', flag:'r'});
var endString = "var config = [];\n";
const loginRows = data.split("\n");
for (let i = 0; i < loginRows.length; i++) {
    const login = loginRows[i];
    const loginInfo = login.split(":")
    if(loginInfo.length = 3){
        endString += `config.push({
            steam_user: "${loginInfo[0]}",
            steam_pass: "${loginInfo[1]}",
            sharedSecret: "${loginInfo[2]}"
        });\n`;
    }
}
endString += "module.exports = config;";
console.log(endString); 

Might need to chance the data.split("\n"); to data.split("\r\n"); base on your file ( you will know if it add \r in the end of the sharedSecret code. Then just copy the console log into the config.js file. If this is somefing you do offen, then create a new js file in the main folder, and add

fs.writeFile('config.js', endString, err => {
    if (err) {
      console.error(err)
      return
    }
    //file written successfully
  })

to the end of the file, then you just have to run that file, to convert them into the config file

SENPAY98K commented 3 years ago

Thanks for the help, I will try to do it, as i am not really into this things :)

SENPAY98K commented 3 years ago

image I could not make it run :/

quer commented 3 years ago

image I could not make it run :/

what did the console say?

quer commented 3 years ago

What you have to do , is in the root folder, create new file eks, ConvertToConfig.js And place my code into it

const fs = require('fs');
const data = fs.readFileSync('./test.txt', {encoding:'utf8', flag:'r'});
var endString = "var config = [];\n";
const loginRows = data.split("\r\n");
for (let i = 0; i < loginRows.length; i++) {
    const login = loginRows[i];
    const loginInfo = login.split(":")
    if(loginInfo.length = 3){
        endString += `config.push({
            steam_user: "${loginInfo[0]}",
            steam_pass: "${loginInfo[1]}",
            sharedSecret: "${loginInfo[2]}"
        });\n`;
    }
}
endString += "module.exports = config;";
console.log(endString); 

fs.writeFile('config.js', endString, err => {
    if (err) {
      console.error(err)
      return
    }
    //file written successfully
  })

and then replace the part test.txt whit the txt file whit all the logins in.

and then just in the cmd in that folder run node ConvertToConfig.js and it will convert the logins into the config file. and then you can use it.

SENPAY98K commented 3 years ago

Thanks works just in a sec