Jump to content
McKay Development

Help me get my bot accept only certain trade offers.


Recommended Posts

So I'm quite new to this stuff and I'd like to get some help.

I want to make a bot that accepts only certain trade offers, for ex, user put a KB-808 in the trade offer and took 3 scrap(/1 rec) and I want that to be accepted, what I have right now accepts everything, here's the bot:

 

-----------------------------------------

var Steam = require ('steam');
var SteamUser = require('steam-user');
 
var client = new SteamUser();
 
var SteamTotp = require('steam-totp');
 
var fs = require("fs");
 
var SteamCommunity = require('steamcommunity');
var community = new SteamCommunity(steamClient);
var steamClient = new Steam.SteamClient();
var SteamUser = new Steam.SteamUser(steamClient);
var SteamFriends = new Steam.SteamFriends(steamClient);
var crypto = require('crypto');
 
var SteamTradeOffers = require('steam-tradeoffers');
var offers = new SteamTradeOffers();
 
var config;
try {
  config = JSON.parse(fs.readFileSync('./config.json'));
} catch (err) {
  console.log("Error: Unable to parse config.json");
  console.log(err);
  process.exit(1);
}
 
client.logOn({
  "accountName": config.username,
  "password": config.password
});
 
var TradeOfferManager = require('steam-tradeoffer-manager');
var manager = new TradeOfferManager({
  "community": community,
  "language": "en",
  "pollInterval": 1000
});
 
client.on("webSession", function(steamID, cookies){
  manager.setCookies(cookies);
  community.setCookies(cookies);
  SteamTotp.steamID = steamID;
  community.startConfirmationChecker(2500, config.identitySecret)
});
 
manager.on('newOffer', function(offer) {
  console.log("New offer #" + offer.id + " from " + offer.partner.getSteam3RenderedID());
  offer.accept(function(err) {
    if (err) {
      console.log("Unable to accept offer: " + err.message);
    } else {
      community.checkConfirmations(); // Check for confirmations right after accepting the offer
      console.log("Offer accepted");
    }
  });
});
 
manager.on('receivedOfferChanged', function(offer, oldState) {
  console.log("Offer #" + offer.id + " changed: " + TradeOfferManager.getStateName(oldState) + " -> " + TradeOfferManager.getStateName(offer.state));
 
if (offer.state == TradeOfferManager.ETradeOfferState.Accepted) {
  offer.getReceivedItems(function(err, items) {
    if (err) {
      console.log("Couldn't get received items: " + err);
    } else {
      var names = items.map(function(item) {
        return item.name;
      });
 
      console.log("Received: " + names.join(', '));
     }
   });
  }
});
 
client.on("loggedOn", function(details)
{
  client.setPersona(Steam.EPersonaState.Online)
  client.gamesPlayed(440)
 
  console.log("Successfully logged onto Steam, APIKey: " + config.apikey)
});
 
client.on("steamGuard", function(domain, callback, lastCodeWrong)
{
  if(lastCodeWrong)
  {
     console.log("Last code wrong, retrying");
  }
 
  var shared_secret = config.sharedsecret;
 
  callback(SteamTotp.generateAuthCode(shared_secret));
});
 
community.on("newConfirmation", function(conf)
{
    conf.respond(Math.floor(Date.now() / 1000), SteamTotp.getConfirmationKey(config.identitysecret,Math.floor(Date.now() / 1000), "allow"), true, function(err){
      if(err)
      {
        console.log("Confirmation failed: " + err);
        return;
      }
        console.log("Sucessfully confirmed!");
 
    });
});
 
community.on("confKeyNeeded", function(tag, callback){
  var time = Math.floor(Date.now() / 1000);
  callback(null, time, SteamTotp.getConfirmationKey(config.identitysecret, time, tag));
});
Edited by Galorch
Link to comment
Share on other sites

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