Jump to content
McKay Development

Recommended Posts

Posted

when i use my account for script it see trades but when on account for bot it doesn't work(i tested on account where i don't pay 5$ and on account where payed 5$ but need 7 days after adding mobile auth)

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

const prices = require('./prices.json')

const client = new SteamUser();
const community = new SteamTrade();
const manager = new SteamTradeMann({
	language: 'en'
});

const logOnOptions = {
	accountName: 'name',
	password: 'pass'
};

client.logOn(logOnOptions);

client.on('loggedOn', () => {
	console.log('succesfully logged');
	client.setPersona(1);
	client.gamesPlayed([440])
});

client.on('webSession', (sessionid, cookies) => {
	manager.setCookies(cookies);
	community.setCookies(cookies);
	community.startConfirmationChecker(20000);
})

function acceptOff(offer) {
	offer.accept((err) => {
		community.checkConfirmations();
		console.log("Accepted");
		if (err) console.log("bruh accept");
		if (err) acceptOff(offer);
	})
}

function denyOff(offer) {
	offer.decline((err) => {
		console.log("Declined");
		if (err) console.log("bruh deny");
	})
}

function processTrade(offer) {
	console.log("daa");
	if (offer.state === 11){
		console.log("Trade glithced, declining");
		denyOff(offer);
	} else {
		var sell = offer.itemsToGive;
		var buy = offer.itemsToReceive;
		var ourprice = 0;
		var theirprice = 0;
		console.log(sell);
		console.log(sell.name);
		//console.log(buy);
		//console.log(buy.name);
		for (var i in sell) {
			var item = sell[i].name;
			if(prices[item]){
				ourprice += prices[item].sell;
			} else {
				console.log("Error price sell");
				ourprice += 99999;
			}
		}
		for (var i in buy) {
			var item = buy[i].name;
			if(prices[item]){
				theirprice += prices[item].buy;
			} else {
				console.log("Error price buy");
			}
		}
		console.log("Sell: "+ourprice);
		console.log("Buy: "+theirprice);

		if(ourprice <= theirprice){
			acceptOff(offer);
			chataccpt(offer.partner);
		} else {
			denyOff(offer);
			chatdec(offer.partner, ourprice, theirprice);
		}
	}
}

function chataccpt(id){
	client.chatMessage(id, "Offer accepted!")
}

function chatdec(id, our, their){
	client.chatMessage(id, "Offer declined!");
	client.chatMessage(id, "Your items : "+their);
	client.chatMessage(id, "My items : "+our);
}

manager.on('newOffer', function(offer) {
	console.log("daAAAA");
	processTrade(offer);
})

 

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