Jump to content
Sign in to follow this  
Xenu

Zapisywanie kont z sentry code w osobnym pliku i używanie ich. NodeJS

Recommended Posts

Cześć, mam skrypt Node JS. Wszystko dobrze działa, jednak są dwie rzeczy, których nie potrafie dodać.

1. Podczas dodawania konta chciałbym aby zostało zapisane w innym pliku wraz z Sentry code,by mogło się logować. Pomyślałem zeby użyć .json. (kod na dole). Od razu chciałbym zeby po dodaniu konta komentarze wystawiły wszystkie już zapisane konta. Wiem, ze gdybym takie coś dodał to zawsze po włączeniu skryptu musiałbym dodać jakieś konto, ale to nie problem.

var SteamCommunity = require('steamcommunity');
var ReadLine = require('readline');
var fs = require('fs');
var SteamID = require("steamid");
var banshee = 'steamid';
var comments = [a,b,c,d];    
var rand = Math.floor(Math.random() * comments.length);
var concat = comments[rand];
var community = new SteamCommunity();
var steamID = new SteamID(banshee);
var rl = ReadLine.createInterface({
  "input": process.stdin,
  "output": process.stdout
});
rl.question("Username: ", function(accountName) {
  rl.question("Password: ", function(password) {
    doLogin(accountName, password);
    )};
              });
  fnuction doLogin(accountName, password, authCode, captcha) {
    community.login({
      "accountName": accountName,
      "password": password,
      "authCode": authCode,
      "captcha": captcha
    }, function(err, sessionID, cookies, steamguard) {
      if(err) {
        if(err.message == 'SteamGuard') {
          console.log("An email has been sent to your address at " + err.emaildomain);
          rl.question("Steam Guard Code: ", fnuction(code) {
                      doLogin(accountName, password, code);
        });
        return;
      }
      if(err.message == 'CAPTCHA') {
        console.log(err.captchaurl);
        rl.question("CAPTCHA: ", function(captchaInput) {
          doLogin(accountName, password, null, captchaInput);
        });
        return;
      }
      console.log(err);
      process.exit();
      return;
    }
                    console.log("Logged on!");
    community.getSteamUser(steamID, function(err, user) {
      if(err) console.log(err);
      else {
        user.comment(concat, function(err) {
          if(err) console.log(err);
        });
        console.log("Comment posted!");
        setTimeout(function() {
          process.exit();
        }, 2000);
      }
    });
  });
}

Database.json

SteamCommunity = require 'Steamcommunity'
jsonfile  = require 'jsonfile'
jsonfile.spaces = 2
try
  database = jsonfile.readFileSync 'database.json'
catch e
  database = {}
  secret = null
  inquirer.prompt [
{name: 'username', message: 'Username:'}
{name: 'password', message: 'Password:', type: 'password'}
  ]
  .then ({username, password}) ->
    database[username] = {}
client = new SteamUser
client.setOption 'promptSteamGuardCode', false
client.setOption 'dataDirectory', null
client.logOn
accountName: username,
  password: password,
    client.on 'steamGuard', (domain, callback) ->
      if domain
      inquirer.prompt [name: 'code', message: "Steam guard code (#{domain}):"]
        .then ({code}) -> callback code
      else
        inquirer.prompt [name: 'secret', message: 'Two-factor shared secret:']
          .then ({secret}) ->
          SteamTotp.generateAuthCode secret, (err, code) ->
            database[username].secret = secret
callback code
client.on 'sentry', (sentry) ->
  database[username].sentry = sentry.toString('base64')
jsonfile.writeFileSync 'database.json', database
client.on 'LoggedOn', (Details) ->
  database[username].password = password
process.exit 1

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Create a New Account. It’s free and easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×
×
  • Create New...