Search the Community
Showing results for tags 'steam-tradeoffer-manager'.
-
The is my steam bot code. Idk what is wrong to code bot it don't work very good because after 1-2 days it brakes. That are the errors that i get: Error: Disconnected at SteamClient._disconnected (/var/server/node_modules/steam/lib/steam_client.js:189:24) at Connection.emit (events.js:189:13) at TCP._handle.close (net.js:600:12) TypeError: Cannot read property 'send' of undefined at SteamClient._send (/var/server/node_modules/steam/lib/steam_client.js:117:20) at SteamClient.send (/var/server/node_modules/steam/lib/steam_client.js:126:8) at SteamUser.requestWebAPIAuthenticateUserNonce (/var/server/node_modules/steam/lib/handlers/user/index.js:37:16) at SteamWebLogOn.<anonymous> (/var/server/node_modules/steam-weblogon/index.js:34:23) at ClientRequest.<anonymous> (/var/server/node_modules/steam-web-api/index.js:34:9) at Object.onceWrapper (events.js:277:13) at ClientRequest.emit (events.js:189:13) at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21) at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17) at TLSSocket.socketOnData (_http_client.js:442:20) at TLSSocket.emit (events.js:189:13) at addChunk (_stream_readable.js:284:12) at readableAddChunk (_stream_readable.js:265:11) at TLSSocket.Readable.push (_stream_readable.js:220:10) at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:94:17) And more errors. I want the best code the this bot without disconnects and with auto session cookies set after expires. Thanks. BOT CODE var bots = { steam: { botname: config.bot_steam.botname, username: config.bot_steam.username, password: config.bot_steam.password, identitySecret: config.bot_steam.identitySecret, sharedSecret: config.bot_steam.sharedSecret } } var new_steam_bot = function() { var connected = false; var community = new SteamCommunity(); var client = new Steam.SteamClient(); var user = new Steam.SteamUser(client); var friends = new Steam.SteamFriends(client); var webLogon = new SteamWebLogon(client, user); var manager = new TradeOfferManager({ steam: client, community: community, domain: 'localhost', language: 'en', cancelTime: 150000 }); client.connect(); return { connected, community, client, user, friends, webLogon, manager, } } var Steam = require('steam'); var TradeOfferManager = require('steam-tradeoffer-manager'); var SteamTotp = require('steam-totp'); var SteamWebLogon = require('steam-weblogon'); var SteamCommunity = require('steamcommunity'); var q = require('q'); var protos = require('./protos'); var steam_bots = new_steam_bot(); steam_bots.client.on('connected', function() { logger.warn('[BOT] Client Connected'); steam_bots.user.logOn({ account_name: bots.steam.username, password: bots.steam.password, two_factor_code: SteamTotp.generateAuthCode(bots.steam.sharedSecret) }); }); steam_bots.client.on('logOnResponse', function(response) { if(response.eresult !== Steam.EResult.OK) { logger.warn('[BOT] Client Login Failed'); steam_bots.client.connect(); return; } logger.warn('[BOT] Client Login Success'); setWebLogOn(); }); steam_bots.client.on('loggedOff', function(eresult, msg) { logger.warn('[BOT] Client Logout. Message: ' + msg); steam_bots.client.connect(); }); steam_bots.client.on('error', function(err) { logger.warn('[BOT] Client Error. Error: ' + err.message); logger.error(err); writeError(err); if(err.message == 'Disconnected') { logger.error('[BOT] Client Disconnected. Reconnecting!'); steam_bots.client.connect(); } }); steam_bots.community.on('confKeyNeeded', function(deepDataAndEvents, updateFunc) { logger.warn('[BOT] Need Conf Key'); updateFunc(null, time, SteamTotp.getConfirmationKey(bots.steam.identitySecret, time(), deepDataAndEvents)); }); steam_bots.community.on('sessionExpired', function(err) { logger.warn('[BOT] Session expired, logging in...'); bots.steam.connected = false; steam_bots.community.stopConfirmationChecker(); setWebLogOn(); }); steam_bots.user.on('updateMachineAuth', function( sentry, callback ) { callback({ sha_file: getSHA1(sentry.bytes) }); }); function getSHA1(bytes) { var shasum = crypto.createHash('sha1'); shasum.end(bytes); return shasum.read(); } function setWebLogOn(){ try{ steam_bots.webLogon.webLogOn(function(sessionID, cookies) { logger.warn('[BOT] Session cookies set'); steam_bots.manager.setCookies(cookies, function(err) { if (err) { logger.error(err); writeError(err); process.exit(1); } }); steam_bots.community.setCookies(cookies); steam_bots.community.startConfirmationChecker(5000, bots.steam.identitySecret); setTimeout(function(){ steam_bots.connected = true; loadOffersSent(); loadPricesAll(); }, 1000); }); } catch(err){ logger.warn('[BOT] Error Web Log On. Error: ' + err.message); logger.error(err); if(client.loggedOn){ user.requestWebAPIAuthenticateUserNonce(function(result){ logger.error('Error: Request Web API Authenticate User Nonce. ' + result); }); } else { client.connect(); } } }
- 1 reply
-
- steam
- steam-tradeoffer-manager
-
(and 3 more)
Tagged with:
-
Hello i have authorized node js bot and Steam Web API of my 2nd account, i'm looking for the way to send trade offers to this 2nd account without it's token is there any possible way to do this? I was thinking about sending friend request first and tried this POST request to Steam Web Api but it's seem not working https://api.steampowered.com/IPlayerService/AddFriend/v1/?key=2ND_ACC_API&steamid=BOT_ID
- 2 replies
-
- node.js
- steam-tradeoffer-manager
-
(and 1 more)
Tagged with:
-
I need like a help section on node-steam-tradeoffer-manager,steam-community, steam-totp, and steam-user on where the commands are. Like where should I know where are the command help page. I seem to can't find one in general. I'll really appreciate if someone shows me a link on where it is. Thank you
- 3 replies
-
- node.js
- steam-totp
-
(and 3 more)
Tagged with:
-
I have this code here mostly from the example in the steam trade offer manager. It accepts all trade offers fine (without any exceptions). I added some code where the bot would skip the trade offer if the bot didn't receive any items (a gift offer). I'm struggling to create the part of code where I can filter items and create the prices for them for buy orders and sell orders. Could anyone tell me the syntax for that? CODE SO FAR //TF2 TRADE BOTvar SteamUser = require('steam-user'); var SteamCommunity = require('steamcommunity'); var SteamTotp = require('steam-totp'); var TradeOfferManager = require('steam-tradeoffer-manager'); var fs = require('fs'); require('consoleplusplus') var client = new SteamUser(); var manager = new TradeOfferManager({ "steam": client, "domain": "example.com", "language": "en" }) var community = new SteamCommunity(); // Steam logon var logOnOptions = { "accountName": "username", "password": "password", "twoFactorCode": SteamTotp.getAuthCode("sharedSecret") }; if (fs.existsSync('polldata.json')) { manager.pollData = JSON.parse(fs.readFileSync('polldata.json')); } client.logOn(logOnOptions); client.on('loggedOn', function() { var logonmessage = "#magenta{LOGGED INTO STEAM SUCCESSFULLY}" console.info(logonmessage); }); client.on('webSession', function(sessionID, cookies) { manager.setCookies(cookies, function(err) { if (err) { console.error(err); process.exit(1); return; } console.info("Got API key: " + manager.apiKey); console.log("________________________________________________________________________________") }); community.setCookies(cookies); community.startConfirmationChecker(30000, "identitySecret"); }); manager.on('newOffer', function(offer) { console.info("New offer #" + offer.id + " from " + offer.partner.getSteam3RenderedID()); offer.accept(function(err) { if (err) { console.error("Unable to accept offer: " + err.message); } else { if(offer.itemsToReceive.length === 0) { // Gift offer console.info(offer.partner.getSteam3RenderedID() + " Offer #" + offer.id + " is a gift offer, skipping"); return; }else{ community.checkConfirmations(); console.log("Offer accepted"); } } }); }); manager.on('receivedOfferChanged', function(offer, oldState) { console.info(`Offer #${offer.id} changed: ${TradeOfferManager.ETradeOfferState[oldState]} -> ${TradeOfferManager.ETradeOfferState[offer.state]}`); if (offer.state == TradeOfferManager.ETradeOfferState.Accepted) { offer.getReceivedItems(function(err, items) { if (err) { console.error("Couldn't get received items: " + err); } else { var names = items.map(function(item) { return item.name; }); console.log("Received: " + names.join(', ')); console.log("________________________________________________________________________________") } }); } }); manager.on('pollData', function(pollData) { fs.writeFile('polldata.json', JSON.stringify(pollData)); });
-
- node.js
- javascript
-
(and 4 more)
Tagged with: