Jump to content


Photo
Question

How to get an array of the users whom relationship is 2 (Waiting for friend request to accept)?

node.js node-steam-user

Best Answer Dr. McKay , 28 March 2019 - 10:19 PM

client.myFriends is useless before friendsList is emitted.

Go to the full post


  • Please log in to reply
4 replies to this topic

#1 Slime

Slime

    Newbie

  • Member
  • Pip
  • 8 posts

Posted 27 March 2019 - 12:06 PM

I would like it to accept everyone who added me when the bot wasn't opened. i've tried to do that but i think i didn't get how it works, here's what i tried:
 

client.on('loggedOn', () => {
    client.setPersona(1);
    client.getPersonas(client.myFriends);
});

client.on('user', function (sid, user) {
    console.log(sid + " " + user.value);
    if (user.value == 2) {
        client.addFriend(sid);
        client.getChatHistory(sid);
    }
});



#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,162 posts

Posted 27 March 2019 - 09:02 PM

Replace user.value == 2 with client.myFriends[sid.toString()] == SteamUser.EFriendRelationship.RequestRecipient



#3 Slime

Slime

    Newbie

  • Member
  • Pip
  • 8 posts

Posted 28 March 2019 - 07:10 AM

Replace user.value == 2 with client.myFriends[sid.toString()] == SteamUser.EFriendRelationship.RequestRecipient

It seems to be working tho the client.myFriends don't include the users that are waiting for you to accept thier friend request...
Is there a way to get them from any other array or something?
Thanks for the quick respond btw.



#4 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,162 posts

Posted 28 March 2019 - 10:19 PM   Best Answer

client.myFriends is useless before friendsList is emitted.



#5 Slime

Slime

    Newbie

  • Member
  • Pip
  • 8 posts

Posted 29 March 2019 - 01:12 AM

Thanks for the info and the quick answer as always. i've made this and it works if anyone wants it:
 

client.on('friendsList', function () {
    console.log("Searching for friend requests...");
    for (var i = 0; i < Object.keys(client.myFriends).length; i++) {
        if (client.myFriends[Object.keys(client.myFriends)[i]] == SteamUser.EFriendRelationship.RequestRecipient) {
            console.log("Added " + Object.keys(client.myFriends)[i]);
            client.addFriend(Object.keys(client.myFriends)[i]);
            client.getChatHistory(Object.keys(client.myFriends)[i]);
        }
    }
});






Also tagged with one or more of these keywords: Question, node.js, node-steam-user

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users