Jump to content
McKay Development

Search the Community

Showing results for tags 'Node.js'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News & Announcements
    • Releases & Updates
  • Help & Support
    • General
    • Guides
    • node-steam-user
    • node-steamcommunity
    • node-steam-tradeoffer-manager
    • node-steam-session

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Skype


Location


Interests

  1. Hello, I am getting this error: Error: There was an error sending your trade offer. Please try again later. (26) at exports.makeAnError (/home/hamaad/projects/cs-go/backend/node_modules/steam-tradeoffer-manager/lib/helpers.js:17:12) at SteamCommunity.<anonymous> (/home/hamaad/projects/cs-go/backend/node_modules/steam-tradeoffer-manager/lib/classes/TradeOffer.js:349:12) at Request._callback (/home/hamaad/projects/cs-go/backend/node_modules/steamcommunity/components/http.js:67:15) at self.callback (/home/hamaad/projects/cs-go/backend/node_modules/request/request.js:185:22) at Request.emit (node:events:514:28) at Request.<anonymous> (/home/hamaad/projects/cs-go/backend/node_modules/request/request.js:1154:10) at Request.emit (node:events:514:28) at Gunzip.<anonymous> (/home/hamaad/projects/cs-go/backend/node_modules/request/request.js:1076:12) at Object.onceWrapper (node:events:628:28) at Gunzip.emit (node:events:514:28) { eresult: 26 } I know that this error occurs when there is items in the inventory don't exist, but I cant find the problem in my code: const express = require('express'); const session = require('express-session'); const cookieParser = require('cookie-parser'); const passport = require('passport'); const SteamUser = require('steam-user'); const SteamStrategy = require('passport-steam').Strategy; const SteamCommunity = require('steamcommunity'); const SteamInventory = require('get-steam-inventory'); const TradeOfferManager = require('steam-tradeoffer-manager'); const crypto = require('crypto'); const cors = require('cors'); const app = express(); const PORT = 8080; const STEAM_API_KEY = '<API KEY>'; let community = new SteamCommunity(); let manager = new TradeOfferManager({ community: community, language: 'en', }); let client = new SteamUser(); client.logOn({ accountName: '<USERNAME>', password: '<PASSWORD>', }); manager.on('sessionExpired', function (err) { client.webLogOn(); }); client.on('webSession', (sessionID, cookies) => { manager.setCookies(cookies); community.setCookies(cookies); }); const httpServer = require('http').createServer(app); const sessionSecret = crypto.randomBytes(32).toString('hex'); app.use( session({ secret: sessionSecret, resave: true, saveUninitialized: true }) ); app.use((req, res, next) => { res.setHeader('Access-Control-Allow-Origin', '*'); res.setHeader('Access-Control-Allow-Credentials', 'true'); res.setHeader( 'Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS' ); res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization'); next(); }); app.use( cors({ origin: ['http://localhost:3000', 'http://localhost:3001'], methods: 'GET,POST,PATCH,PUT,DELETE', credentials: true, }) ); app.use(cookieParser()); app.use(passport.initialize()); app.use(passport.session()); const io = require('socket.io')(httpServer, { cors: { origin: ['http://localhost:3000', 'http://localhost:3001'], methods: 'GET,POST,PATCH,PUT,DELETE', credentials: true, }, }); try { io.on('connection', (socket) => { io.to(socket.id).emit('connected'); }); } catch (error) { console.log(error); } passport.use( new SteamStrategy( { returnURL: 'http://localhost:8080/auth/steam/return', realm: 'http://localhost:8080/', apiKey: STEAM_API_KEY, }, function (identifier, profile, done) { process.nextTick(function () { profile.identifier = identifier; return done(null, profile); }); } ) ); passport.serializeUser(function (user, done) { done(null, user); }); passport.deserializeUser(function (obj, done) { done(null, obj); }); app.get('/auth/steam', passport.authenticate('steam')); app.get( '/auth/steam/return', passport.authenticate('steam', { failureRedirect: '/' }), (req, res) => { res.redirect('http://localhost:3000/'); } ); function isAuthenticated(req, res, next) { console.log(req.isAuthenticated(), 'auth'); if (req.isAuthenticated()) { return next(); } res.redirect('/'); } app.get('/user', isAuthenticated, (req, res) => { try { res.json({ user: req?.user?._json }); } catch (error) { res.json({ message: error.message }); } }); app.get('/inventory', isAuthenticated, async (req, res) => { const steamId = req?.user?._json?.steamid; SteamInventory.getinventory(730, steamId, '2') .then((data) => { res.json({ invetory: data }); }) .catch((err) => res.send(err)); }); let coinflipRooms = []; io.on('connection', (socket) => { const sendRoomsInterval = 5000; function sendRooms() { socket.emit('getCoinFlipRooms', coinflipRooms); } const sendRoomsTimer = setInterval(sendRooms, sendRoomsInterval); socket.on( 'createCoinflipRoom', ({ roomId, player, invertoryItem, roomOwner, coin, tradeUrl }) => { const owner = { player, invertoryItem, roomOwner, coin, tradeUrl }; const room = { roomId, players: [owner] }; coinflipRooms.push(room); socket.emit('coinflipRoomCreated', room); // Notify all clients about the new room } ); socket.on( 'joinCoinflipRoom', ({ roomId, player, invertoryItem, roomOwner, coin, tradeUrl }) => { if (coinflipRooms.length === 0) { io.emit(`coinFlipRoomError${player.steamId}`, 'Room not found'); } else { const joinedPlayer = { player, invertoryItem, roomOwner, coin, tradeUrl }; coinflipRooms.forEach((room) => { if (room.roomId === roomId) { room.players.push(joinedPlayer); } }); socket.emit('coinflipPlayerJoined', coinflipRooms); // Notify all clients in the room about the new player const selectWinnerInterval = 3000; async function selectRandomPlayer(room) { const randomIndex = Math.floor(Math.random() * room?.players.length); const randomPlayer = room?.players[randomIndex]; // Winner const loserPlayer = room?.players.find( (player) => player !== randomPlayer ); socket.emit('coinflipWinner', randomPlayer); const removedCurrectRoom = coinflipRooms.filter( (obj) => obj?.roomId !== room?.roomId ); coinflipRooms = removedCurrectRoom; // Transfer items to the winner const offer = manager.createOffer(randomPlayer?.player?.tradeUrl); console.log('Adding: '); console.log(loserPlayer?.invertoryItem[0].asset); offer.addTheirItem(loserPlayer?.invertoryItem[0].asset); offer.setMessage( `You won the coinflip! Your items: ${loserPlayer?.invertoryItem}` ); offer.send(async function (err, status) { if (err) { console.log(err); return; } if (status == 'pending') { console.log(`Offer #${offer.id} sent, but requires confirmation`); community.acceptConfirmationForObject( await getIdentitySecret(loserPlayer?.player?.steamid), offer.id, function (err) { if (err) { console.log(err); } else { console.log('Offer confirmed'); } } ); } else { console.log(`Offer #${offer.id} sent successfully`); } }); } const autoWinnerTimer = setInterval( () => selectRandomPlayer(coinflipRooms.find((room) => room.roomId === roomId)), selectWinnerInterval ); } } ); socket.on('disconnect', () => { console.log('user disconnected'); clearInterval(autoRoomTimer); clearInterval(autoWinnerTimer); }); process.on('SIGINT', () => { clearInterval(autoRoomTimer); clearInterval(autoWinnerTimer); process.exit(); }); }); httpServer.listen(PORT, () => { console.log(`Server is running on http://localhost:${PORT}`); });
  2. I have a web app that processes steam trades. The goal is to log into steamcommunity with user/pass/2fa once on startup, then use the logged in community object to create offers when trades are processed. I have the current code which seems to successfully process trades (I can't know for sure as the bot account had 2FA enabled just a few days ago), the problem is that every time a trade is processed, a community login is required. If I remember correctly, you can only log in with 2FA once every 30 seconds. For my use case, this is a limitation I am hoping to avoid. import two from './twofactor_76561199485326357.json'; import {TItemsAsset} from "@/helpers/steamTypes"; var SteamTotp = require('steam-totp'); var TradeOfferManager = require('steam-tradeoffer-manager'); var SteamCommunity = require('steamcommunity'); var community = new SteamCommunity(); require('dotenv').config(); export default function createOffer(tradeURL: string, items: TItemsAsset[]) { var logOnOptions = { accountName: process.env.BOT_USER, password: process.env.BOT_PASS, twoFactorCode: SteamTotp.generateAuthCode(two.shared_secret), } community.login(logOnOptions, (err: Error) => { if (err) { console.log('Error logging into community'); throw Error; } else { console.log('Successfully logged into community as ' + logOnOptions.accountName); var manager = new TradeOfferManager({ "community": community, "pollInterval": 5000, "cancelTime": 180000, "pendingCancelTime": 180000, "domain": (process.env.NODE_ENV !== 'production' ? 'localhost:3000' : 'mywebsite.com'), "language": "en", }) let offer = manager.createOffer(tradeURL); //offer.addTheirItems(items.map(item => ({ appid: item.assetid, contextid: item.contextid, assetid: item.assetid }))); offer.addTheirItem({ appid: 730, contextid: 2, assetid: 19506293513 }) offer.setMessage('Items from bounty creator'); offer.send(function(err: Error, status: string) { if (err) { console.log('send err: ' + err); throw Error; } else if (status === 'pending') { community.acceptConfirmationForObject(two.identity_secret, offer.id, (err: Error) => { if (err) { console.log('confirm err: ' + err); } else { console.log('Offer confirmed'); } }); } else { console.log('trade offer sent successfully'); } }); } }); } I respect your time and am not asking you to teach me basic javascript principles, but if you could point me in the right direction that would be very much appreciated. Thanks for creating these libraries, - b_zy
  3. Hey! I am trying to Import the Sentry File of a Real Steam Client running locally. After googling, i found that it is saved in <steamInstallDir>/Steam/ssfn<numbers>. Problem being, i seem to have two of these files locally, both following the name format, just with different Numbers. The content of the files is different, however one of the two is marked as NTFS Hidden. How do i know which of the two files are used by my real Steam client? (Is there any meaning to the Numbers?) I have checked with a friend, they also have the same situation: 2 files, different names, different content, one hidden. Thanks for all the time you spend on this stuff! ~ ty
  4. Hello, I am getting a UnhandledPromiseRejectionWarning: Error: AccountNotFound when trying to Authorize the local SentryFile to get a deviceToken. My code is currently as barebones as it could be. const SteamUser = require("steam-user"); var c = new SteamUser(); c.logOn({ "accountName": "...", "password": "..." }) c.on("loggedOn", (det)=>{ c.setPersona(SteamUser.EPersonaState.Online); c.authorizeLocalSharingDevice("Test-PC").then(res=>{ console.log("token: "+res.deviceToken) }) }) The Online Status successfully updates, however i get a promise Failiure on the authorizeLocalSharingDevice. What am i doing wrong? ~ ty
  5. 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
  6. How do I get the direct detection of the bot when I change the content of the /message file. I do not want to close and open the bot and enter the guard code.
  7. How to comment on the drawing showcase and screenshot and how do I like it?
  8. Hello! I've been trying to log in with loginkey but it always says InvalidPassword. My code works like this: 1. Download steamusername and loginkey from database. 2. Check if they are not null. 3. a) If they are not null, log in with them. 3. b) If they are null, ask for password. Every time the 'loginkey' event gets called, I save the loginkey to the database. Logging in with the password works, but when I try to log in with the loginkey from the database, I get the error InvalidPassword. What am I doing wrong? My code: /* login without loginkey */ client.logOn({ accountName: steamusername, password: steampassword, machineName: "***", rememberPassword: true }); /* saving the loginkey */ client.on("loginKey", key => { saveLoginKey(username, steamusername, key); }); /* login with loginkey */ client.logOn({ accountName: steamusername, loginKey: loginkey, rememberPassword: true, machineName: "***" }); The loginkey variable is set, I checked it. (I'm sorry for any misspelled words or grammar mistakes, english is not my native language) NodeJS version 12.9.1 npm version 6.12.1 steam-user version 4.12.4
  9. Hello, when someone sends a trading offer to the boat. Unknown Command sends message How can I exclude this
  10. Guest

    Friend and Blocked

    Hi, How can I find out that a friend has blocked me? client.myFriends[user_id] = 3 , but on account who blocked this value = 6
  11. Sometimes pollFailure event is emitted and gives the error below. { Error: socket hang up at createHangUpError (_http_client.js:323:15) at TLSSocket.socketOnEnd (_http_client.js:426:23) at TLSSocket.emit (events.js:203:15) at endReadableNT (_stream_readable.js:1145:12) at process._tickCallback (internal/process/next_tick.js:63:19) code: 'ECONNRESET' } My script is running on AWS. So there shouldn't be any issues with the network.
  12. Hey, i read all post at this forum about this issue. https://dev.doctormckay.com/topic/2128-error-when-using-loginkey/?hl=loginkey https://dev.doctormckay.com/topic/1896-loginkey-throw-error-invalidpassword/?hl=loginkey https://dev.doctormckay.com/topic/2120-using-loginkey-gives-error-invalidpassword/?hl=loginkey https://dev.doctormckay.com/topic/2264-what-data-must-be-stored-for-reauthorization/?hl=loginkey&do=findComment&comment=7443 I can't login with loginKey on my VDS based on Linux. I am updating loginKey every time when receive new one from Steam. All working fine at my local Windows machine. So i tryed use Windows VDS - all working fine. Is there any bug on Linux? Can that be that when i use steam-user at linux it won't use sentry files. That can explain why loginKey don't work. I found folder where sentryes stored at Linux and tryed to manualy load them with setSentry - won't help. Any ideas how understand where problem is? Ye, i know, it's Steam and we can't know for 100% how it works under the hood. But it bothers me that the same code behaves differently on different OS, so it's probably some bug inside steam-user. P.S. Sorry for my English. English is not my native language
  13. Hello, I'm using this code to keep me logged (to avoid session expired) setInterval(function() { if (client.steamID) { client.webLogOn(); } else { client.logOn(account); } }, 1800000); but sometimes I'm getting crash with LogonSessionReplaced, should I use relog() instead?
  14. Hello, i have a problem with multiple TradeOfferManagers, in this example the first console.log returns a name for a different account then the second console.log. How is this possible? let offer = managers[x].createOffer(new SteamID(steamId), token); offer.getUserDetails((err, me, them) => { console.log(me.personaName); console.log(managers[x].steamID.getSteamID64());
  15. First of all, thanks for writing and maintaining this library ! I'm trying to pull more than 5k servers from `getServerList()`. I don't see any options to paginate (don't think Steam supports it). Any idea how this could be achieved ? Thanks
  16. const client = new SteamUser();client.setOption("localAddress",logInConfig.publicIP);const logInOptions = { accountName: logInConfig.accountName, password: logInConfig.password, twoFactorCode: SteamTotp.generateAuthCode(logInConfig.sharedSecret)}; const community = new SteamCommunity({ localAddress:logInConfig.publicIP});const manager = new TradeOfferManager({ steam: client, community: community, language: "en", cancelOfferCount: 30});client.logOn(logInOptions);Will the manager use the logInConfig.publicIP?
  17. Hello, I apologize for the longwinded questions, I'm new to Steam trading and would like to learn more about building trade bots. Using multiple trade bots at once is a pretty common usage scenario of node-steam-user and node-steam-trade-offer-manager but I haven't found many guides or examples that go into finer detail on this. I have a fuzzy idea of how to do it but I would like some validation/clarification to see if I'm heading in the right direction. If I have many available bot accounts, say 20 bots, and I start them all up at once, I'm sure I would run into steam's rate limiting per IP address, as well as getting a LogonSessionReplaced error if my bots were to re-login on the same IP. I see that there is a loginID option for the steam-user logOn method, I'm assuming I can use a proxy pool in tandem with this option to mitigate these issues? Is logging in with different IP addresses enough or do I need to use a loginKey? I see that when logging in and using the rememberPassword option, it triggers a loginKey event, which I can store and use for subsequent logins. Does using a loginKey bypass the LogonSessionReplaced error as well? I don't quite understand the benefit of using a loginKey instead of username/password. Second question - Can I send trades from the same bots that are running in separate processes? For example, maybe on app startup, I can log into all my bots at once and have them ready to initiate trades. I would also have a worker process running in the background that would start up all of the same bots to send a trade at a later time, let's say when an item on trade hold becomes available. Would these bots log off the other bots from app startup? This is probably related to my first question about using a loginKey or loginID. Last question - How can I check if a bot is already logged on? Instead of starting up all bots on app startup, I could just login to each bot separately when a trade is requested for an item in their inventory. I would want to check if the bot is logged in already before calling the logOn method again. Thank you for your time and for your great work on these libraries!
  18. const manager = new TradeOfferManager({ steam: client, community: community, language: "en"}); manager.on("sentOfferChanged ", function (offer,oldState) { console.log(`Sent offer changed:` + offer.state);}); sentOfferChanged doesnt emit, the only time it emits something is when I send an offer that needs to be confirmed (ETradeOfferState = 9). Do I have to call doPoll() manually or Iam missing something?
  19. I've fixed the issue. It was ``addTheirItem`` instead of ``addMyItem``.
  20. i have windows and i test it and runs all ok but when i want to use centos 7 to run it on my server it does not work!! steam-user client.logOn does not give me error and do nothing it is so weird i have tried it into 4 different linux servers still the same what do you think the problem is? my code : const SteamUser = require('steam-user'); var client = new SteamUser(); client.logOn({ accountName: 'test', password: 'tes',}) client.on('loggedOn', () => { console.log('logged on'); }); client.on('error', (err) => { console.log(err); });
  21. How do i check if a group is joinable or invite only?
  22. Hello, What data must be stored for reauthorization ? For example i can provide my cookies into node-steamcommunity for renew my auth ( if it be saved before ), but what's data need to store for renew my auth in steam-user ? Because when i have much accounts auth take so long time when i restart my software.
  23. Hello, I tried to use community.postUserComment but it didn't work with no errors. I'm using the script below. I'm trying to comment on user profiles. client.on('friendRelationship', (friend, relationship) => { if(relationship == 3) { client.chatMessage(friend, "Hello!"); community.postUserComment(friend,"Thanks for adding!"); }});
×
×
  • Create New...