Jump to content
McKay Development

SENPAY98K

Member
  • Posts

    47
  • Joined

  • Last visited

Posts posted by SENPAY98K

  1. Hi,
    is it posible to add games to cart and buy with steam balance ?
    Tried it, but not sure if im skipping/missung other requests.

    // Add games to cart
    for (let i = 0; i < arrayGames.length; i++) {
    	var gameID = Number(arrayGames[i]);
    	logINFO(`gameID: ` + gameID);
    
    	await addToCart(Steam, Community, sessionID, gameID);
    	await SLEEP(5000);
    }
    // Get transaction id
    let purchaseId = await scrapTransactionID(Community);
    logINFO(purchaseId);
    // Buy games in cart
    await purchaseGames(Community, purchaseId);
    
    function addToCart(Steam, Community, sessionID, subid) {
    	return new Promise((resolve) => {
    		Community.httpRequestPost(
    			`https://store.steampowered.com/cart/`,
    			{
    				form: {
    					snr: "1_5_9__403",
    					originating_snr: "1_direct-navigation__",
    					action: "add_to_cart",
    					sessionid: sessionID,
    					subid: subid,
    				},
    				headers: {
    					Host: "store.steampowered.com",
    					Origin: "https://store.steampowered.com",
    				},
    				json: true,
    			},
    			(err, res, body) => {
    				if (!err && res.resposeCode == 200) {
    					logINFO(`Success`);
    				} else {
    					logERROR(`Failed`);
    				}
    			}
    		);
    		resolve();
    	});
    } // func()
    
    function scrapTransactionID(Community) {
    	return new Promise((resolve) => {
    		Community.httpRequestPost(
    			`https://store.steampowered.com/cart`,
    			(err, res, body) => {
    				if (!err) {
    					let pattern = /https:\/\/store.steampowered.com\/checkout\/\?purchasetype=gift&cart=(\d+)&/;
    					let match = body.match(pattern);
    					if (match) {
    						logINFO(`Matched: ` + match[1]);
    						resolve(match[1]);
    					}
    				}
    			}
    		);
    	});
    } //func()
    
    function purchaseGames(Community, purchaseId) {
    	return new Promise((resolve) => {
    		Community.httpRequestPost(
    			`https://store.steampowered.com/checkout/finalizetransaction/`,
    			{
    				form: {
    					transid: purchaseId,
    					CardCVV2: "",
    					browserInfo: {
    						language: "en-US",
    						javaEnabled: "false",
    						colorDepth: 24,
    						screenHeight: 600,
    						screenWidth: 800,
    					},
    				},
    				headers: {
    					Host: "store.steampowered.com",
    					Origin: "https://store.steampowered.com",
    					Referer: `https://store.steampowered.com/checkout/?purchasetype=self&cart=${purchaseId}&snr=1_8_4__503`,
    				},
    				json: true,
    			},
    			(err, res, body) => {
    				if (!err) {
    					logINFO("success");
    				}
    			}
    		);
    		resolve();
    	});
    } //func()

     

  2. 4 hours ago, PonyExpress said:
    pos = 1
    function getItems(inventory, currency, startId, startPos) {
    // startId - assetid for new endpoint
    // startPos - pos for old endpoint
    
    // ... getting items using the old or new endpoint ...
    
    // if used new endpoint:
    if (body.more_items) {
    	getItems(inventory, currency, body.last_assetid, startPos + body.assets.length) // or startPos should be +/- 1?
    	return
    }
    
    // if used old endpoint:
    if (body.more) {
    	pos = pos + Object.keys(body.rgInventory).length + Object.keys(body.rgCurrency).length
    	let lastAssetid = Object.keys(body.rgInventory)[Object.keys(body.rgInventory).length - 1]
    	|| Object.keys(body.rgCurrency)[Object.keys(body.rgCurrency).length - 1] // this is the last received Assetid?
    
    	getItems(inventory, currency, lastAssetid, body.more_start)
    	return
    }
    
    }


    What is the paramater you use in old api ?
     

  3. On 4/20/2022 at 8:57 PM, Dr. McKay said:

    You could manually construct an object, like this:

    let assetIds = [1, 2, 3, 4, 5];
    offer.addTheirItems(assetIds.map(id => ({appid: 730, contextid: 2, assetid: id})));

    Steam needs to know which game you want to access items for, so the appid and contextid are required.

    the map only stocks ids 
     

    [
        {
            "appid": 753,
            "contextid": 6,
            "assetid": [
                [
                    "22434481908",
                    "22434481910",
                    "22434481915",
                    "22434481907",
                    "22434481917"
                ],
                [
                    "22434481909",
                    "22434481911",
                    "22434481918",
                    "22434481913",
                    "22434481919"
                ],
                [
                    "22434481914",
                    "22434481912",
                    "22434481921",
                    "22434481916",
                    "22434481920"
                ]
            ]
        }
    ]

     

  4. @PonyExpress

    Does not work i guess, returns empty object and arrays

     

    const database = {
        "730": { "amount": 5},
        "603750": { "amount": 5},
    	...
    }
    
    const cards = OFFER.itemsToGive;
    
    await getSets(cards, (cardSets, extraCards, unknownCards) => {
    if (cardSets) console.log(cardSets);
    if (extraCards) console.log(extraCards);
    if (unknownCards) console.log(unknownCards);
    })

     

  5. 2 minutes ago, PonyExpress said:

    In my case it works like this. Maybe this will help you.

    // lodash
    // cards = { "<appid>": ["<classid>": [ {<item>}, ... ], ... ], ... }
    // cardData = {"220":{"amount":8,"name":"Half-Life 2"} ... }
    
    function getSets(cards, callback) {
    	let cardSets = {}
    	let extraCards = []
    	let unknownCards = []
    	lodash.forOwn(cards, (cards, id) => {
    		id = id.toString()
    		if (cardData[id]) {
    			let cardCount = lodash.mapValues(cards, array => array.length)
    			cardCount = Object.keys(cardCount).map(number => cardCount[number])
    			let min = Math.min(...cardCount)
    			let max = Math.max(...cardCount)
    
    			// There is at least one full set.
    			if (Object.keys(cards).length == cardData[id].amount) {
    				cardSets[id] = []
    				for (let i = 0; i < min; i++) {
    					let set = []
    					lodash.forOwn(cards, item => {
    						set.push(item[i])
    					})
    					cardSets[id].push(set)
    				}
    
    			// There are no full sets.
    			} else {
    				min = 0
    			}
    
    			// Extra cards:
    			for (let i = min; i < max; i++) {
    				lodash.forOwn(cards, item => {
    					if (item[i]) {
    						extraCards.push(item[i])
    					}
    				})
    			}
    
    		// Unknown cards:
    		} else {
    			lodash.forOwn(cards, item => {
    				unknownCards.push(item)
    			})
    		}
    	})
    	callback(cardSets, extraCards, unknownCards)
    }

     


    I will try it, thank you :)

  6. 1 minute ago, PonyExpress said:

    If I remember correctly, you can specify language in Options ( https://github.com/DoctorMcKay/node-steam-tradeoffer-manager/wiki/TradeOfferManager#language )
    In this case, you will receive all data like name and tags.

    This can take up a lot of memory. (in my case, this required several gigabytes with a large number of trading offers / items in offers)

     If language disabled, you can check only classid. I don't know of any database that gives any additional information by classid.

     

    The language is not the problem here, 
    I receive the offer, i check the offer details, then filter items for trading cards only,
    after that i have a database of {appid, number of cards in set} which i need to compare against it
    and retrun the amount of sets

    Im lacking the idea of how to process it!

  7. 12 hours ago, Dr. McKay said:

    I dunno, maybe there's some second request that gets sent when you rate up some content that actually triggers the badge activity.

    Maybe the `/actions/LogFriendActivityUpvote` request !! 

    I already tried sending it with its options alongside with rate up status but always failed !!

    Can you help checking it ? @Dr. McKaydo you think anything missing in options ? 
    Also do you think it's similar to my previous thread `View a Broadcast` that steam badge did not detect it ?

    var optionLogRateActivity = {
        form: { sessionID: sessionID },
        headers: {
    		Host: 'steamcommunity.com',
    		Origin: 'https://steamcommunity.com',
    		Referer: 'https://steamcommunity.com/profiles/'+RatePostSteamID64+'/home/'
    	},
        json: true
    };
    var postURL0 = 'https://steamcommunity.com/actions/LogFriendActivityUpvote';
    community.httpRequestPost(postURL0, optionLogRateActivity, function (err, res, data) {
        if (err) {
            console.log('   [%s] actions/LogFriendActivityUpvote: FAIL'.red, logOnOptions.accountName);
        }
        if (!err) {
            console.log('   [%s] actions/LogFriendActivityUpvote: DONE'.green, logOnOptions.accountName);
        }
    },
        "steamcommunity"
    );
  8. Hi, im trying to achieve the task of Rate up content in your Activity Feed

    My code works fine and it really rate up the status, but in the steam badge it does not detect that.

    @Dr. McKay what you think is wrong ?

    // Rate up the status
    var optionRateActivityPost = {
        form: {
    		sessionid: sessionID,
    		vote: 1,
    		count: 6,
    		feature2: -1,
    		newestfirstpagination: true
    	},
        headers: {
    		Host: 'steamcommunity.com',
    		Origin: 'https://steamcommunity.com',
    		Referer: 'https://steamcommunity.com/profiles/'+RatePostSteamID64+'/home/'
    	},
        json: true
    };
    
    var postURL08 = 'https://steamcommunity.com/comment/UserStatusPublished/voteup/'+RatePostSteamID64+'/1639600415/';
    
    community.httpRequestPost(postURL08, optionRateActivityPost, function (err, res, data) {
        if (err) {
            console.log('   [%s] TASK08: Rate Activity Post: FAIL'.red, logOnOptions.accountName);
        }
        if (!err) {
            console.log('   [%s] TASK08: Rate Activity Post: DONE'.green, logOnOptions.accountName);
        }
    },
        "steamcommunity"
    );
  9. https://steamcommunity.com/?subsection=broadcasts

    Trying to view a steam brodcast but could make it, i don't know why!

    console.log('  [%s] Successfully Logged On.', logOnOptions.accountName);
    var optionViewBroadcast = {
        headers: { Host: 'steamcommunity.com', Referer: 'https://steamcommunity.com/?subsection=broadcasts'},
        json: true
    };
    var postURL02 = 'https://steamcommunity.com/broadcast/watch/'config.CasterID64+'/';
    community.httpRequestPost(postURL02, optionViewBroadcast, function (err, res, data) {
        if (err) { console.log(' TASK02: View Broadcast: FAIL ');
        }
        if (!err) { console.log(' TASK02: View Broadcast: DONE ');
        }
    });

    Any idea ?

×
×
  • Create New...