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. Hi all, i need your help. i can't get the token when i want to send others a offer. which method i need to use. thanks a lot. var offer = manager.createOffer(offSteamID); var accountid = offer.partner.accountid; console.log(accountid);
  2. 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}`); });
  3. 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
  4. Hello, recently i saw your post about get game ticket. is there anyway to get PUBG game Ticket ? GetEncryptedAppTicket wont work it gives me a error client.on("loggedOn", function (dataAndEvents) { console.log("[bOT] Signed in!");client.getEncryptedAppTicket(578080, function(err,ticket){ console.log(ticket);});}); it gives undefined var... is there anyway to get the ticket like in SteamWorks : Using this function greenworks.getAuthSessionTicket((data) => { ticket = data.ticket.toString('hex').toUpperCase();console.log(ticket); resolve(ticket); }, (err) => {console.log('err'); reject(err); }); it returns something like this : 14000000AA709D6426279EE4DF689D1901001001DBEF735A180000000100000002000000A961CDB14E0FA8C0288A2C0021000000B20000003200000004000000DF689D190100100120D20800A961CDB14E0FA8C000000000D2DF735A528F8F5A0100844002000000000090A62D0F6CDB2A5F4E54A765AAD6D477A384ECF2DAF14CC7FA13A7E925FC7999FB53990D7AC185A77793C559481A674FCBF98774A9F723590940032FA61CB3CC6C19E931D55A19ADB0CEE94DBDF6104BC9FE5F97F8BBDA968F2E2FAD52C305B250DD8E6E3C8C317E960996F1F1AEBA774D602C14E5CE4989F30AB231D5B54355
  5. Good evening. I noticed that user data is cached. For example: community.getSteamUser(steamID), (err, user) => { console.log(user.groups); }); Will output the same data until I restarted the bot. Is there a way to disable this cache ?
  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. Why doesn't this work? const SteamCommunity = require('steamcommunity'); let community = new SteamCommunity(); community.login({ "accountName": "accountName", "password": "password", }); community.loggedIn(() => { console.log("test"); }); Of course, I use proper login and password. And I get this when I run it:
  8. //Logging ON client.logOn(logOnOptions); client.on('loggedOn', function (details) { if (details.eresult == SteamUser.EResult.OK) { client.getPersonas([client.steamID], function (personas) { console.log("== Logged in =============") console.log('== Name: ' + personas[client.steamID]["player_name"]); console.log('== ID64: ' + client.steamID); console.log("=========================="); console.log(""); }); client.setPersona(5); //"5": "LookingToTrade" -- https://github.com/DoctorMcKay/node-steam-user/blob/master/enums/EPersonaState.js client.gamesPlayed('Accepting Junk and Making Friends'); } else { console.log(details); //Do whatever u want to handle the error... } }); client.on('webSession', (sessionid, cookies) => { manager.setCookies(cookies); community.setCookies(cookies); }); As soon as the bot starts everythings works fine. After some minutes, every time an offer is received by the bot, I get the "Not Logged In" error. I set up a cron (after reading a similar thread on this forum), like this: //Session refresh every 15 minutes cron.schedule('*/15 * * * *', () => { if (client.steamID) { client.webLogOn(); } else { client.logOn(logOnOptions); console.log('Logged in again using cron'); } }); but the "not logged in" error still remains. I also read this topic where Admin says this but at this point I don't understand which session needs to be refreshed and how. Also calling "sessionExpired" isn't helping because whenever an incoming trade offer gives me the error, bot doesn't try anymore to accept it, even after session is refreshed, so I have to restart it. manager.on('newOffer', offer => { if (offer.partner.getSteamID64() === 'my_stemid_64') { offer.accept((err, status) => { if (err) { console.log(err); } else { console.log(`Accepted offer from owner. Status: ${status}.`); } }); } else { if (offer.itemsToGive.length === 0) { offer.accept((err, status) => { if (err) { console.log(err); } else { console.log(`Donation accepted. Status: ${status}.`); } }); } else { offer.decline(err => { if (err) { console.log(err); } else { console.log('Donation declined (wanted our items).'); } }); } } }); Any help would be appreciated.
  9. Error: Not Logged In at SteamCommunity.<anonymous> (/node_modules/steam-tradeoffer-manager/lib/classes/TradeOffer.js:486:25) at Request._callback (/node_modules/steamcommunity/components/http.js:67:15) I'm passing a steam community object into my trade offer manager like so var myCommunity = new SteamCommunity(); var client = new SteamUser(); var offerMananger = new TradeOfferManager({ steam: client, language: "en", cancelTime: 300000, community: myCommunity });Sometimes, for whatever reason, as have been stated before, my community session will timeout, expire or just logout when I attempt a trade. I get the Not logged in error. Is there a simple way to check if myCommunity is logged out once it's attached to an offerManager? Or can I just check the loggedIn method on the myCommunity object? Do I need to reset cookies when I do this? Do I need to recreate my offerManager to set cookies? What's the recommended way?
  10. 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
  11. 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
  12. Hey I wanted to create a bot that farms hours on a few games and if I (player) start let's say CS:GO. The bot will give an error: Logged into Steam Boosting our hours on chosen games ... Set state to Snooze // starting CS:GO here { Error: LoggedInElsewhere at SteamUser._handleLogOff (C:\Users\Admin\node_modules\steam-user\components\logon.js:400:11) at SteamUser._handlers.(anonymous function) (C:\Users\Admin\node_modules\steam-user\components\logon.js:380:7) at SteamUser._handleMessage (C:\Users\Admin\node_modules\steam-user\components\messages.js:235:30) at emitThree (events.js:136:13) at CMClient.emit (events.js:217:7) at CMClient._netMsgReceived (C:\Users\Admin\node_modules\steam-user\node_modules\steam-client\lib\cm_client.js:323:8) at CMClient.handlers.(anonymous function) (C:\Users\Admin\node_modules\steam-user\node_modules\steam-client\lib\cm_client.js:603:8) at CMClient._netMsgReceived (C:\Users\Admin\node_modules\steam-user\node_modules\steam-client\lib\cm_client.js:305:24) at emitOne (events.js:116:13) at TCPConnection.emit (events.js:211:7) eresult: 6 } This is the bot's code: var colors = require("colors"); const SteamUser = require("steam-user"); const client = new SteamUser(); const logOnOptions = { accountName: "u", password: "p", }; autoRelogin = true; //correct? client.logOn(logOnOptions); client.on("loggedOn", () => { console.log("Logged into Steam".green); client.gamesPlayed(["Boosting Hours", 20, 70, 50, 9480, 300, 40, 130, 10, 730]); console.log("Boosting our hours on chosen games ...".yellow); client.setPersona(SteamUser.Steam.EPersonaState.Snooze); console.log("Set state to Snooze".blue); }); client.on('error', function (err) { console.log(err); client.gamesPlayed(["Boosting Hours", 20, 70, 50, 9480, 300, 40, 130, 10, 730]); }); I'm not sure if I need to use the autoRelogin boolean. I do know I need to handle the error. Not sure how to. So my thought now was to just add the gamesPlayed function again to start those games when the errors appear. But my thought of creating the bot was: // Farm bot 1. Log in on the account 2. Run a check if the account is already playing game(s) (with interval, so it constantly checks) 3. If it is playing a game -> do nothing 4. If it is not playing any games -> start idling a list of games 5. Also handle the LoggedInElsewhere? I'm learning C++ atm. And this is how I start my projects. Writing down what I want my program to do. And turn the text into code. I just can't with JS. Simply because I don't understand the language that well. Trust me, I don't like being spoonfed but I just can't code from scratch with JS. If anyone is planning to spoonfeed me. Do know I'd love some explaination. Otherwise I cannot learn from it. Best regards Ruben.
  13. Is there some clever way to get a list of packageid's, that contain a certain appid, without building an entire database of existing packages? I don't want to scrape steamdb.info either.
  14. 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
  15. Guest

    Can't Leave Comment

    Hello. When i Tried to leave comment i get error Error: The settings on this account do not allow you to add comments. My code let SteamUser = require("steam-user"), SteamCommunity = require("steamcommunity"), SteamID = require('steamid'), CONFIG = require('./config.js'), SteamTotp = require("steam-totp") let client = new SteamUser(); let community = new SteamCommunity(); let banshee = '765611979625767xxx'; let steamID = new SteamID(banshee); community.getSteamUser(steamID, function(ERR, USER) { if (ERR) { console.log("## An error occurred while getting user profile: " + ERR); } else { USER.comment('CONFIG.COMMENTAFTERTRADE', (ERR) => { if (ERR) { console.log("## An error occurred while commenting on user profile: " + ERR); } else { console.log('comment was posted') } }); } })
  16. How to comment on the drawing showcase and screenshot and how do I like it?
  17. 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
  18. Hello, when someone sends a trading offer to the boat. Unknown Command sends message How can I exclude this
  19. 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); });
  20. I have several questions that I have been looking for an answer for a long time. Some of my questions are more for a node js, sorry for that. And thanks in advance for your help! 1: If I need to decline/delete incoming offers that were not accepted in 10 minutes, would this be the right? Maybe there are any cases, why can it be a bad option? manager.on("newOffer", (OFFER) => { setTimeout(function() { OFFER.decline(); }, $MINUTE * 10); 2: I have to save completed trades. If not - sometimes some of them work 2-3 times. Why? // "pollInterval": "10000", // "dataDirectory": "./pool_data", // "savePollData": true var completedTrades = []; manager.on("sentOfferChanged", (OFFER) => { if (completedTrades.indexOf(OFFER.id) >= 0) { console.log("aborted"); return; } if (OFFER.state == 3) { completedTrades.push(OFFER.id); console.log("completed"); //Log: completed aborted aborted 3: In some trading offers I add data: trade.data("somedataname", myvar.toString()); After i check it this way (Is this correct or can it be different?): manager.on("sentOfferChanged", (OFFER) => { if (!!OFFER.data("somedataname")) { console.log("trade with somedataname"); 4: If I want to make a counter offer to a user (not on the list of friends) - will it work as I am create a new offer? manager.on("newOffer", (OFFER) => { let trade = OFFER.counter(); trade.getUserDetails((ERR, BotDetails, UserDetails) => { OFFER.itemsToGive = []; OFFER.itemsToReceive = []; //... add items trade.send((ERR) => { 5: How can I use more than 1 appid / txid? manager.getUserInventoryContents(SENDER, 753, 6, true, (ERR, USERINVENTORY) => { Here I will get only Steam (753-6); What should I do to add for example TF items (440-2)
  21. Hi, when i using method community.editProfile - it remove my background if it exist
  22. Is there a way to fetch certain data like the Steam Profile Name and Steam Avatar, if the Profile is Public, Steam Level, Ability to Invite Friends etc. and fetch it from Steam via Steam-User or is that something I would have to do without Steam-User via Steam Web API?
  23. 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
  24. 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.
×
×
  • Create New...