prk*_*prk 4 javascript node.js
我正在试图弄清楚如何自动接受朋友请求,因为我真的很无聊我已经在这里和那里开始做一些机器人我已经开始了.
这里有两个有用的链接:
https
:
//github.com/seishun/node-steam/blob/master/README.md#relationships
https://github.com/seishun/node-steam/blob/master/README.md#朋友
所以我一直试图弄清楚如何通过使用它来自动接受朋友请求.
目前有一个待处理的好友请求,我很好奇我将如何让它自动接受它,甚至打印当前的好友请求.
这是我关于@ node-steam自述文件的"朋友"活动,看起来像.
在"朋友"活动下,它说如下:
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.
Run Code Online (Sandbox Code Playgroud)
我很好奇我将如何访问这两个属性?对不起,如果这是一个愚蠢的问题.提前谢谢,我还在学习.:3
我已经确定我做错了但是我已经在这里待了很长时间并试图弄明白,但我做不到.如果有多个朋友请求,我的"朋友"事件将无法工作,因为它需要通过所有现有的事件,但我仍然不确定如何做到这一点.编辑; 我刚试过这个:
它目前至少有一个朋友请求,但它没有对此作出反应,所以我认为'朋友'事件是错误的?
编辑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,
};
Run Code Online (Sandbox Code Playgroud)
我不确定我将如何通过所有现有的朋友邀请.使用:
console.log(Steam.EFriendRelationship.PendingInvitee);
Run Code Online (Sandbox Code Playgroud)
返回'2',因为这是枚举的值.如何列出所有挂起的邀请?
回答你的第一个问题......
我今天真的用这个写了一个机器人并遇到了问题.这是我如何做到的:
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");
}
});
Run Code Online (Sandbox Code Playgroud)
这是相当不言自明的,但它在收到朋友请求后打印"收到朋友请求",添加朋友,然后打印添加了朋友.
编辑:
以下是添加机器人离线时发送的好友请求的方法;
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");
};
Run Code Online (Sandbox Code Playgroud)
如果我是对的,这就是你要找的东西?:)
重要说明:调用addPendingFriends(); 在webLogOn()之后,似乎steam.friends不是在loggedOn上启动的.
归档时间: |
|
查看次数: |
5000 次 |
最近记录: |