NodeJS - Steam API - Auto Accept Friend Requests

I’m trying to figure out how to automatically accept friend requests as I’m really bored. I did something here and there on the bot I started with.

Here are two useful links:
https://github.com/seishun/node-steam/blob/master/README.md#relationships
https://github.com/seishun/node-steam/blob/master/README.md# friends

So, I was trying to figure out how I can automatically accept friends' requests using them.

There is currently a pending friend request, and I wonder how I will automatically receive it or even print the current friend requests.

Here is what my "friend" event looks like you can read about @ node -steam readme.

http://puu.sh/6XznQ.png

The friend event says the following:

The friends and groups properties now contain data (unless your friend/group list is empty). Listen for this if you want to accept/decline friend requests that came while you were offline, for example.

, ? , . , .: 3

, , , . , "friend" , , , . ; :

second image

, , , "friend" ?

2; "", "". , .

:

Steam.EFriendRelationship = {
  None: 0,
  Blocked: 1,
  PendingInvitee: 2, // obsolete - renamed to RequestRecipient
  RequestRecipient: 2,
  Friend: 3,
  RequestInitiator: 4,
  PendingInviter: 4, // obsolete - renamed to RequestInitiator
  Ignored: 5,
  IgnoredFriend: 6,
  SuggestedFriend: 7,
  Max: 8,
};

, , . :

console.log(Steam.EFriendRelationship.PendingInvitee);

'2', . ?

+4
1

...

. :

var Steam = require("steam");
var steam = new Steam.SteamClient()

steam.on("friend", function(steamID, relationship) {
    if (relationship == Steam.EFriendRelationship.PendingInvitee) {
        console.log("friend request received");
        steam.addFriend(steamID);
        console.log("friend request accepted");
    }
});

, " " , , , .

Edit:

, , , ;

var _ = require("underscore");

var addPendingFriends = function() {
    console.log("searching for pending friend requests...");
    _.each(steam.friends, function(relationship, steamID) {
        if (relationship == Steam.EFriendRelationship.RequestRecipient) {
            steam.addFriend(steamID);
            console.log(steamID+" was added as a friend");
        }
    });
    console.log("finished searching");
};

, , ?:)

: addPendingFriends(); webLogOn(), , steam.friends loggedOn.

+9

Source: https://habr.com/ru/post/1527135/


All Articles