-
Posts
43 -
Joined
-
Last visited
Reputation Activity
-
SnaBe got a reaction from Dr. McKay in Do i use this event wrong
You probably want to listen for the 'newOffer' event using your steam-tradeoffer-manager instance.
-
SnaBe got a reaction from Op1x3r in Escrow trades
You can get a user's escrow days by using getUserDetails() and only send the trade offer if your trade partner's escrow days are 0, otherwise, you would cancel the offer and notify the user.
-
SnaBe got a reaction from vrtgn in inviteToGroup
Since you haven't posted any code I'm unsure how you're using the method. So I'll show you how I usually do it.
Let's say you want to invite the user as soon as they become friends with yout bot, you can do it as follows:
client.on('friendRelationship', (steamID, relationship) => { switch(relationship) { //The bot received a friend request from another Steam user case 2: console.log(`Bot ${client.steamID.getSteamID64()} received a friend request from user ${steamID}.`); client.addFriend(steamID, (err) => { if(err) { console.log(`Error adding user ${steamID}.`); } else { client.getPersonas([steamID], (err, personas) => { var persona = personas[steamID.getSteamID64()]; var name = persona ? persona.player_name : ("[" + steamID.getSteamID64() + "]"); client.chatMessage(steamID, `Greetings ${name}! ${config.steam.messages.new_friend}`); }); console.log(`Bot ${client.steamID.getSteamID64()} accepted user ${steamID}'s friend request.`); } }); break; //The bot is now friends with another Steam user case 3: //Invite that user to our Steam group client.inviteToGroup(steamID, config.steam.groupID); console.log(`Bot ${client.steamID.getSteamID64()} invited user ${steamID} to our Steam group.`); break; default: break; } }); The inviteToGroup methods takes two arguments, the SteamID of the user you wish to invite and the groupID for the group.
The SteamID is retrieved from the friendRelationship event. You'll have to store your Steam group ID in a variable or in a separate file. I store mine in a JSON config file.
If you don't have the groupID you can find it by replacing <GroupName> in this url https://steamcommunity.com/groups/<GroupName>/memberslistxml/?xml=1 with the name of your Steam group. Then you'll be able to extract the groupID from the XML file in your browser.
I hope this helps!
-
SnaBe reacted to Dr. McKay in Interacting with CS:GO Storage Units programmatically
It's a planned feature for globaloffensive, but I haven't gotten around to adding it yet.
-
SnaBe reacted to vrtgn in Error: ETIMEDOUT and reload cookies
You're not meant to use the method I gave in conjunction with the confirmation checker.
The confirmation checker (in simple terms) works by telling Steam every X seconds: "Hey, I wanna confirm everything waiting to be confirmed". It will tell steam even if there is nothing waiting to be confirmed thus the load it puts on servers - imagine loads of bots doing this.
Whereas the method I put tells steams servers: "Hey, I wanna confirm this specific trade". Therefore, it only tells steam when there is something to be confirmed.
-
SnaBe got a reaction from vrtgn in Web App to idle hundreds of accounts?
You could make a seperate server for x amount of SteamUsers and use http requests to communicate with the main server.
-
SnaBe reacted to vrtgn in Creating Specific offer from chat command
Working out change is similar to the popular coin change problem, except you don't have infinite amount of each coin.
Here's how I would do it:
Convert the price to scrap. Then using the coin change problem work out the least amount of scrap needed. In this case your coins would be 1, 3, 9, and key price in scrap being scrap, rec, ref and key price in scrap respectively.
Look up the coin change problem and develop a function to work out the change. It's hard but also good to develop your coding skills. I wouldn't recommend to steal someone else's code since you don't know what it's doing and at the end of the day if your bot gets scammed it is your fault for not knowing how your code works.
-
SnaBe got a reaction from Raminos in [HELP] how to continue?
Here's how you can check if an offer you sent has been accepted or declined.
//When one of our trade offers changes states. manager.on('sentOfferChanged', function(offer, oldState) { //Alert us when an outgoing offer is accepted. if(offer.state == TradeOfferManager.ETradeOfferState.Accepted) { console.log('Our offer #' + offer.id + ' has been accepted.'); client.chatMessage(offer.partner.getSteamID64(), 'Thanks for the trade!'); } else if(offer.state == TradeOfferManager.ETradeOfferState.Declined) { console.log('Our offer #' + offer.id + ' has been declined.'); client.chatMessage(offer.partner.getSteamID64(), 'If you believe there\'s an error with your trade offer, please contact a staff member.'); } }); -
SnaBe got a reaction from Raminos in [HELP] how to continue?
To add an 'x' amount of keys to the array, just add an extra check in the if statement. (The one inside the for-loop)
//Loop for(var n = 0; n < inventory.length; n++) { if(theirKeys.length < amountOfKeysToAddVariable && config.csgo.acceptedKeys.indexOf(inventory[n].market_hash_name) >= 0) { theirKeys.push(inventory[n]); console.log(inventory[n].market_hash_name); } } The item ids are stored inside the theirKeys array, adding them to a trade offer is very simple.
offer.addTheirItems(theirKeys); I hope this helps!
-
SnaBe got a reaction from Raminos in [HELP] how to continue?
You're very close, here's how I would do it.
//Load the inventory manager.getUserInventoryContents(steamID, 730, 2, true, function(err, inventory) { if(err) { console.log('Error getting their inventory: ' + err); } else { console.log('Checking if user: ' + steamID + ' has any CS:GO keys we accept.'); for(var n = 0; n < inventory.length; n++) { if(config.csgo.acceptedKeys.indexOf(inventory[n].market_hash_name) >= 0) { console.log(inventory[n].market_hash_name); } } } }); acceptedKeys is an array containing all the current CS:GO keys, you can always remove or add keys to meet your needs.
"acceptedKeys": [ "Glove Case Key", "Spectrum Case Key", "Gamma 2 Case Key", "Clutch Case Key", "Huntsman Case Key", "Gamma Case Key", "Spectrum 2 Case Key", "Operation Breakout Case Key", "Shadow Case Key", "Chroma 3 Case Key", "Falchion Case Key", "Winter Offensive Case Key", "Revolver Case Key", "Chroma 2 Case Key" ] To store the keys for a possible trade offer, you would have to add them in a new array. Like so:
(This should be done within the for-loop)
//New empty array var theirKeys = []; //Add the keys to our array theirKeys.push(inventory[n]); After that, you can see how many keys the array contains.
console.log('User has ' + theirKeys.length + ' key(s).'); I would suggest a custom function for easier use.
function checkKeys(steamID) { //Their keys in a new array var theirKeys = []; //Load the inventory manager.getUserInventoryContents(steamID, 730, 2, true, function(err, inventory) { if(err) { console.log('Error getting their inventory: ' + err); } else { console.log('Checking if user: ' + steamID + ' has CS:GO keys.'); for(var n = 0; n < inventory.length; n++) { if(config.csgo.acceptedKeys.indexOf(inventory[n].market_hash_name) >= 0) { theirKeys.push(inventory[n]); console.log(inventory[n].market_hash_name); } } console.log('User has ' + theirKeys.length + ' key(s).'); } }); } Chat command example:
client.on('friendMessage', function(steamID, message) { if(message.match('!check')) { client.chatMessage(steamID, 'Handling your request...'); checkKeys(steamID); } else { client.chatMessage(steamID, 'I don\'t know that command.'); } }); -
SnaBe got a reaction from Dr. McKay in Chat command create and send trade offer... Can someone help ?
Alright, there's primarily to parts of creating a systen like this.
1. Handling chat commands / buy & sell requests from Steam chat.
2. Searching inventories for the required items and creating the trade offer.
Luckily for you, other users have had similar questions regarding this topic.
Here's an entry regarding chat commands.
Here's an entry regarding looping trough the inventory and looking for item matches.
I hope this helps!
-
SnaBe got a reaction from Midmines in Chat messages with some specific input (multiple lines)
Yes, it's possible to have "inputs" in a message or command.
To do so, you'll have to learn about regex.
Here's an example:
//Act on chat messages & commands client.on('friendMessage', (steamID, message) => { //Command place holder var cmd; //Does the message match our buy command if(cmd = message.match(/^!buy (\d+) (\D+)/i)) { //The amount to buy (input string to number) var amount = Number(cmd[1]); //The item to buy (input string) var item = cmd[2]; //Log the regex values console.log(`User ${steamID} would like to purchase ${amount} of ${item}`); //Call your function that takes these two values as arguments. sellItem(steamID, amount, item); } }); In the example above we're looking for a buy command match. The string has to start with !buy, contain a number & a set of characters. For numbers only we use 'd' & for characters we use 'D'. The number is the amount of an item to buy, while the charaters is the item's name. We can access these values by using the following notation cmd[1]. Here 1 is the first regex match & cmd[2] is the second one.
The (), \ & + all have different uses, escpeially when it comes to matching something from a string using regex. You can read more about those used in the example above here.
I hope this helps!
-
SnaBe reacted to CellSplitter in Can't post comments on profiles
If u have a free Account, you must be friends to comment on their profile. You must spend minimum 5 Dollar to your Acc. The higher your steam level, the more comments you can write before getting a cool down
-
SnaBe reacted to FallingLight in [HELP] how to continue?
Thanks Man. Meanwhile, I realized a few things.
Check if the offer is accepted
And if he/she is accept the offer -> bot receive of course items ->
for(var i = 0, len = items.length; i < len; i++){var itemnames = items.market_hash_name;} console.log("Received items: " + itemnames); Big Thanks to you man. You helped me so much and i learned so much thing about javascript.I know it's late, but Happy Christmas & New Year. -
SnaBe got a reaction from FallingLight in [HELP] how to continue?
You're very close, here's how I would do it.
//Load the inventory manager.getUserInventoryContents(steamID, 730, 2, true, function(err, inventory) { if(err) { console.log('Error getting their inventory: ' + err); } else { console.log('Checking if user: ' + steamID + ' has any CS:GO keys we accept.'); for(var n = 0; n < inventory.length; n++) { if(config.csgo.acceptedKeys.indexOf(inventory[n].market_hash_name) >= 0) { console.log(inventory[n].market_hash_name); } } } }); acceptedKeys is an array containing all the current CS:GO keys, you can always remove or add keys to meet your needs.
"acceptedKeys": [ "Glove Case Key", "Spectrum Case Key", "Gamma 2 Case Key", "Clutch Case Key", "Huntsman Case Key", "Gamma Case Key", "Spectrum 2 Case Key", "Operation Breakout Case Key", "Shadow Case Key", "Chroma 3 Case Key", "Falchion Case Key", "Winter Offensive Case Key", "Revolver Case Key", "Chroma 2 Case Key" ] To store the keys for a possible trade offer, you would have to add them in a new array. Like so:
(This should be done within the for-loop)
//New empty array var theirKeys = []; //Add the keys to our array theirKeys.push(inventory[n]); After that, you can see how many keys the array contains.
console.log('User has ' + theirKeys.length + ' key(s).'); I would suggest a custom function for easier use.
function checkKeys(steamID) { //Their keys in a new array var theirKeys = []; //Load the inventory manager.getUserInventoryContents(steamID, 730, 2, true, function(err, inventory) { if(err) { console.log('Error getting their inventory: ' + err); } else { console.log('Checking if user: ' + steamID + ' has CS:GO keys.'); for(var n = 0; n < inventory.length; n++) { if(config.csgo.acceptedKeys.indexOf(inventory[n].market_hash_name) >= 0) { theirKeys.push(inventory[n]); console.log(inventory[n].market_hash_name); } } console.log('User has ' + theirKeys.length + ' key(s).'); } }); } Chat command example:
client.on('friendMessage', function(steamID, message) { if(message.match('!check')) { client.chatMessage(steamID, 'Handling your request...'); checkKeys(steamID); } else { client.chatMessage(steamID, 'I don\'t know that command.'); } }); -
SnaBe reacted to Revadike in Where to start from for making a simple chat response bot
This is also a great guide: https://github.com/andrewda/node-steam-guide
-
SnaBe got a reaction from vmu123 in Help with a particular code (getpersona)
Here's how I would get the users display name on any chat message:
client.on('friendMessage', function(steamID, message) { //When we get a message show the users steamid64 and display name. client.getPersonas([steamID], function(personas) { var persona = personas[steamID.getSteamID64()]; var name = persona ? persona.player_name : ("[" + steamID.getSteamID64() + "]"); console.log('User: ' + steamID + '\'s display name is ' + name); }); }); An example of using setNickname to set a users nickname with a chat command:
//Command for setting a nickname client.on('friendMessage', function(steamID, message) { //If the message meets the requirements. var setNick; if(setNick = message.match(/^!setnick (\d+) (\D+)/i)) { var id = setNick[1]; var nickname = setNick[2]; console.log('User: ' + steamID + ' would like to give user: ' + id + ' the nickname of: ' + nickname); //Set the nickname client.setNickname(id, nickname, function(err) { if(err) { console.log('Error giving the user a nickname.'); } else { console.log('Success setting user ' + id + '\'s nickname as ' + nickname + '.'); } }); } }); I hope this helps!