Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function loginResponse (err) {
if (err) {
if (!lastLoginFailed && err.eresult !== SteamUser.EFriendRelationship.RateLimitExceeded && err.eresult !== SteamUser.EFriendRelationship.InvalidPassword) {
lastLoginFailed = true;
// Try and sign in without login key
log.warn('Failed to sign in to Steam, retrying without login key...');
login(null, loginResponse);
} else {
log.warn('Failed to sign in to Steam');
handler.onLoginFailure(err);
}
return;
}
checkAccountLimitations(function (err) {
if (err) {
throw err;
}
steam.on("friendRelationship", (sender, relationship) => {
var profile = tryGetProfile(sender);
var msg = "\*\* " + profile.name + " ";
if( relationship == Steam.EFriendRelationship.None ){
msg+= "❌ removed you.";
} else if( relationship == Steam.EFriendRelationship.RequestRecipient ){
msg+= "✅ sent a friend invite.";
} else if( relationship == Steam.EFriendRelationship.Friend ){
msg+= "✅ is now your friend.";
} else if( relationship == Steam.EFriendRelationship.Ignored || relationship == Steam.EFriendRelationship.IgnoredFriend ){
msg+="❌ ignored you.";
} else if( relationship == Steam.EFriendRelationship.Blocked ){
msg+="❌ blocked you.";
}
sendMessageAs(sender, msg);
});
}
steamids.push(id);
if( steam.myFriends[id] == Steam.EFriendRelationship.Friend ){
if( steam.users[id].persona_state == Steam.EPersonaState.Offline ) states.push("Offline");
else if( steam.users[id].persona_state == Steam.EPersonaState.Online ) states.push("Online");
else if( steam.users[id].persona_state == Steam.EPersonaState.Busy ) states.push("Busy");
else if( steam.users[id].persona_state == Steam.EPersonaState.Away ) states.push("Away");
else if( steam.users[id].persona_state == Steam.EPersonaState.Snooze ) states.push("Snooze");
else if( steam.users[id].persona_state == Steam.EPersonaState.LookingToPlay ) states.push("Looking to Play");
else if( steam.users[id].persona_state == Steam.EPersonaState.LookingToTrade ) states.push("Looking to Trade");
else states.push("Offline");
} else {
if( steam.myFriends[id] == Steam.EFriendRelationship.RequestRecipient ) states.push("Added you as a friend");
else if ( steam.myFriends[id] == Steam.EFriendRelationship.Ignored ) states.push("Blocked");
else states.push("??");
}
});
function getFriends () {
const friends = [];
for (const steamID64 in client.myFriends) {
if (!client.myFriends.hasOwnProperty(steamID64)) {
continue;
}
const relation = client.myFriends[steamID64];
if (relation == SteamUser.EFriendRelationship.Friend) {
friends.push(steamID64);
}
}
return friends;
}
client.on('friendsList', () => {
let friends = client.myFriends;
for(let friend in friends) {
if(friends.hasOwnProperty(friend)) {
let state = friends[friend];
if(state == SteamUser.EFriendRelationship.RequestRecipient)
client.addFriend(friend);
}
}
});
}
exports.friendRelationChanged = function (steamID, relationship) {
if (relationship === SteamUser.EFriendRelationship.Friend) {
onNewFriend(steamID);
checkFriendsCount(steamID);
} else if (relationship === SteamUser.EFriendRelationship.RequestRecipient) {
respondToFriendRequest(steamID);
}
};
function getFriends () {
const friends = [];
for (const steamID in client.myFriends) {
if (!Object.prototype.hasOwnProperty.call(client.myFriends, steamID)) {
continue;
}
const relation = client.myFriends[steamID];
if (relation === SteamUser.EFriendRelationship.Friend) {
friends.push(steamID);
}
}
return friends;
}
client.on('friendRelationship', (sid, relationship) => {
if(relationship == SteamUser.EFriendRelationship.RequestRecipient)
client.addFriend(sid);
if(relationship == SteamUser.EFriendRelationship.Friend) {
exports.message(sid, "Thanks for adding me, type !help to get started.");
offers.inviteUserToGroup(sid);
}
});