Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
SteamUser.prototype._handlerManager.add('PlayerClient.NotifyFriendNicknameChanged#1', function(body) {
let sid = SteamID.fromIndividualAccountID(body.accountid);
this.emit('nickname', sid, body.nickname || null);
if (!body.nickname) {
// removal
delete this.myNicknames[sid.getSteamID64()];
} else {
this.myNicknames[sid.getSteamID64()] = body.nickname;
}
});
handlers[Language.PlayersProfile] = function(body) {
let proto = decodeProto(Protos.CMsgGCCStrike15_v2_PlayersProfile, body);
if (!proto.account_profiles[0]) {
return;
}
let profile = proto.account_profiles[0];
let sid = SteamID.fromIndividualAccountID(profile.account_id);
this.emit('playersProfile', profile);
this.emit('playersProfile#' + sid.getSteamID64(), profile);
};
state.members_in_voice = state.members_in_voice.map(m => SteamID.fromIndividualAccountID(m));
return state;
}, false, function(body) {
var results = {};
var invalidSid = SteamID.fromIndividualAccountID(0).getSteamID64();
(body.publishedfiledetails || []).forEach(function(item) {
if (!item.publishedfileid) {
return;
}
for (var i in item) {
if (item.hasOwnProperty(i) && item[i] && typeof item[i] === 'object' && item[i].constructor.name == 'Long') {
item[i] = item[i].toString();
}
}
if (typeof item.creator === 'string' && item.creator != invalidSid) {
item.creator = new SteamID(item.creator);
} else {
item.creator = null;
} else if (key == 'timestamp' || key.match(/^time_/) || key.match(/_timestamp$/)) {
if (val === 0) {
obj[key] = null;
} else if (val !== null) {
obj[key] = new Date(val * 1000);
}
} else if (key == 'clanid' && typeof val === 'number') {
let id = new SteamID();
id.universe = SteamID.Universe.PUBLIC;
id.type = SteamID.Type.CLAN;
id.instance = SteamID.Instance.ALL;
id.accountid = val;
obj[key] = id;
} else if ((key == 'accountid' || key.match(/^accountid_/) || key.match(/_accountid$/)) && (typeof val === 'number' || val === null)) {
let newKey = key == 'accountid' ? 'steamid' : key.replace('accountid_', 'steamid_').replace('_accountid', '_steamid');
obj[newKey] = val === 0 || val === null ? null : SteamID.fromIndividualAccountID(val);
delete obj[key];
} else if (key.includes('avatar_sha')) {
let url = null;
if (obj[key] && obj[key].length) {
url = "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/chaticons/";
url += obj[key][0].toString(16) + '/';
url += obj[key][1].toString(16) + '/';
url += obj[key][2].toString(16) + '/';
url += obj[key].toString('hex') + '_256.jpg';
}
obj[key.replace('avatar_sha', 'avatar_url')] = url;
} else if (key.match(/^can_/) && obj[key] === null) {
obj[key] = false;
} else if (isDataObject(val)) {
obj[key] = preProcessObject(val);
}
token = b.readInt8(position + lookahead);
} while (v7 < 35);
if (backup < 0) {
break;
}
position += lookahead;
if (v5 === 0) {
continue;
}
results.push(SteamID.fromIndividualAccountID(v5));
}
return results;
}
body.nicknames.forEach(player => nicks[SteamID.fromIndividualAccountID(player.accountid).getSteamID64()] = player.nickname);
body.messages = body.messages.map((msg) => {
msg.sender = SteamID.fromIndividualAccountID(msg.sender);
msg.server_timestamp = new Date(msg.server_timestamp * 1000);
msg.ordinal = msg.ordinal || 0;
msg.message_bbcode_parsed = parseBbCode(msg.message);
msg.deleted = !!msg.deleted;
if (msg.server_message) {
msg.server_message.steamid_param = msg.server_message.accountid_param ? SteamID.fromIndividualAccountID(msg.server_message.accountid_param) : null;
delete msg.server_message.accountid_param;
}
return msg;
});
output.sessions = output.sessions.map((session) => {
return {
"steamid_friend": SteamID.fromIndividualAccountID(session.accountid_friend),
"time_last_message": session.last_message ? new Date(session.last_message * 1000) : null,
"time_last_view": session.last_view ? new Date(session.last_view * 1000) : null,
"unread_message_count": session.unread_message_count
};
});