Seeringfate Posted May 28, 2017 Report Posted May 28, 2017 Hi there, I'm trying to get my bot to accept friends request from members from my group.My code is not fully working, it keep getting errors at "community.groups(steamid). Here is my code: client.on("friendRelationship", (steamid, reletionship, name) => { if (reletionship === 2) { var userGroups = community.groups(steamid) if (userGroups.indexOf(wantedGroupID) != -1) { client.addFriend(steamid); client.chatMessage(steamid, `Thank you for adding me!`); console.log(`Friends request from ${name} accepted, IdleNet member. SteamID: ${steamid}`); } else { client.removeFriend(steamid); console.log(`Ignored friends request from ${name}, not in the IdleNet group. SteamID: ${steamid}`); } } });This is before my code: const SteamUser = require('steam-user'); const SteamTotp = require("steam-totp"); const SteamCommunity = require("steamcommunity"); const TradeOfferManager = require("steam-tradeoffer-manager"); var wantedGroupID = 'groupid'; const client = new SteamUser(); const community = new SteamCommunity(); const manager = new TradeOfferManager({ steam: client, community: community, language: "en" }); const logOnOptions = { accountName: 'name', password: 'pass', twoFactorCode: SteamTotp.generateAuthCode("secret") }; client.logOn(logOnOptions); client.on('loggedOn', () => { console.log('Logged into Steam'); client.setPersona(SteamUser.Steam.EPersonaState.Online) client.gamesPlayed("Testing"); }); client.on("webSession", (sessionid, cookies) => { manager.setCookies(cookies); community.setCookies(cookies); community.startConfirmationChecker(10000, "secret"); }); Could someone help me ? Thanks ! Quote
SunriseM Posted May 29, 2017 Report Posted May 29, 2017 Where did you get community.groups from? i haven't heard of it. You should use community.getGroupMembers() method. community.getGroupMembers("groupid", function(err, members) { //Check if steamid is included in members array }); Quote
Seeringfate Posted May 30, 2017 Author Report Posted May 30, 2017 (edited) Where did you get community.groups from? i haven't heard of it. You should use community.getGroupMembers() method. community.getGroupMembers("groupid", function(err, members) { //Check if steamid is included in members array });This worked, this only created a new problem:the getGroupMembers has a Steam3ID output while my code works with SteamID64.So I can get the array and find my string there, but how do I convert the Steam3ID to a SteamID64 ? My code now: // Accepting friends requests. client.on("friendRelationship", (steamid, reletionship) => { if (reletionship === 2) { community.getGroupMembers('GROUPID', function(err, members) { if (members.indexOf(steamid) > -1) { client.addFriend(steamid); client.chatMessage(steamid, `Thank you for adding me!`); console.log(`Friends request accepted, is group member. SteamID: ${steamid}`); } else if (err){ console.log(err); } else { client.removeFriend(steamid); console.log(`Ignored friends request, not in the group. SteamID: ${steamid}`); } }); } }); Thanks ! Edited May 30, 2017 by Seeringfate Quote
Seeringfate Posted June 2, 2017 Author Report Posted June 2, 2017 (edited) I fixed it, for people who have the same issue, here is what I did:first I created a new array containing all accountid's from the group members: const groupMembers = []; community.getGroupMembers('GROUPID', function(err, members) { for(x = 0; x < members.length; x++) { groupMembers.push(members[x].accountid); } }); after that I compared it to the acountID from the getGroupMembers function: client.on("friendRelationship", (steamid, reletionship, name) => { if (reletionship === 2) { community.getGroupMembers('GROUPID', function(err, members) { if (groupMembers.indexOf(steamid.accountid) > -1) { client.addFriend(steamid); client.chatMessage(steamid, `Thank you for adding me!`); console.log(`Friends request accepted, member. SteamID: ${steamid}`); } else if (err){ console.log(err); } else { client.removeFriend(steamid); console.log(`Ignored friends request, not in the group. SteamID: ${steamid}`); } }); } }); Edited June 2, 2017 by Seeringfate Quote
1Life1Chance Posted March 26, 2018 Report Posted March 26, 2018 This way have a some problems like sometime didn't get members list or update members list Quote
1Life1Chance Posted March 31, 2018 Report Posted March 31, 2018 Hey! Anyone know how i can clear getGroupMembers cache ? I need this becase when i launch first time function it get members but after didn't get new members. Quote
neverhood Posted September 10, 2018 Report Posted September 10, 2018 I have same problem, my bot checking if user is in group with every trade, but list doesnt refresh :/ Quote
Dr. McKay Posted September 10, 2018 Report Posted September 10, 2018 I have same problem, my bot checking if user is in group with every trade, but list doesnt refresh :/ You should use the WebAPI to check if a user is in a group. Quote
neverhood Posted September 10, 2018 Report Posted September 10, 2018 ye but I guess user needs to have public/friends only profile, its easier to get group members and compare it with offer.partner, anyway this method 'getGroupMembers' depends of steam (they refreshing every 5-10 min group members - I tried to refresh .xml manually) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.