我已经尝试了一段时间,当机器人处于脱机状态并收到好友请求时。当机器人再次上线时他会自动接受。
如果我用谷歌搜索我的问题,尽管我会为与此问题同义的其他人提供一些建议。不幸的是没有任何作用
这是我的代码:
const SteamUser = require('steam-user');
const config = require('./config.json');
const client = new SteamUser();
var Steam = require('steam');
var _ = require("underscore");
const logOnOptions = {
accountName: config.username,
password: config.password
};
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,
};
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");
};
client.logOn(logOnOptions);
client.on('loggedOn', () => {
console.log('succesfully logged on.');
client.setPersona(SteamUser.Steam.EPersonaState.Online);
client.gamesPlayed(["Service Online, Type !start to Start",486310])
});
client.on('friendRelationship', function(sid, relationship) {
if (relationship == SteamUser.EFriendRelationship.RequestRecipient) {
console.log("Wir haben eine Freundesanfrage von" +sid);
client.addFriend(sid, function (err, name) {
if (err) {
console.log(err);
return;
}
console.log("Akzeptiere User mit dem Namen "+name)
client.chatMessage(sid, 'Type !start to Start');
})
}
})
client.on('friendsList', function() {
for (var sid in client.myFriends);
var relationship = client.myFriends[sid]
if (relationship == SteamUser.EFriendRelationship.RequestRecipient) {
console.log("(offline) We recieved a friend request from "+sid);
client.addFriend(sid, function (err, name) {
if (err) {
console.log(err);
return;
}
console.log("(offline) Accepted user with the name of "+name)
})
}
})
感谢可以帮助我的人:)