Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var SteamCommunity = require("steamcommunity");
- var SteamIDs = require('steamid');
- var community = new SteamCommunity();
- var readline = require("readline");
- var settings = require('./settings');
- var request = require('request');
- var community = new SteamCommunity();
- var getSteamAPIKey = require('steam-web-api-key');
- var fs = require('fs');
- var rl = readline.createInterface({
- input: process.stdin,
- output: process.stdout
- });
- var username = settings.user;
- var password = settings.password;
- var steamCode;
- relog();
- function relog()
- {
- if (require('fs').existsSync('steamguard'+username+'.hash') && require('fs').existsSync('oauthtoken'+username+'.hash')) {
- var steamguard, oauthtoken;
- fs.readFile('steamguard'+username+'.hash', 'utf8', function (err,data) {
- if (err) {
- return console.log(err);
- }
- console.log(data);
- steamguard = data;
- fs.readFile('oauthtoken'+username+'.hash', 'utf8', function (err,dat) {
- if (err) {
- return console.log(err);
- }
- console.log(dat);
- oauthtoken = dat;
- community.oAuthLogin(steamguard , require('fs').readFileSync('oauthtoken'+username+'.hash'), function(err, sessionId, cookies)
- {
- if(err)
- {
- console.log(err);
- return;
- }
- console.log('Logged to community');
- console.log('Wait 10sec');
- setTimeout(function(){
- startIt();},10000);
- })
- });
- });
- }
- else
- {
- login();
- function login() {
- community.login({
- "accountName": username,
- "password": password,
- }, function(err, sessionId, cookies, steamguard) {
- if (err) {
- console.log(err);
- rl.resume();
- rl.question("SteamGuard code: ", function(answer) {
- steamCode = answer;
- rl.pause();
- community.login({
- "accountName": username,
- "password": password,
- "authCode": steamCode
- }, function(err, sessionId, cookies, steamguard, oAuthToken) {
- if (err) {
- } else {
- getSteamAPIKey({
- sessionID: sessionId,
- webCookie: cookies
- }, function(err, APIKey) {
- if(err) return;
- apik = APIKey;
- startIt();
- });
- require('fs').writeFileSync('steamguard'+username+'.hash', steamguard);
- require('fs').writeFileSync('oauthtoken'+username+'.hash', oAuthToken);
- community.chatLogon();
- community.loggedIn(function(err, loggedIn){
- console.log(err);
- console.log(loggedIn);
- })
- };
- });
- });
- } else {
- getSteamAPIKey({
- sessionID: sessionId,
- webCookie: cookies
- }, function(err, APIKey) {
- if(err) return;
- apik = APIKey;
- startIt();
- });
- };
- });
- };
- }
- }
- //Offers handling
- function startIt(){
- var sid = new SteamIDs('103582791440532314');
- console.log(sid);
- community.getGroupMembers(sid, function(error, response){
- if(error)
- {
- console.log(error);
- if(error.indexOf('403')>0)
- {relog()}
- else
- {startIt()};
- return;
- }
- var length = 0;
- if(response.length>1000)
- {length = 1000;}
- else
- {length=response.length}
- for(var i = 0; i < length; i++ )
- {
- invite2(response[i]);
- }
- });
- }
- function invite2(steamid)
- {
- community.getSteamUser(steamid, function(err, response)
- {
- if(err)
- {
- console.log(err);
- return;
- }
- response.inviteToGroup('103582791441479782', function(error, resp)
- {
- if(error == null)
- {
- console.log(steamid + ' was invited to group!');
- }
- else
- {
- console.log(error);
- }
- })
- } , 4000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement