Jump to content


Photo
Question

Get steam keys from a file ?



Best Answer Dr. McKay , 27 November 2018 - 05:30 PM

The first problem I see is that you aren't handling the callback to offer.accept, which could fail.

 

Secondly, you can use the fs module to read from a file. If it's newline-delimited, you could call split("\n") to get an array containing each line in the file.

Go to the full post


  • Please log in to reply
5 replies to this topic

#1 R3v3rso

R3v3rso

    Newbie

  • Member
  • Pip
  • 5 posts
  • LocationValenciennes, France

Posted 27 November 2018 - 04:24 PM

Hello everyone !

So I spent the last few weeks trying to create a bot that basically trades random steam cards for Steam Game Keys (with a lot of help from Vanilla ;p )

 

I am now pretty much done with all the trading stuff, and the last thing that I need is to get the Steam Key from my file.

 

Basically, my goal is to

- Count how many keys in total are in my .txt or .csv or .anything file and get that to a variable so I can add a line earlier in the code which checks if i have enough keys left before accepting the cards

- Get the key(s) from the file (in order to send them in chat)

-move the used keys to another file or modify their line to mark them as 'inactive' or something.

 

Here is the part where I stopped :

else {
    totalKeyWeGive = cardCount / cardToKey;
    console.log("We will give "+totalKeyWeGive+ " SteamKey");
    
    offer.accept();
    console.log("OFFER ACCEPTED");
    
    //loop on how much we give the key
    for (i = 0; i < totalKeyWeGive; i++) {
        //get steamkey from file here ----------------------------------------------------------------------------
        
     
    }
    
    var textMsg = "Hello ! You bought "+totalKeyWeGive+ " Game keys. Your keys are: ";
    }
    
    client.chatMessage(offer.partner.getSteamID64(), textMsg);
    

}

I already have most of the variables setup, and processed earlier in the code : 

 

cardToKey - How many cards are needed for one key

cardCount - How many cards are there in the offer

totalKeyWeGive - If everything is okay in the trade, how many keys should we give

 

 

 

Any advices on how I should handle this ?



#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,815 posts

Posted 27 November 2018 - 05:30 PM   Best Answer

The first problem I see is that you aren't handling the callback to offer.accept, which could fail.

 

Secondly, you can use the fs module to read from a file. If it's newline-delimited, you could call split("\n") to get an array containing each line in the file.


  • R3v3rso likes this

#3 R3v3rso

R3v3rso

    Newbie

  • Member
  • Pip
  • 5 posts
  • LocationValenciennes, France

Posted 28 November 2018 - 07:16 AM

Oh yeah I forgot to add that, so it should be offer.accept(offer) right ?

 

Thanks for the suggestion. I'll look into that !

 

Have a nice day



#4 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,815 posts

Posted 29 November 2018 - 01:44 AM

Oh yeah I forgot to add that, so it should be offer.accept(offer) right ?

 

No, that's not right.



#5 R3v3rso

R3v3rso

    Newbie

  • Member
  • Pip
  • 5 posts
  • LocationValenciennes, France

Posted 02 December 2018 - 04:38 AM

Then how should I handle the callback ? I'm currently getting errors on offer.decline(offer) , while offer.accept(offer) is fully working ?

 

 

(btw I finally managed to make something functional out of the fs module, thank you for the advice !)



#6 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,815 posts

Posted 03 December 2018 - 12:28 AM

offer.accept(function(err) {
    if (err) {
        // handle error
    }
});






Also tagged with one or more of these keywords: Question

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users