Jump to content
McKay Development

Recommended Posts

Posted (edited)

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
Posted
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)

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