Jump to content


Photo
Question

Auto Confirm Outgoing Trade Offer

node.js node-steam-tradeoffer-manager

  • Please log in to reply
4 replies to this topic

#1 xawa

xawa

    Newbie

  • Member
  • Pip
  • 8 posts

Posted 10 April 2019 - 02:28 PM

Hello here is my code,

const SteamUser = require('steam-user');
const SteamCommunity = require('steamcommunity');
const SteamTotp = require('steam-totp');
const TradeManager = require('steam-tradeoffer-manager');

var self = null;

var BotHandler = function(botConfig, tradeUrl, ownItems = "15702927052", theirItems= "") {
	this.tradeUrl = tradeUrl;
	this.ownItems = ownItems;
	this.theirItems = theirItems;
	this.config = botConfig;
	this.client = new SteamUser();
	this.manager = new TradeManager({
		'steam': this.client, 
		'domain': 'xx',
		'language': 'tr'
	});

	this.community = new SteamCommunity();
	
	this.logOnOptions = {
		'accountName': botConfig.username,
		'password': botConfig.password,
		'twoFactorCode': SteamTotp.getAuthCode(botConfig.secret)
	};

	self = this;
};

BotHandler.prototype.start = function() {
	this.client.on('webSession', this.trade);
	this.client.logOn(this.logOnOptions);
};

BotHandler.prototype.trade = function(sessionId, cookies) {
	self.manager.setCookies(cookies, self.getInventory);
};

BotHandler.prototype.getInventory = function(error) {
	if(error) {
		throw error;
		return;
	}

	self.manager.getInventoryContents(self.config.appId, 
		self.config.contextId, true, self.createOffer);
};

BotHandler.prototype.createOffer = function(error, inventory) {
	if(error) {
		throw error;
	}
	var offer = self.manager.createOffer(self.tradeUrl);
	console.log(inventory);
    offer.addMyItem({
        assetid: "15702927030",
        appid: self.config.appId,
        contextid: self.config.contextId,
        amount: 1
    });

	// for(var i = 0; i < self.ownItems.length; i++) {
	// 	offer.addMyItem({
	// 		assetid: self.ownItems[i],
	// 		appid: self.config.appId,
	// 		contextid: self.config.contextId,
	// 		amount: 1
	// 	});
	// }

    // offer.addTheirItem({
    //     assetid: self.theirItems,
    //     appid: self.config.appId,
    //     contextid: self.config.contextId,
    //     amount: 1
    // });

	// for(var i = 0; i < self.theirItems.length; i++) {
	// 	offer.addTheirItem({
	// 		assetid: self.theirItems[i],
	// 		appid: self.config.appId,
	// 		contextid: self.config.contextId,
	// 		amount: 1
	// 	});
	// }

    offer.send((err, status) => {
        if (err) {
            console.log(err);
        } else {
            console.log('trade sent');
            console.log(status);
        }
    })
};

BotHandler.prototype.acceptTrade = function(error, status) {
	if(err) {
		throw error;
	}

	if(status == 'pending') {
		console.log("pending");
	}else {
		console.log('sent');
	}
};

module.exports = BotHandler;

how can i accept auto the outgoing trade in mobile app? I got my identity secret vb in config


Edited by xawa, 11 April 2019 - 05:25 AM.


#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,042 posts

Posted 10 April 2019 - 04:43 PM

https://github.com/D...jectid-callback


  • xawa likes this

#3 xawa

xawa

    Newbie

  • Member
  • Pip
  • 8 posts

Posted 11 April 2019 - 05:23 AM

Hello master. Thx for your fast reply first of all. When i try this method, it gives an error Like "Must be logged in", idk why im getting this error, on start i did logining is there a something wrong im my code ?



#4 xawa

xawa

    Newbie

  • Member
  • Pip
  • 8 posts

Posted 11 April 2019 - 12:49 PM

offer.send((err,token, status) => {
if (err) {
console.log(err);
} else {
console.log('trade sent');
self.community.acceptConfirmationForObject(self.config.identitySecret);
}
})

I've added self.community.acceptConfirmationForObject Getting this error

F:\Xamp\htdocs\steam-trade-bot\node_modules\steamcommunity\components\confirmations.js:247
                throw new Error("Must be logged in before trying to do anything with confirmations");
                ^

Error: Must be logged in before trying to do anything with confirmations
    at request (F:\Xamp\htdocs\steam-trade-bot\node_modules\steamcommunity\components\confirmations.js:247:9)
    at SteamCommunity.getConfirmations (F:\Xamp\htdocs\steam-trade-bot\node_modules\steamcommunity\components\confirmations.js:17:2)
    at doConfirmation (F:\Xamp\htdocs\steam-trade-bot\node_modules\steamcommunity\components\confirmations.js:182:8)
    at F:\Xamp\htdocs\steam-trade-bot\node_modules\steamcommunity\components\confirmations.js:170:4
    at IncomingMessage.<anonymous> (F:\Xamp\htdocs\steam-trade-bot\node_modules\steamcommunity\node_modules\steam-totp\index.js:129:4)
    at IncomingMessage.emit (events.js:194:15)
    at endReadableNT (_stream_readable.js:1103:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)



#5 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,042 posts

Posted 11 April 2019 - 05:02 PM

https://dev.doctormc...-confirmations/







Also tagged with one or more of these keywords: Question, node.js, node-steam-tradeoffer-manager

4 user(s) are reading this topic

0 members, 4 guests, 0 anonymous users