2014-02-15 48 views
4

我想弄清楚如何自動接受朋友請求,因爲我真的很無聊我一直在做一些東西在這裏和那裏我已經開始了一個機器人。NodeJS - 蒸汽API - 自動接受朋友請求

這裏有兩個有用的鏈接:
https://github.com/seishun/node-steam/blob/master/README.md#relationships
https://github.com/seishun/node-steam/blob/master/README.md#friends

所以我一直在試圖找出我怎麼會讓它自動接受使用這些朋友的請求。

目前有一個待處理的朋友請求,我很好奇我會如何自動接受它,甚至打印當前的朋友請求。

以下是您可以閱讀有關@ node-steam的自述文件的我的'朋友'事件,看起來像。

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

在「朋友」的事件,它說以下內容:

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

我已經知道我做錯了,但我一直在這裏坐了很長一段時間,試圖弄明白,但我做不到。如果有不止一個朋友請求,我的'朋友'活動將無法正常工作,因爲它需要通過所有現有的活動,但我仍然不確定該如何做。 編輯;我只是嘗試這樣做:

second image

目前,它至少有一個朋友的要求,但它不會對反應,所以我想「朋友」事件是錯誤的?

編輯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',因爲這是枚舉值。我將如何獲取列出的所有待處理邀請?

+0

@mathias ..嗨,我想在我的意思應用程序做朋友請求....我已經嘗試了很多方法,我已經搜索了很多鏈接,以找到確切的解決方案,但它對我們沒有用......所以你能請幫助我們?...我如何在我的應用程序中做朋友請求....請幫助我們,,,謝謝如果您有闖入者請提供知道確切的結構和解決方案以及... –

回答

9

要回答你的第一個問題......

我其實一直在寫一個機器人與此今天和整個問題就來了。 我是這樣做的:

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"); 
    } 
}); 

這是相當不言自明,但它打印「好友請求獲得」在收到好友請求,加入的朋友,那麼加入朋友的照片。

編輯:

這裏是如何添加,而機器人脫機已發送好友請求;

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"); 
}; 

如果我是對的,這是你在找什麼? :)

重要說明:call addPendingFriends();在webLogOn()之後,似乎steam.friends不會在登錄後啓動。