Jump to content
McKay Development

Recommended Posts

i have been trying to get my steam bot to do automatic buy and selling meaning that it has a stock management system and i almost got one that i created from messing around in nodejs i got it it runs the only thing i am having trouble with is an error a friend told me it might be a bug i was wandering if anyone knows what the error means

 

Error:

{ Error: EBADF: bad file descriptor, write errno: -4083, code: 'EBADF', syscall: 'write' }

 

does not stop the code it keeps going and accepts ust it has that as if it was part of the console.log command

 

also i used jsonfile npm and colors npm modules

 

Here is the full part of it

function processOffer(offer) {
	if (offer.isGlitched() || offer.state === 11) {
		console.log("[".green+h+":".cyan+m+":".cyan+s+"] ".green+"Offer was glitched, declining.");
		declineOffer(offer);
	} else if (offer.partner.getSteamID64() === config.ownerID) {
		acceptOffer(offer);
	} else {
		var ourItems = offer.itemsToGive;
		var theirItems = offer.itemsToReceive;
		var ourValue = 0;
		var theirValue = 0;
		var currentstock = 0;
		var StockLimit = 0;
		for (var i in ourItems) {
			var item = ourItems[i].market_name;
			if (stock[item]){
				currentstock = stock[item].instock;
				StockLimit = stock[item].stocklimit;
				if (fs.readFileSync('.//settings/Stock/stock.json')){
				console.log(timestamp+"Our " +item+" - stock number: " +currentstock+ " / " +StockLimit+ ".")
				if (currentstock < StockLimit){
					if(Prices[item]) {
					ourValue += Prices[item].sell;
					} else if (MetalPrices[item]){
					ourValue += MetalPrices[item].sell;
				} else {
					console.log(timestamp+"Invalid Value.");
					ourValue += 99999;
					}
			} else if (currentstock >= StockLimit){
				console.log(timestamp+item +" Stock Limit Reached")
					manager.on('receivedOfferChanged', (offer)=>{
					if (adminConfig.disableAdminComments == "Enable") {
						community.postUserComment(offer.partner.toString(), item+ " - Stock Limit Reached", (err)=>{
							if(err) throw err.message
						});
					}
					})
			}
				};
			}
		}					
		for(var i in theirItems) {
			var item= theirItems[i].market_name;
			if (stock[item]){
				currentstock = stock[item].instock;
				StockLimit = stock[item].stocklimit;
				fs.readFileSync('.//settings/Stock/stock.json')
				console.log(timestamp+"The " +item+" - stock number: " +currentstock+ " / " +StockLimit+ ".")
				if (currentstock < StockLimit){
					if(Prices[item]) {
					theirValue += Prices[item].buy;
					} else if (MetalPrices[item]){
					theirValue += MetalPrices[item].buy;
					} else {
					console.log(timestamp+"Invalid Value.");
					theirValue += 99999;
				}
				} else if (currentstock >= StockLimit){
						console.log(timestamp+item +" Stock Limit Reached")
						manager.on('receivedOfferChanged', (offer)=>{
						community.postUserComment(offer.partner.toString(), item+ " Stock Limit Reached", (err)=>{
							if(err) throw err.message
							})
						})
					} 
			}
		}
console.log(timestamp+"Our value: "+ourValue);
console.log(timestamp+"Their value: "+theirValue);

	
	if (ourValue <= theirValue) {
		if (config.DevCode == "True"){
			if (DevCodeCFG.Enable_Dev_Stock_Manager== "True"){
				for (var i in ourItems) {
					var item = ourItems[i].market_name;
						if (stock[item]){
							var file = (stock[item].instock);
							var obj = math.subtract(currentstock, 1)
							jsonfile.writeFile(file, function (err) {
							console.error(err)
							})
					console.log(timestamp+' The file has been saved!');
						}
				}
				for (var i in theirItems) {
					var item = theirItems[i].market_name;
						if (stock[item]){
							var file = (stock[item].instock);
							var obj = math.add(currentstock, 1)
							jsonfile.writeFile(file, obj, function (err) {
							console.error(err)
							})
						console.log(timestamp+' The file has been saved!');
						}
				}
			}
		}
			acceptOffer(offer);
		} else if (ourValue > theirValue){
		console.log(timestamp+"Their value was different.")
			declineOffer(offer);
		}
	}
}

If you want to try out my steam bot i got so far it is at github at github.com/LonsterMonster/Steam-Trade-Node-Bot

you have to enable the developer options becasue i didnt want anyone to use the stock management that didnt know what they were doing since it is incomplete

Edited by Lonster_Monster
Link to post
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...