-
Posts
14 -
Joined
-
Last visited
Posts posted by Andrei Elvis
-
-
Hello!
I've been facing an issue. The bot was used to work before, but now it is not working. I've also tried to create a new code from scratch (maybe the old code was wrong) but still, the same result. There is no console log, nothing, about the `sentOfferChanged` event..
Here is my code:
// Required packages const SteamTotp = require('steam-totp'); const SteamCommunity = require('steamcommunity'); const TradeOfferManager = require('steam-tradeoffer-manager'); // Steam credentials const username = 'xxx'; const password = 'xxx'; const sharedSecret = 'xxx'; // Target trade link (replace with the actual trade offer link of the user) const tradeOfferURL = 'https://steamcommunity.com/tradeoffer/new/?partner=xxx&token=xxx'; // SteamCommunity and TradeOfferManager instances const community = new SteamCommunity(); const manager = new TradeOfferManager({ community: community, domain: 'localhost', language: 'en', pollInterval: 10000 }); // Steam App ID and Context ID for CS:GO const appid = 730; const contextid = 2; // Log in and send a trade offer function loginAndSendTradeOffer() { console.log("Logging in to Steam..."); const authCode = SteamTotp.generateAuthCode(sharedSecret); community.login({ accountName: username, password: password, twoFactorCode: authCode }, (err, sessionID, cookies, steamguard) => { if (err) { console.log("Failed to login:", err); return; } console.log("Successfully logged in!"); manager.on('debug', console.log) manager.setCookies(cookies, (err) => { if (err) { console.log("Failed to set cookies:", err); return; } console.log("Cookies set, fetching inventory..."); manager.getUserInventoryContents('xxx', appid, contextid, true, (err, inventory) => { if (err) { console.log("Failed to fetch partner's inventory:", err); return; } if (inventory.length === 0) { console.log("Partner's inventory is empty, no items to trade."); return; } console.log(`Found ${inventory.length} items in partner's inventory. Picking the first item...`); const firstItem = inventory[0]; const offer = manager.createOffer(tradeOfferURL); offer.addTheirItem({ appid: appid, contextid: contextid, assetid: firstItem.assetid }); offer.send((err, status) => { if (err) { console.log("Failed to send offer:", err); return; } console.log("Trade offer sent successfully! Status:", status); }); }); }); }); } manager.on('sentOfferChanged', (offer, oldState) => { console.log(`Trade offer #${offer.id} changed from ${oldState} to ${offer.state}.`); switch (offer.state) { case TradeOfferManager.ETradeOfferState.Accepted: console.log('The trade offer was accepted!'); break; case TradeOfferManager.ETradeOfferState.Declined: console.log('The trade offer was declined.'); break; case TradeOfferManager.ETradeOfferState.Canceled: console.log('The trade offer was canceled.'); break; case TradeOfferManager.ETradeOfferState.InvalidItems: console.log('The trade offer contained invalid items.'); break; case TradeOfferManager.ETradeOfferState.Countered: console.log('The trade offer was countered by the other party.'); break; default: console.log('Trade offer status updated.'); break; } }); loginAndSendTradeOffer();
And these are my logs, after having it running for few time ( after I've declined the offer )
Logging in to Steam... Successfully logged in! Doing trade offer poll since 1 (full update) Cookies set, fetching inventory... Trade offer poll succeeded in 361 ms Found 39 items in partner's inventory. Picking the first item... Trade offer sent successfully! Status: sent Doing trade offer poll since 0 Trade offer poll succeeded in 260 ms Doing trade offer poll since 0 Trade offer poll succeeded in 230 ms Doing trade offer poll since 0 Trade offer poll succeeded in 257 ms Doing trade offer poll since 0 Trade offer poll succeeded in 241 ms Doing trade offer poll since 0 Trade offer poll succeeded in 246 ms Doing trade offer poll since 0 Trade offer poll succeeded in 247 ms Doing trade offer poll since 0 Trade offer poll succeeded in 266 ms Doing trade offer poll since 0 Trade offer poll succeeded in 416 ms Doing trade offer poll since 0 Trade offer poll succeeded in 235 ms Doing trade offer poll since 0 Trade offer poll succeeded in 228 ms Doing trade offer poll since 0 Trade offer poll succeeded in 281 ms Doing trade offer poll since 1 (full update) Trade offer poll succeeded in 294 ms Doing trade offer poll since 0 Trade offer poll succeeded in 245 ms Doing trade offer poll since 0 Trade offer poll succeeded in 236 ms Doing trade offer poll since 0 Trade offer poll succeeded in 378 ms
What's wrong?
I've used another steam account for this and it's the same result. It is like I am doing something wrong.. what am I doing wrong? Thanks!!
-
Hi Echo,
I don't think it's possible to extract a image by the market name (without scraping the market), I do know you used to be able to get it using the classid of an item;
I'm not sure if it still is a valid way of doing this but I remember I used to be using,
https://steamcommunity-a.akamaihd.net/economy/image/class/730/<classid>/150fx125f
It is useless with classid... as I have an array with the skin names
, but thanks for reply.
I had the script to get the image of a skin name, it was requesting the steam market with the skin name given and it were getting the skin image.
But I do not have the code and I do not have any idea how to make it right now :'(
-
Hello,
Can someone help me with the url from where I can get the skin image just by knowing the skin name.
So in node.js is like
request("link, link / skin name", function(x,y,z) { if(y.statusCode == 200) { skinImage = blabla; } });
Hope someone can help me
!
-
Hello,
I've saw that there's an error when the bot tries to reconnect after a session expires
[ERROR] default - Error: Cannot log onto steamcommunity.com without first being connected to Steam network at SteamUser.webLogOn (/var/www/node_modules/steam-user/components/web.js:9:9) at SteamCommunity.<anonymous> (/var/www/socket/main.js:1453:29) at emitOne (events.js:96:13) at SteamCommunity.emit (events.js:188:7) at SteamCommunity._notifySessionExpired (/var/www/node_modules/steamcommunity/components/http.js:85:7) at /var/www/node_modules/steamcommunity/components/confirmations.js:21:10 at /var/www/node_modules/steamcommunity/components/confirmations.js:272:4 at SteamCommunity._checkHttpError (/var/www/node_modules/steamcommunity/components/http.js:90:3) at Request._callback (/var/www/node_modules/steamcommunity/components/http.js:50:61) at self.callback (/var/www/node_modules/request/request.js:186:22)
And I want to know if there's a callback, so when an error comes in to just
return;
Can I do like:
client.webLogOn(function(err) { if(err) return; });
Or something like this?
Please help me.
Thanks!
-
Well, I didn't use "pollFailure" on my bot, and I use this solution for my bot
(trying to send offer -> error not logged in -> steam-community "sessionExpired" called -> relogin using client.webLogOn(); -> use if/else and re-send trade offer)
Thanks!
-
-
When you add items to the offer (with .addMyItem and .addTheirItem) you need to specify appid and contextid of items.
So, instead of
offer.addMyItem(myItem);
Replace with:
offer.addMyItem({ 'assetid': myItem.assetid, 'appid': appid, 'contextid': contextid });
Same for
offer.addTheirItem(theirItem);
Replace with:
offer.addTheirItem({ 'assetid': theirItem.assetid, 'appid': appid, 'contextid': contextid });
-
That processOffer should be like this:
function processOffer(offer, oldstate) { if (offer.isGlitched() || (offer.state === 11 && oldstate == 2)) { //console.log("Offer was glitched, declining."); declineOffer(offer); } else if (offer.partner.getSteamID64() === config.ownerID) { acceptOffer(offer); var item = ourItems[i].market_name; } else { //my_code }
And at the event 'sentOfferChanged' you should put the function:
processOffer(offer, oldstate);
Note: On the event 'sentOfferChanged' put the oldstate to be same as on the processOffer function.
-
Instead of this:
offer.addMyItems(inventory[0]);
Replace with this: (the code below will add all items from bot to the offer).
for(var k in inventory) { offer.addMyItem({ 'assetid': inventory[k].assetid, 'appid': 730, 'contextid': 2 }); }
-
Hello,
How can I fix the Error: "Not Logged In" error after some hours.
I know I need to login the bot again but I did some code for bot to login again.
Maybe I didn't do correct. So, someone can explain me how to login again bot when the session expires?
Thanks!
-
It should look like this:
function acceptOffer(offer) { offer.accept((err) => { community.checkConfirmations(); if (err) console.log("There was an error accepting the offer."); manager.getOffer(offer.id, function(er, of) { if(er) throw er; var itemsReceived = of.itemsToReceive; var newOffer = manager.createOffer(SOMEID); newOffer.addMyItem(itemsReceived[0]); newOffer.send(function(err, status) {console.log('error: '+err+' status: '+status)}); console.log(newOffer.state); }); }); };
Hope it works!
-
Would you mind giving me an example of adding a key to a trade offer, thanks
You can do something like:
var keysToAdd = [] // ARRAY WITH THE ASSETIDS OF THE KEYS. for(var i in keysToAdd) { offer.addMyItem({ 'appid': appid, 'contextid': contextid, 'assetid': keysToAdd[i] }); } //YOU NEED TO ADD THIS BEFORE <offer.send> function
-
Hello,
I have this error since 3 days and I didn't change anything on the scripts, I just restarted the node.
Can someone help me, pls?
sentOfferChanged is not firing. The bot can send offer though
in node-steam-tradeoffer-manager
Posted
Thanks, that was the fix! <3