code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
getManifest(appID, depotID, manifestID, branchName, branchPassword, callback) {
if (typeof manifestID == 'object' && typeof manifestID.gid == 'string') {
// At some point, Valve changed the format of appinfo.
// Previously, appinfo.depots[depotId].manifests.public would get you the public manifest ID.
// Now, you need to access it with appinfo.depots[depotId].manifests.public.gid.
// Here's a shim to keep consumers working properly if they expect the old format.
manifestID = manifestID.gid;
this._warn(`appinfo format has changed: you now need to use appinfo.depots[${depotID}].manifests.${branchName || 'public'}.gid to access the manifest ID. steam-user is fixing up your input, but you should update your code to retrieve the manifest ID from its new location in the appinfo structure.`);
}
if (typeof branchName == 'function') {
callback = branchName;
branchName = null;
}
if (typeof branchPassword == 'function') {
callback = branchPassword;
branchPassword = null;
}
return StdLib.Promises.timeoutCallbackPromise(10000, ['manifest'], callback, async (resolve, reject) => {
let manifest = ContentManifest.parse((await this.getRawManifest(appID, depotID, manifestID, branchName, branchPassword)).manifest);
if (!manifest.filenames_encrypted) {
return resolve({manifest});
}
ContentManifest.decryptFilenames(manifest, (await this.getDepotDecryptionKey(appID, depotID)).key);
return resolve({manifest});
});
}
|
Download a depot content manifest.
@param {int} appID
@param {int} depotID
@param {string} manifestID
@param {string} branchName - Now mandatory. Use 'public' for a the public build (i.e. not a beta)
@param {string} [branchPassword]
@param {function} [callback]
@return Promise
|
getManifest
|
javascript
|
DoctorMcKay/node-steam-user
|
components/cdn.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/cdn.js
|
MIT
|
getRawManifest(appID, depotID, manifestID, branchName, branchPassword, callback) {
if (typeof branchName == 'function') {
callback = branchName;
branchName = null;
}
if (typeof branchPassword == 'function') {
callback = branchPassword;
branchPassword = null;
}
return StdLib.Promises.callbackPromise(['manifest'], callback, async (resolve, reject) => {
let {servers} = await this.getContentServers(appID);
let server = servers[Math.floor(Math.random() * servers.length)];
let urlBase = (server.https_support == 'mandatory' ? 'https://' : 'http://') + server.Host;
let vhost = server.vhost || server.Host;
let token = '';
if (server.usetokenauth == 1) {
// Only request a CDN auth token if this server wants one.
// I'm not sure that any servers use token auth anymore, but in case there's one out there that does,
// we should still try.
token = (await this.getCDNAuthToken(appID, depotID, vhost)).token;
}
if (!branchName) {
this._warn(`No branch name was specified for app ${appID}, depot ${depotID}. Assuming "public".`);
branchName = 'public';
}
let {requestCode} = await this.getManifestRequestCode(appID, depotID, manifestID, branchName, branchPassword);
let manifestRequestCode = `/${requestCode}`;
let manifestUrl = `${urlBase}/depot/${depotID}/manifest/${manifestID}/5${manifestRequestCode}${token}`;
this.emit('debug', `Downloading manifest from ${manifestUrl} (${vhost})`);
download(manifestUrl, vhost, async (err, res) => {
if (err) {
return reject(err);
}
if (res.type != 'complete') {
return;
}
try {
let manifest = await CdnCompression.unzip(res.data);
return resolve({manifest});
} catch (ex) {
return reject(ex);
}
});
});
}
|
Download and decompress a manifest, but don't parse it into a JavaScript object.
@param {int} appID
@param {int} depotID
@param {string} manifestID
@param {string} branchName - Now mandatory. Use 'public' for a the public build (i.e. not a beta)
@param {string} [branchPassword]
@param {function} [callback]
|
getRawManifest
|
javascript
|
DoctorMcKay/node-steam-user
|
components/cdn.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/cdn.js
|
MIT
|
getManifestRequestCode(appID, depotID, manifestID, branchName, branchPassword, callback) {
if (typeof branchPassword == 'function') {
callback = branchPassword;
branchPassword = null;
}
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, (resolve, reject) => {
this._sendUnified('ContentServerDirectory.GetManifestRequestCode#1', {
app_id: appID,
depot_id: depotID,
manifest_id: manifestID,
app_branch: branchName,
branch_password_hash: branchPassword ? StdLib.Hashing.sha1(branchPassword) : undefined
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
resolve({requestCode: body.manifest_request_code});
});
});
}
|
Gets a manifest request code
@param {int} appID
@param {int} depotID
@param {string} manifestID
@param {string} branchName
@param {string} [branchPassword]
@param {function} [callback]
|
getManifestRequestCode
|
javascript
|
DoctorMcKay/node-steam-user
|
components/cdn.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/cdn.js
|
MIT
|
downloadChunk(appID, depotID, chunkSha1, contentServer, callback) {
if (typeof contentServer === 'function') {
callback = contentServer;
contentServer = null;
}
chunkSha1 = chunkSha1.toLowerCase();
return StdLib.Promises.callbackPromise(['chunk'], callback, async (resolve, reject) => {
if (!contentServer) {
let {servers} = await this.getContentServers(appID);
contentServer = servers[Math.floor(Math.random() * servers.length)];
}
let urlBase = (contentServer.https_support == 'mandatory' ? 'https://' : 'http://') + contentServer.Host;
let vhost = contentServer.vhost || contentServer.Host;
let {key} = await this.getDepotDecryptionKey(appID, depotID);
let token = '';
if (contentServer.usetokenauth == 1) {
token = (await this.getCDNAuthToken(appID, depotID, vhost)).token;
}
download(`${urlBase}/depot/${depotID}/chunk/${chunkSha1}${token}`, vhost, async (err, res) => {
if (err) {
return reject(err);
}
if (res.type != 'complete') {
return;
}
try {
let result = await CdnCompression.unzip(SteamCrypto.symmetricDecrypt(res.data, key));
if (StdLib.Hashing.sha1(result) != chunkSha1) {
return reject(new Error('Checksum mismatch'));
}
return resolve({chunk: result});
} catch (ex) {
return reject(ex);
}
});
});
}
|
Download a chunk from a content server.
@param {int} appID - The AppID to which this chunk belongs
@param {int} depotID - The depot ID to which this chunk belongs
@param {string} chunkSha1 - This chunk's SHA1 hash (aka its ID)
@param {object} [contentServer] - If not provided, one will be chosen randomly. Should be an object identical to those output by getContentServers
@param {function} [callback] - First argument is Error/null, second is a Buffer containing the chunk's data
@return Promise
|
downloadChunk
|
javascript
|
DoctorMcKay/node-steam-user
|
components/cdn.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/cdn.js
|
MIT
|
downloadFile(appID, depotID, fileManifest, outputFilePath, callback) {
if (typeof outputFilePath === 'function') {
callback = outputFilePath;
outputFilePath = null;
}
return StdLib.Promises.callbackPromise(null, callback, async (resolve, reject) => {
if (fileManifest.flags & EDepotFileFlag.Directory) {
return reject(new Error(`Attempted to download a directory ${fileManifest.filename}`));
}
let numWorkers = 4;
let fileSize = parseInt(fileManifest.size, 10);
let bytesDownloaded = 0;
let {servers: availableServers} = await this.getContentServers(appID);
let servers = [];
let serversInUse = [];
let currentServerIdx = 0;
let downloadBuffer;
let outputFd;
let killed = false;
// Choose some content servers
for (let i = 0; i < numWorkers; i++) {
assignServer(i);
serversInUse.push(false);
}
if (outputFilePath) {
await new Promise((resolve, reject) => {
FS.open(outputFilePath, 'w', (err, fd) => {
if (err) {
return reject(err);
}
outputFd = fd;
FS.ftruncate(outputFd, fileSize, (err) => {
if (err) {
FS.closeSync(outputFd);
return reject(err);
}
return resolve();
});
});
});
} else {
downloadBuffer = Buffer.alloc(fileSize);
}
let self = this;
let queue = new StdLib.DataStructures.AsyncQueue(function dlChunk(chunk, cb) {
let serverIdx;
// eslint-disable-next-line
while (true) {
// Find the next available download slot
if (serversInUse[currentServerIdx]) {
incrementCurrentServerIdx();
} else {
serverIdx = currentServerIdx;
serversInUse[serverIdx] = true;
break;
}
}
self.downloadChunk(appID, depotID, chunk.sha, servers[serverIdx], (err, data) => {
serversInUse[serverIdx] = false;
if (killed) {
return;
}
if (err) {
// Error downloading chunk
if ((chunk.retries && chunk.retries >= 5) || availableServers.length == 0) {
// This chunk hasn't been retired the max times yet, and we have servers left.
reject(err);
queue.kill();
killed = true;
} else {
chunk.retries = chunk.retries || 0;
chunk.retries++;
assignServer(serverIdx);
dlChunk(chunk, cb);
}
return;
}
bytesDownloaded += data.length;
if (typeof callback === 'function') {
callback(null, {
type: 'progress',
bytesDownloaded,
totalSizeBytes: fileSize
});
}
// Chunk downloaded successfully
if (outputFilePath) {
FS.write(outputFd, data, 0, data.length, parseInt(chunk.offset, 10), (err) => {
if (err) {
reject(err);
queue.kill();
killed = true;
} else {
cb();
}
});
} else {
data.copy(downloadBuffer, parseInt(chunk.offset, 10));
cb();
}
});
}, numWorkers);
fileManifest.chunks.forEach((chunk) => {
queue.push(JSON.parse(JSON.stringify(chunk)));
});
queue.drain = () => {
// Verify hash
let hash;
if (outputFilePath) {
FS.close(outputFd, (err) => {
if (err) {
return reject(err);
}
if (fileSize === 0) {
// Steam uses a hash of all 0s if the file is empty, which won't validate properly
return resolve({type: 'complete'});
}
// File closed. Now re-open it so we can hash it!
hash = require('crypto').createHash('sha1');
FS.createReadStream(outputFilePath).pipe(hash);
hash.on('readable', () => {
if (!hash.read) {
return; // already done
}
hash = hash.read();
if (hash.toString('hex') != fileManifest.sha_content) {
return reject(new Error('File checksum mismatch'));
} else {
resolve({
type: 'complete'
});
}
});
});
} else {
if (fileSize > 0 && StdLib.Hashing.sha1(downloadBuffer) != fileManifest.sha_content) {
return reject(new Error('File checksum mismatch'));
}
return resolve({
type: 'complete',
file: downloadBuffer
});
}
};
if (fileSize === 0) {
// nothing to download, so manually trigger the queue drain method
queue.drain();
}
function assignServer(idx) {
servers[idx] = availableServers.splice(Math.floor(Math.random() * availableServers.length), 1)[0];
}
function incrementCurrentServerIdx() {
if (++currentServerIdx >= servers.length) {
currentServerIdx = 0;
}
}
});
}
|
Download a specific file from a depot.
@param {int} appID - The AppID which owns the file you want
@param {int} depotID - The depot ID which contains the file you want
@param {object} fileManifest - An object from the "files" array of a downloaded and parsed manifest
@param {string} [outputFilePath] - If provided, downloads the file to this location on the disk. If not, downloads the file into memory and sends it back in the callback.
@param {function} [callback]
@returns {Promise}
|
downloadFile
|
javascript
|
DoctorMcKay/node-steam-user
|
components/cdn.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/cdn.js
|
MIT
|
function assignServer(idx) {
servers[idx] = availableServers.splice(Math.floor(Math.random() * availableServers.length), 1)[0];
}
|
Download a specific file from a depot.
@param {int} appID - The AppID which owns the file you want
@param {int} depotID - The depot ID which contains the file you want
@param {object} fileManifest - An object from the "files" array of a downloaded and parsed manifest
@param {string} [outputFilePath] - If provided, downloads the file to this location on the disk. If not, downloads the file into memory and sends it back in the callback.
@param {function} [callback]
@returns {Promise}
|
assignServer
|
javascript
|
DoctorMcKay/node-steam-user
|
components/cdn.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/cdn.js
|
MIT
|
function incrementCurrentServerIdx() {
if (++currentServerIdx >= servers.length) {
currentServerIdx = 0;
}
}
|
Download a specific file from a depot.
@param {int} appID - The AppID which owns the file you want
@param {int} depotID - The depot ID which contains the file you want
@param {object} fileManifest - An object from the "files" array of a downloaded and parsed manifest
@param {string} [outputFilePath] - If provided, downloads the file to this location on the disk. If not, downloads the file into memory and sends it back in the callback.
@param {function} [callback]
@returns {Promise}
|
incrementCurrentServerIdx
|
javascript
|
DoctorMcKay/node-steam-user
|
components/cdn.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/cdn.js
|
MIT
|
getAppBetaDecryptionKeys(appID, password, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, ['keys'], callback, (resolve, reject) => {
this._send(EMsg.ClientCheckAppBetaPassword, {
app_id: appID,
betapassword: password
}, (body) => {
if (body.eresult != EResult.OK) {
return reject(Helpers.eresultError(body.eresult));
}
let branches = {};
(body.betapasswords || []).forEach((beta) => {
branches[beta.betaname] = Buffer.from(beta.betapassword, 'hex');
});
return resolve({keys: branches});
});
});
}
|
Request decryption keys for a beta branch of an app from its beta password.
@param {int} appID
@param {string} password
@param {function} [callback] - First arg is Error|null, second is an object mapping branch names to their decryption keys
@return Promise
|
getAppBetaDecryptionKeys
|
javascript
|
DoctorMcKay/node-steam-user
|
components/cdn.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/cdn.js
|
MIT
|
function download(url, hostHeader, destinationFilename, callback) {
if (typeof destinationFilename === 'function') {
callback = destinationFilename;
destinationFilename = null;
}
let timeout = null;
let ended = false;
let resetTimeout = () => {
clearTimeout(timeout);
timeout = setTimeout(() => {
if (ended) {
return;
}
ended = true;
callback(new Error('Request timed out'));
}, 10000);
};
let options = require('url').parse(url);
options.method = 'GET';
options.headers = {
Host: hostHeader,
Accept: 'text/html,*/*;q=0.9',
'Accept-Encoding': 'gzip,identity,*;q=0',
'Accept-Charset': 'ISO-8859-1,utf-8,*;q=0.7',
'User-Agent': 'Valve/Steam HTTP Client 1.0'
};
let module = options.protocol.replace(':', '');
let req = require(module).request(options, (res) => {
if (ended) {
return;
}
if (res.statusCode != 200) {
ended = true;
callback(new Error('HTTP error ' + res.statusCode));
return;
}
res.setEncoding('binary'); // apparently using null just doesn't work... thanks node
let stream = res;
if (res.headers['content-encoding'] && res.headers['content-encoding'] == 'gzip') {
stream = require('zlib').createGunzip();
stream.setEncoding('binary');
res.pipe(stream);
}
let totalSizeBytes = parseInt(res.headers['content-length'] || 0, 10);
let receivedBytes = 0;
let dataBuffer = Buffer.alloc(0);
if (destinationFilename) {
stream.pipe(require('fs').createWriteStream(destinationFilename));
}
stream.on('data', (chunk) => {
if (ended) {
return;
}
resetTimeout();
if (typeof chunk === 'string') {
chunk = Buffer.from(chunk, 'binary');
}
receivedBytes += chunk.length;
if (!destinationFilename) {
dataBuffer = Buffer.concat([dataBuffer, chunk]);
}
callback(null, {type: 'progress', receivedBytes: receivedBytes, totalSizeBytes: totalSizeBytes});
});
stream.on('end', () => {
if (ended) {
return;
}
ended = true;
callback(null, {type: 'complete', data: dataBuffer});
});
});
req.on('error', (err) => {
if (ended) {
return;
}
ended = true;
callback(err);
});
req.end();
resetTimeout();
}
|
Request decryption keys for a beta branch of an app from its beta password.
@param {int} appID
@param {string} password
@param {function} [callback] - First arg is Error|null, second is an object mapping branch names to their decryption keys
@return Promise
|
download
|
javascript
|
DoctorMcKay/node-steam-user
|
components/cdn.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/cdn.js
|
MIT
|
resetTimeout = () => {
clearTimeout(timeout);
timeout = setTimeout(() => {
if (ended) {
return;
}
ended = true;
callback(new Error('Request timed out'));
}, 10000);
}
|
Request decryption keys for a beta branch of an app from its beta password.
@param {int} appID
@param {string} password
@param {function} [callback] - First arg is Error|null, second is an object mapping branch names to their decryption keys
@return Promise
|
resetTimeout
|
javascript
|
DoctorMcKay/node-steam-user
|
components/cdn.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/cdn.js
|
MIT
|
resetTimeout = () => {
clearTimeout(timeout);
timeout = setTimeout(() => {
if (ended) {
return;
}
ended = true;
callback(new Error('Request timed out'));
}, 10000);
}
|
Request decryption keys for a beta branch of an app from its beta password.
@param {int} appID
@param {string} password
@param {function} [callback] - First arg is Error|null, second is an object mapping branch names to their decryption keys
@return Promise
|
resetTimeout
|
javascript
|
DoctorMcKay/node-steam-user
|
components/cdn.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/cdn.js
|
MIT
|
chatMessage(recipient, message, type) {
recipient = Helpers.steamID(recipient);
type = type || EChatEntryType.ChatMsg;
if ([SteamID.Type.CLAN, SteamID.Type.CHAT].indexOf(recipient.type) != -1) {
// It's a chat message
let msg = ByteBuffer.allocate(8 + 8 + 4 + Buffer.byteLength(message) + 1, ByteBuffer.LITTLE_ENDIAN);
msg.writeUint64(this.steamID.getSteamID64()); // steamIdChatter
msg.writeUint64(toChatID(recipient).getSteamID64()); // steamIdChatRoom
msg.writeUint32(type); // chatMsgType
msg.writeCString(message);
this._send(EMsg.ClientChatMsg, msg.flip());
} else {
this.chat.sendFriendMessage(recipient, message, {chatEntryType: type});
}
}
|
Sends a chat message to a user or a chat room.
@param {(SteamID|string)} recipient - The recipient user/chat, as a SteamID object or a string which can parse into one. To send to a group chat, use the group's (clan's) SteamID.
@param {string} message - The message to send.
@param {EChatEntryType} [type=ChatMsg] - Optional. The type of the message. Defaults to ChatMsg. Almost never needed.
@deprecated Use SteamUser.chat.sendFriendMessage instead
|
chatMessage
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
chatMsg(recipient, message, type) {
return this.chatMessage(recipient, message, type);
}
|
Sends a chat message to a user or a chat room.
@param {(SteamID|string)} recipient - The recipient user/chat, as a SteamID object or a string which can parse into one. To send to a group chat, use the group's (clan's) SteamID.
@param {string} message - The message to send.
@param {EChatEntryType} [type=ChatMsg] - Optional. The type of the message. Defaults to ChatMsg. Almost never needed.
@deprecated Use SteamUser.chat.sendFriendMessage instead
|
chatMsg
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
chatTyping(recipient) {
this.chatMessage(recipient, '', EChatEntryType.Typing);
}
|
Tell another user that you're typing a message.
@param {SteamID|string} recipient - The recipient, as a SteamID object or a string which can parse into one.
@deprecated Use SteamUser.chat.sendFriendTyping instead
|
chatTyping
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
getChatHistory(steamID, callback) {
return StdLib.Promises.callbackPromise(['messages'], callback, true, (resolve, reject) => {
steamID = Helpers.steamID(steamID);
let sid64 = steamID.getSteamID64();
this._send(EMsg.ClientFSGetFriendMessageHistory, {
steamid: sid64
});
/**
* Simply binds a listener to the `chatHistory` event and removes the SteamID parameter.
* @callback SteamUser~getChatHistoryCallback
* @param {Error|null} success - Was the request successful?
* @param {Object[]} messages - An array of message objects
* @param {SteamID} messages[].steamID - The SteamID of the user who sent the message (either you or the other user)
* @param {Date} messages[].timestamp - The time when the message was sent
* @param {string} messages[].message - The message that was sent
* @param {bool} messages[].unread - true if it was an unread offline message, false if just a history message
*/
Helpers.onceTimeout(10000, this, 'chatHistory#' + sid64, (err, steamID, success, messages) => {
err = err || Helpers.eresultError(success);
if (err) {
return reject(err);
} else {
return resolve({messages});
}
});
});
}
|
Requests chat history from Steam with a particular user. Also gets unread offline messages.
@param {(SteamID|string)} steamID - The SteamID of the other user with whom you're requesting history (as a SteamID object or a string which can parse into one)
@param {SteamUser~getChatHistoryCallback} [callback] - An optional callback to be invoked when the response is received.
@return Promise
|
getChatHistory
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
joinChat(steamID, callback) {
return StdLib.Promises.callbackPromise([], callback, true, (resolve, reject) => {
let msg = ByteBuffer.allocate(9, ByteBuffer.LITTLE_ENDIAN);
msg.writeUint64(toChatID(steamID).getSteamID64()); // steamIdChat
msg.writeUint8(0); // isVoiceSpeaker
this._send(EMsg.ClientJoinChat, msg.flip());
Helpers.onceTimeout(10000, this, 'chatEnter#' + Helpers.steamID(steamID).getSteamID64(), (err, chatID, result) => {
err = err || Helpers.eresultError(result);
if (err) {
return reject(err);
} else {
return resolve();
}
});
});
}
|
Join a chat room. To join a group chat, use the group's (clan) SteamID.
@param {(SteamID|string)} steamID - The SteamID of the chat to join (as a SteamID object or a string which can parse into one)
@param {SteamUser~genericEResultCallback} [callback] - An optional callback to be invoked when the room is joined (or a failure occurs).
@return Promise
@deprecated This uses the old-style chat rooms, if you want new chat instead use this.chat
|
joinChat
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
leaveChat(steamID) {
let msg = ByteBuffer.allocate(32, ByteBuffer.LITTLE_ENDIAN);
msg.writeUint64(toChatID(steamID).getSteamID64()); // steamIdChat
msg.writeUint32(EChatInfoType.StateChange); // type
msg.writeUint64(this.steamID.getSteamID64());
msg.writeUint32(EChatMemberStateChange.Left);
msg.writeUint64(this.steamID.getSteamID64());
this._send(EMsg.ClientChatMemberInfo, msg.flip());
steamID = Helpers.steamID(steamID);
delete this.chats[steamID.getSteamID64()];
}
|
Leave a chat room.
@param {(SteamID|string)} steamID - The SteamID of the chat room to leave (as a SteamID object or a string which can parse into one)
@deprecated This uses the old-style chat rooms, if you want new chat instead use this.chat
|
leaveChat
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
setChatPrivate(steamID) {
let msg = ByteBuffer.allocate(20, ByteBuffer.LITTLE_ENDIAN);
msg.writeUint64(toChatID(steamID).getSteamID64()); // steamIdChat
msg.writeUint64(toChatID(steamID).getSteamID64()); // steamIdUserToActOn
msg.writeUint32(EChatAction.LockChat);
this._send(EMsg.ClientChatAction, msg.flip());
}
|
Sets a chat room private (invitation required to join, unless a member of the group [if the chat is a Steam group chat])
@param {(SteamID|string)} steamID - The SteamID of the chat room to make private (as a SteamID object or a string which can parse into one)
@deprecated This uses the old-style chat rooms, if you want new chat instead use this.chat
|
setChatPrivate
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
setChatPublic(steamID) {
let msg = ByteBuffer.allocate(20, ByteBuffer.LITTLE_ENDIAN);
msg.writeUint64(toChatID(steamID).getSteamID64()); // steamIdChat
msg.writeUint64(toChatID(steamID).getSteamID64()); // steamIdUserToActOn
msg.writeUint32(EChatAction.UnlockChat);
this._send(EMsg.ClientChatAction, msg.flip());
}
|
Sets a chat room public (no invitation required to join)
@param {(SteamID|string)} steamID - The SteamID of the chat room to make public (as a SteamID object or a string which can parse into one)
@deprecated This uses the old-style chat rooms, if you want new chat instead use this.chat
|
setChatPublic
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
setChatOfficersOnly(steamID) {
let msg = ByteBuffer.allocate(20, ByteBuffer.LITTLE_ENDIAN);
msg.writeUint64(toChatID(steamID).getSteamID64()); // steamIdChat
msg.writeUint64(toChatID(steamID).getSteamID64()); // steamIdUserToActOn
msg.writeUint32(EChatAction.SetModerated);
this._send(EMsg.ClientChatAction, msg.flip());
}
|
Sets a group chat room to officers-only chat mode.
@param {(SteamID|string)} steamID - The SteamID of the clan chat room to make officers-only (as a SteamID object or a string which can parse into one)
@deprecated This uses the old-style chat rooms, if you want new chat instead use this.chat
|
setChatOfficersOnly
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
unsetChatOfficersOnly(steamID) {
let msg = ByteBuffer.allocate(20, ByteBuffer.LITTLE_ENDIAN);
msg.writeUint64(toChatID(steamID).getSteamID64()); // steamIdChat
msg.writeUint64(toChatID(steamID).getSteamID64()); // steamIdUserToActOn
msg.writeUint32(EChatAction.SetUnmoderated);
this._send(EMsg.ClientChatAction, msg.flip());
}
|
Sets a group chat room out of officers-only chat mode, so that everyone can chat.
@param {(SteamID|string)} steamID - The SteamID of the clan chat room to make open (as a SteamID object or a string which can parse into one)
@deprecated This uses the old-style chat rooms, if you want new chat instead use this.chat
|
unsetChatOfficersOnly
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
kickFromChat(chatID, userID) {
userID = Helpers.steamID(userID);
let msg = ByteBuffer.allocate(20, ByteBuffer.LITTLE_ENDIAN);
msg.writeUint64(toChatID(chatID).getSteamID64()); // steamIdChat
msg.writeUint64(userID.getSteamID64()); // steamIdUserToActOn
msg.writeUint32(EChatAction.Kick);
this._send(EMsg.ClientChatAction, msg.flip());
}
|
Kicks a user from a chat room.
@param {(SteamID|string)} chatID - The SteamID of the chat room to kick the user from (as a SteamID object or a string which can parse into one)
@param {(SteamID|string)} userID - The SteamID of the user to kick from the room (as a SteamID object or a string which can parse into one)
@deprecated This uses the old-style chat rooms, if you want new chat instead use this.chat
|
kickFromChat
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
banFromChat(chatID, userID) {
userID = Helpers.steamID(userID);
let msg = ByteBuffer.allocate(20, ByteBuffer.LITTLE_ENDIAN);
msg.writeUint64(toChatID(chatID).getSteamID64()); // steamIdChat
msg.writeUint64(userID.getSteamID64()); // steamIdUserToActOn
msg.writeUint32(EChatAction.Ban);
this._send(EMsg.ClientChatAction, msg.flip());
}
|
Bans a user from a chat room.
@param {(SteamID|string)} chatID - The SteamID of the chat room to ban the user from (as a SteamID object or a string which can parse into one)
@param {(SteamID|string)} userID - The SteamID of the user to ban from the room (as a SteamID object or a string which can parse into one)
@deprecated This uses the old-style chat rooms, if you want new chat instead use this.chat
|
banFromChat
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
unbanFromChat(chatID, userID) {
userID = Helpers.steamID(userID);
let msg = ByteBuffer.allocate(20, ByteBuffer.LITTLE_ENDIAN);
msg.writeUint64(toChatID(chatID).getSteamID64()); // steamIdChat
msg.writeUint64(userID.getSteamID64()); // steamIdUserToActOn
msg.writeUint32(EChatAction.UnBan);
this._send(EMsg.ClientChatAction, msg.flip());
}
|
Unbans a user from a chat room.
@param {(SteamID|string)} chatID - The SteamID of the chat room to unban the user from (as a SteamID object or a string which can parse into one)
@param {(SteamID|string)} userID - The SteamID of the user to unban from the room (as a SteamID object or a string which can parse into one)
@deprecated This uses the old-style chat rooms, if you want new chat instead use this.chat
|
unbanFromChat
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
inviteToChat(chatID, userID) {
userID = Helpers.steamID(userID);
this._send(EMsg.ClientChatInvite, {
steam_id_invited: userID.getSteamID64(),
steam_id_chat: toChatID(chatID).getSteamID64()
});
}
|
Invites a user to a chat room.
@param {(SteamID|string)} chatID - The SteamID of the chat room to invite the user to (as a SteamID object or a string which can parse into one)
@param {(SteamID|string)} userID - The SteamID of the user to invite (as a SteamID object or a string which can parse into one)
@deprecated This uses the old-style chat rooms, if you want new chat instead use this.chat
|
inviteToChat
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
createChatRoom(convertUserID, inviteUserID, callback) {
return StdLib.Promises.callbackPromise(['chatID'], callback, true, (resolve, reject) => {
convertUserID = convertUserID || new SteamID();
inviteUserID = inviteUserID || new SteamID();
let msg = ByteBuffer.allocate(53, ByteBuffer.LITTLE_ENDIAN);
msg.writeUint32(EChatRoomType.MUC); // multi-user chat
msg.writeUint64(0);
msg.writeUint64(0);
msg.writeUint32(EChatPermission.MemberDefault);
msg.writeUint32(EChatPermission.MemberDefault);
msg.writeUint32(EChatPermission.EveryoneDefault);
msg.writeUint32(0);
msg.writeUint8(EChatFlags.Locked);
msg.writeUint64(Helpers.steamID(convertUserID).getSteamID64());
msg.writeUint64(Helpers.steamID(inviteUserID).getSteamID64());
this._send(EMsg.ClientCreateChat, msg.flip());
/**
* Called when the room is created or a failure occurs. If successful, you will be in the room when this callback fires.
* @callback SteamUser~createChatRoomCallback
* @param {Error|null} err - The result of the creation request
* @param {SteamID} [chatID] - The SteamID of the newly-created room, if successful
*/
Helpers.onceTimeout(10000, this, 'chatCreated#' + convertUserID.getSteamID64(), (err, convertUserID, result, chatID) => {
err = err || Helpers.eresultError(result || EResult.OK);
if (err) {
return reject(err);
} else {
return resolve({chatID});
}
});
});
}
|
Creates a new multi-user chat room
@param {null|SteamID|string} [convertUserID=null] - If the user with the SteamID passed here has a chat window open with us, their window will be converted to the new chat room and they'll join it automatically. If they don't have a window open, they'll get an invite.
@param {null|SteamID|string} [inviteUserID=null] - If specified, the user with the SteamID passed here will get invited to the new room automatically.
@param {SteamUser~createChatRoomCallback} [callback] - Called when the chat is created or a failure occurs.
@return Promise
@deprecated This uses the old-style chat rooms, if you want new chat instead use this.chat
|
createChatRoom
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
function toChatID(steamID) {
steamID = Helpers.steamID(steamID);
if (steamID.type == SteamID.Type.CLAN) {
steamID.type = SteamID.Type.CHAT;
steamID.instance |= SteamID.ChatInstanceFlags.Clan;
}
return steamID;
}
|
If steamID is a clan ID, converts to the appropriate chat ID. Otherwise, returns it untouched.
@param {SteamID} steamID
@returns SteamID
|
toChatID
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
function fromChatID(steamID) {
steamID = Helpers.steamID(steamID);
if (steamID.isGroupChat()) {
steamID.type = SteamID.Type.CLAN;
steamID.instance &= ~SteamID.ChatInstanceFlags.Clan;
}
return steamID;
}
|
If steamID is a clan chat ID, converts to the appropriate clan ID. Otherwise, returns it untouched.
@param {SteamID} steamID
@returns SteamID
|
fromChatID
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
function decomposeChatFlags(chat, chatFlags) {
chat.private = !!(chatFlags & EChatFlags.Locked);
chat.invisibleToFriends = !!(chatFlags & EChatFlags.InvisibleToFriends);
chat.officersOnlyChat = !!(chatFlags & EChatFlags.Moderated);
chat.unjoinable = !!(chatFlags & EChatFlags.Unjoinable);
}
|
Converts chat flags into properties on a chat room object
@param {Object} chat
@param {number} chatFlags
|
decomposeChatFlags
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chat.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chat.js
|
MIT
|
saveGroup(groupId, name, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, true, (resolve, reject) => {
this.user._sendUnified('ChatRoom.SaveChatRoomGroup#1', {
chat_group_id: groupId,
name
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
resolve();
});
});
}
|
Saves an unnamed "ad-hoc" group chat and converts it into a full-fledged chat room group.
@param {int} groupId
@param {string} name
@param {function} [callback]
@returns {Promise}
|
saveGroup
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
getGroups(callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, (resolve, reject) => {
this.user._sendUnified('ChatRoom.GetMyChatRoomGroups#1', {}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
body.chat_room_groups = body.chat_room_groups.map(v => processChatRoomSummaryPair(v));
let groups = {};
body.chat_room_groups.forEach((group) => {
groups[group.group_summary.chat_group_id] = group;
});
body.chat_room_groups = groups;
resolve(body);
});
});
}
|
Get a list of the chat room groups you're in.
@param {function} [callback]
@returns {Promise<{chat_room_groups: Object<string, {group_summary: ChatRoomGroupSummary, group_state: UserChatRoomGroupState}>}>}
|
getGroups
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
setSessionActiveGroups(groupIDs, callback) {
if (!Array.isArray(groupIDs)) {
groupIDs = [groupIDs];
}
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, (resolve, reject) => {
this.user._sendUnified('ChatRoom.SetSessionActiveChatRoomGroups#1', {
chat_group_ids: groupIDs,
chat_groups_data_requested: groupIDs
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
let groups = {};
body.chat_states.forEach((group) => {
groups[group.header_state.chat_group_id] = processChatGroupState(group);
});
resolve({chat_room_groups: groups});
});
});
}
|
Set which groups are actively being chatted in by this session. Only active group chats will receive some events,
like {@link SteamChatRoomClient#event:chatRoomGroupMemberStateChange}
@param {int[]|string[]|int|string} groupIDs - Array of group IDs you want data for
@param {function} [callback]
@returns {Promise<{chat_room_groups: Object<string, ChatRoomGroupState>}>}
|
setSessionActiveGroups
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
getInviteLinkInfo(linkUrl, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, (resolve, reject) => {
let match = linkUrl.match(/^https?:\/\/s\.team\/chat\/([^/]+)$/);
if (!match) {
return reject(new Error('Invalid invite link'));
}
this.user._sendUnified('ChatRoom.GetInviteLinkInfo#1', {invite_code: match[1]}, (body, hdr) => {
if (hdr.proto.eresult == EResult.InvalidParam) {
let err = new Error('Invalid invite link');
err.eresult = hdr.proto.eresult;
return reject(err);
}
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
body = preProcessObject(body);
if (Math.floor(body.time_expires / 1000) == Math.pow(2, 31) - 1) {
body.time_expires = null;
}
body.group_summary = processChatGroupSummary(body.group_summary, true);
body.user_chat_group_state = body.user_chat_group_state ? processUserChatGroupState(body.user_chat_group_state, true) : null;
body.banned = !!body.banned;
body.invite_code = match[1];
resolve(body);
});
});
}
|
Get details from a chat group invite link.
@param {string} linkUrl
@param {function} [callback]
@returns {Promise<{invite_code: string, steamid_sender: SteamID, time_expires: Date|null, group_summary: ChatRoomGroupSummary, time_kick_expire: Date|null, banned: boolean}>}
|
getInviteLinkInfo
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
getClanChatGroupInfo(clanSteamID, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, (resolve, reject) => {
clanSteamID = Helpers.steamID(clanSteamID);
if (clanSteamID.type != SteamID.Type.CLAN) {
return reject(new Error('SteamID is not for a clan'));
}
// just set these to what they should be
clanSteamID.universe = SteamID.Universe.PUBLIC;
clanSteamID.instance = SteamID.Instance.ALL;
this.user._sendUnified('ClanChatRooms.GetClanChatRoomInfo#1', {
steamid: clanSteamID.toString(),
autocreate: true
}, (body, hdr) => {
if (hdr.proto.eresult == EResult.Busy) {
// Why "Busy"? Because Valve.
let err = new Error('Invalid clan ID');
err.eresult = hdr.proto.eresult;
return reject(err);
}
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
body.chat_group_summary = processChatGroupSummary(body.chat_group_summary);
resolve(body);
});
});
}
|
Get the chat room group info for a clan (Steam group). Allows you to join a group chat.
@param {SteamID|string} clanSteamID - The group's SteamID or a string that can parse into one
@param {function} [callback]
@returns {Promise<{chat_group_summary: ChatRoomGroupSummary}>}
|
getClanChatGroupInfo
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
joinGroup(groupId, inviteCode, callback) {
if (typeof inviteCode === 'function') {
callback = inviteCode;
inviteCode = undefined;
}
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, (resolve, reject) => {
this.user._sendUnified('ChatRoom.JoinChatRoomGroup#1', {
chat_group_id: groupId,
invite_code: inviteCode
}, (body, hdr) => {
if (hdr.proto.eresult == EResult.InvalidParam) {
let err = new Error('Invalid group ID or invite code');
err.eresult = hdr.proto.eresult;
return reject(err);
}
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
body = preProcessObject(body);
body.state = processChatGroupState(body.state, true);
body.user_chat_state = processUserChatGroupState(body.user_chat_state, true);
resolve(body);
});
});
}
|
Join a chat room group.
@param {int|string} groupId - The group's ID
@param {string} [inviteCode] - An invite code to join this chat. Not necessary for public Steam groups.
@param {function} [callback]
@returns {Promise<{state: ChatRoomGroupState, user_chat_state: UserChatRoomGroupState}>}
|
joinGroup
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
leaveGroup(groupId, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, true, (resolve, reject) => {
this.user._sendUnified('ChatRoom.LeaveChatRoomGroup#1', {
chat_group_id: groupId
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
resolve();
});
});
}
|
Leave a chat room group
@param {int} groupId
@param {function} [callback]
@returns {Promise}
|
leaveGroup
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
inviteUserToGroup(groupId, steamId, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, true, (resolve, reject) => {
this.user._sendUnified('ChatRoom.InviteFriendToChatRoomGroup#1', {
chat_group_id: groupId,
steamid: Helpers.steamID(steamId).toString()
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
resolve();
});
});
}
|
Invite a friend to a chat room group.
@param {int} groupId
@param {SteamID|string} steamId
@param {function} [callback]
@returns {Promise}
|
inviteUserToGroup
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
createInviteLink(groupId, options, callback) {
if (typeof options == 'function') {
callback = options;
options = {};
}
options = options || {};
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, (resolve, reject) => {
this.user._sendUnified('ChatRoom.CreateInviteLink#1', {
chat_group_id: groupId,
seconds_valid: options.secondsValid || 60 * 60,
chat_id: options.voiceChatId
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
body.invite_url = 'https://s.team/chat/' + body.invite_code;
resolve(body);
});
});
}
|
Create an invite link for a given chat group.
@param {int} groupId
@param {{secondsValid?: int, voiceChatId?: int}} [options]
@param {function} [callback]
@returns {Promise<{invite_code: string, invite_url: string, seconds_valid: number}>}
|
createInviteLink
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
getGroupInviteLinks(groupId, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, (resolve, reject) => {
this.user._sendUnified('ChatRoom.GetInviteLinksForGroup#1', {
chat_group_id: groupId
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
body.invite_links = body.invite_links.map(v => preProcessObject(v)).map((link) => {
if (Math.floor(link.time_expires / 1000) == Math.pow(2, 31) - 1) {
link.time_expires = null;
}
if (link.chat_id == 0) {
link.chat_id = null;
}
link.invite_url = 'https://s.team/chat/' + link.invite_code;
return link;
});
resolve(body);
});
});
}
|
Get all active invite links for a given chat group.
@param {int} groupId
@param {function} [callback]
@returns {Promise<{invite_links: {invite_code: string, invite_url: string, steamid_creator: SteamID, time_expires: Date|null, chat_id: string}[]}>}
|
getGroupInviteLinks
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
deleteInviteLink(linkUrl, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, true, async (resolve, reject) => {
let details = await this.getInviteLinkInfo(linkUrl);
this.user._sendUnified('ChatRoom.DeleteInviteLink#1', {
chat_group_id: details.group_summary.chat_group_id,
invite_code: details.invite_code
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
resolve();
});
});
}
|
Revoke and delete an active invite link.
@param {string} linkUrl
@param {function} [callback]
@returns {Promise}
|
deleteInviteLink
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
sendFriendMessage(steamId, message, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
} else if (!options) {
options = {};
}
if (!options.chatEntryType) {
options.chatEntryType = EChatEntryType.ChatMsg;
}
if (options.chatEntryType && typeof options.containsBbCode === 'undefined') {
options.containsBbCode = true;
}
if (options.containsBbCode) {
message = message.replace(/\[/g, '\\[');
}
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, true, (resolve, reject) => {
this.user._sendUnified('FriendMessages.SendMessage#1', {
steamid: Helpers.steamID(steamId).toString(),
chat_entry_type: options.chatEntryType,
message,
contains_bbcode: options.containsBbCode
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
body = preProcessObject(body);
body.ordinal = body.ordinal || 0;
body.modified_message = body.modified_message || message;
body.message_bbcode_parsed = parseBbCode(body.modified_message);
resolve(body);
});
});
}
|
Send a direct chat message to a friend.
@param {SteamID|string} steamId
@param {string} message
@param {{[chatEntryType], [containsBbCode]}} [options]
@param {function} [callback]
@returns {Promise<{modified_message: string, server_timestamp: Date, ordinal: number}>}
|
sendFriendMessage
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
sendFriendTyping(steamId, callback) {
return this.sendFriendMessage(steamId, '', {chatEntryType: EChatEntryType.Typing}, callback);
}
|
Inform a friend that you're typing a message to them.
@param {SteamID|string} steamId
@param {function} [callback]
@returns {Promise}
|
sendFriendTyping
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
sendChatMessage(groupId, chatId, message, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, (resolve, reject) => {
this.user._sendUnified('ChatRoom.SendChatMessage#1', {
chat_group_id: groupId,
chat_id: chatId,
message
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
body = preProcessObject(body);
body.ordinal = body.ordinal || 0;
body.modified_message = body.modified_message || message;
body.message_bbcode_parsed = parseBbCode(body.modified_message);
resolve(body);
});
});
}
|
Send a message to a chat room.
@param {int|string} groupId
@param {int|string} chatId
@param {string} message
@param {function} [callback]
@returns {Promise<{modified_message: string, server_timestamp: Date, ordinal: number}>}
|
sendChatMessage
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
getActiveFriendMessageSessions(options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
options = options || {};
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, (resolve, reject) => {
let lastmessage_since = options.conversationsSince ? convertDateToUnix(options.conversationsSince) : undefined;
this.user._sendUnified('FriendMessages.GetActiveMessageSessions#1', {
lastmessage_since
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
let output = {
sessions: body.message_sessions || [],
timestamp: body.timestamp ? new Date(body.timestamp * 1000) : null
};
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
};
});
resolve(output);
});
});
}
|
Get a list of which friends we have "active" (recent) message sessions with.
@param {{conversationsSince?: Date|int}} [options]
@param {function} [callback]
@returns {Promise<{sessions: {steamid_friend: SteamID, time_last_message: Date, time_last_view: Date, unread_message_count: int}[], timestamp: Date}>}
|
getActiveFriendMessageSessions
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
getFriendMessageHistory(friendSteamId, options, callback) {
if (typeof options == 'function') {
callback = options;
options = {};
}
options = options || {};
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, async (resolve, reject) => {
let steamid2 = Helpers.steamID(friendSteamId).toString();
let count = options.maxCount || 100;
let bbcode_format = options.wantBbcode !== false;
let rtime32_start_time = options.startTime ? convertDateToUnix(options.startTime) : undefined;
let start_ordinal = rtime32_start_time ? options.startOrdinal : undefined;
let time_last = options.lastTime ? convertDateToUnix(options.lastTime) : Math.pow(2, 31) - 1;
let ordinal_last = time_last ? options.lastOrdinal : undefined;
let userLastViewed = 0;
try {
let activeSessions = await this.getActiveFriendMessageSessions();
let friendSess;
if (
activeSessions.sessions &&
(friendSess = activeSessions.sessions.find(sess => sess.steamid_friend.toString() == steamid2))
) {
userLastViewed = friendSess.time_last_view;
}
} catch (ex) {
this.user.emit('debug', `Exception reported calling getActiveFriendMessageSessions() inside of getFriendMessageHistory(): ${ex.message}`);
}
this.user._sendUnified('FriendMessages.GetRecentMessages#1', {
steamid1: this.user.steamID.toString(),
steamid2,
count,
most_recent_conversation: false,
rtime32_start_time,
bbcode_format,
start_ordinal,
time_last,
ordinal_last
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
body.messages = body.messages.map(msg => ({
sender: SteamID.fromIndividualAccountID(msg.accountid),
server_timestamp: new Date(msg.timestamp * 1000),
ordinal: msg.ordinal || 0,
message: msg.message,
message_bbcode_parsed: bbcode_format ? parseBbCode(msg.message) : null,
unread: msg.accountid != this.user.steamID.accountid && (msg.timestamp * 1000) > userLastViewed
}));
body.more_available = !!body.more_available;
resolve(body);
});
});
}
|
Get your chat message history with a Steam friend.
@param {SteamID|string} friendSteamId
@param {{maxCount?: int, wantBbcode?: boolean, startTime?: Date|int, startOrdinal?: int, lastTime?: Date|int, lastOrdinal?: int}} [options]
@param {function} [callback]
@returns {Promise<{messages: {sender: SteamID, server_timestamp: Date, ordinal: int, message: string, message_bbcode_parsed: null|Array<(BBCodeNode|string)>}[], more_available: boolean}>}
|
getFriendMessageHistory
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
getChatMessageHistory(groupId, chatId, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, (resolve, reject) => {
let max_count = options.maxCount || 100;
let last_time = options.lastTime ? convertDateToUnix(options.lastTime) : undefined;
let last_ordinal = options.lastOrdinal;
let start_time = options.startTime ? convertDateToUnix(options.startTime) : undefined;
let start_ordinal = options.startOrdinal;
this.user._sendUnified('ChatRoom.GetMessageHistory#1', {
chat_group_id: groupId,
chat_id: chatId,
last_time,
last_ordinal,
start_time,
start_ordinal,
max_count
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
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;
});
body.more_available = !!body.more_available;
resolve(body);
});
});
}
|
Get message history for a chat (channel).
@param {int|string} groupId
@param {int|string} chatId
@param {{[maxCount], [lastTime], [lastOrdinal], [startTime], [startOrdinal]}} [options]
@param {function} [callback]
@returns {Promise<{messages: {sender: SteamID, server_timestamp: Date, ordinal: number, message: string, server_message?: {message: EChatRoomServerMessage, string_param?: string, steamid_param?: SteamID}, deleted: boolean}[], more_available: boolean}>}
|
getChatMessageHistory
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
ackFriendMessage(friendSteamId, timestamp) {
this.user._sendUnified('FriendMessages.AckMessage#1', {
steamid_partner: Helpers.steamID(friendSteamId).toString(),
timestamp: convertDateToUnix(timestamp)
});
}
|
Acknowledge (mark as read) a friend message
@param {SteamID|string} friendSteamId - The SteamID of the friend whose message(s) you want to acknowledge
@param {Date|int} timestamp - The timestamp of the newest message you're acknowledging (will ack all older messages)
|
ackFriendMessage
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
ackChatMessage(chatGroupId, chatId, timestamp) {
this.user._sendUnified('ChatRoom.AckChatMessage#1', {
chat_group_id: chatGroupId,
chat_id: chatId,
timestamp: convertDateToUnix(timestamp)
});
}
|
Acknowledge (mark as read) a chat room.
@param {int} chatGroupId
@param {int} chatId
@param {Date|int} timestamp - The timestamp of the newest message you're acknowledging (will ack all older messages)
|
ackChatMessage
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
deleteChatMessages(groupId, chatId, messages, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, true, (resolve, reject) => {
if (!Array.isArray(messages)) {
return reject(new Error('The \'messages\' argument must be an array'));
}
for (let i = 0; i < messages.length; i++) {
if (!messages[i] || typeof messages[i] !== 'object' || (!messages[i].server_timestamp && !messages[i].timestamp)) {
return reject(new Error('The \'messages\' argument is malformed: must be an array of objects with properties {(server_timestamp|timestamp), ordinal}'));
}
}
messages = messages.map((msg) => {
let out = {};
msg.ordinal = msg.ordinal || 0;
if (msg.timestamp && !msg.server_timestamp) {
msg.server_timestamp = msg.timestamp;
}
out.server_timestamp = convertDateToUnix(msg.server_timestamp);
if (msg.ordinal) {
out.ordinal = msg.ordinal;
}
return out;
});
this.user._sendUnified('ChatRoom.DeleteChatMessages#1', {
chat_group_id: groupId,
chat_id: chatId,
messages
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
resolve();
});
});
}
|
Delete one or more messages from a chat channel.
@param {int|string} groupId
@param {int|string} chatId
@param {{server_timestamp, ordinal}[]} messages
@param {function} [callback]
@returns {Promise}
|
deleteChatMessages
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
createChatRoom(groupId, name, options, callback) {
if (typeof options == 'function') {
callback = options;
options = {};
}
options = options || {};
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, true, (resolve, reject) => {
this.user._sendUnified('ChatRoom.CreateChatRoom#1', {
chat_group_id: groupId,
name,
allow_voice: !!options.isVoiceRoom
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
processChatRoomState(body.chat_room, false);
resolve({chat_room: body.chat_room});
});
});
}
|
Create a text/voice chat room in a group, provided you have permissions to do so.
@param {int|string} groupId - The ID of the group in which you want to create the channel
@param {string} name - The name of your new channel
@param {{isVoiceRoom?: boolean}} [options] - Options for your new room
@param {function} [callback]
@returns {Promise<{chat_room: ChatRoomState}>}
|
createChatRoom
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
renameChatRoom(groupId, chatId, newChatRoomName, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, true, (resolve, reject) => {
this.user._sendUnified('ChatRoom.RenameChatRoom#1', {
chat_group_id: groupId,
chat_id: chatId,
name: newChatRoomName
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
resolve();
});
});
}
|
Rename a text/voice chat room in a group, provided you have permissions to do so.
@param {int|string} groupId - The ID of the group in which you want to rename the room
@param {int|string} chatId - The ID of the chat room you want to rename
@param {string} newChatRoomName - The new name for the room
@param {function} [callback]
@returns {Promise}
|
renameChatRoom
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
deleteChatRoom(groupId, chatId, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, true, (resolve, reject) => {
this.user._sendUnified('ChatRoom.DeleteChatRoom#1', {
chat_group_id: groupId,
chat_id: chatId
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
resolve();
});
});
}
|
Delete a text/voice chat room in a group (and all the messages it contains), provided you have permissions to do so.
@param {int|string} groupId - The ID of the group in which you want to delete a room
@param {int|string} chatId - The ID of the room you want to delete
@param {function} [callback]
@returns {Promise}
|
deleteChatRoom
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
getGroupBanList(groupId, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, false, (resolve, reject) => {
this.user._sendUnified('ChatRoom.GetBanList#1', {
chat_group_id: groupId
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
preProcessObject(body);
resolve(body);
});
});
}
|
Get the ban list for a chat room group, provided you have the appropriate permissions.
@param {int|string} groupId
@param {function} [callback]
@returns {Promise<{bans: {steamid: SteamID, steamid_actor: SteamID, time_banned: Date, ban_reason: string}[]}>}
|
getGroupBanList
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
setGroupUserBanState(groupId, userSteamId, banState, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, true, (resolve, reject) => {
this.user._sendUnified('ChatRoom.SetUserBanState#1', {
chat_group_id: groupId,
steamid: Helpers.steamID(userSteamId).toString(),
ban_state: banState
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
// No data in the response
resolve();
});
});
}
|
Ban or unban a user from a chat room group, provided you have the appropriate permissions.
@param {int|string} groupId
@param {string|SteamID} userSteamId
@param {boolean} banState - True to ban, false to unban
@param {function} [callback]
@returns {Promise}
|
setGroupUserBanState
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
setGroupUserRoleState(groupId, userSteamId, roleId, roleState, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, true, (resolve, reject) => {
this.user._sendUnified(roleState ? 'ChatRoom.AddRoleToUser#1' : 'ChatRoom.DeleteRoleFromUser#1', {
chat_group_id: groupId,
role_id: roleId,
steamid: Helpers.steamID(userSteamId).toString()
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
resolve();
});
});
}
|
Add or remove a role to a group user, provided you have the appropriate permissions.
@param {int} groupId
@param {SteamID|string} userSteamId
@param {int} roleId
@param {boolean} roleState
@param {function} [callback]
@returns {Promise}
|
setGroupUserRoleState
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
function processChatRoomSummaryPair(summaryPair, preProcessed) {
if (!preProcessed) {
summaryPair = preProcessObject(summaryPair);
}
summaryPair.group_state = processUserChatGroupState(summaryPair.user_chat_group_state, true);
summaryPair.group_summary = processChatGroupSummary(summaryPair.group_summary, true);
delete summaryPair.user_chat_group_state;
return summaryPair;
}
|
Process a chat room summary pair.
@param {object} summaryPair
@param {boolean} [preProcessed=false]
@returns {{group_state: ChatRoomGroupState, group_summary: ChatRoomGroupSummary}}
|
processChatRoomSummaryPair
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
function processChatGroupSummary(groupSummary, preProcessed) {
if (groupSummary === null) {
return groupSummary;
}
if (!preProcessed) {
groupSummary = preProcessObject(groupSummary);
}
if (groupSummary.top_members) {
groupSummary.top_members = groupSummary.top_members.map(accountid => SteamID.fromIndividualAccountID(accountid));
}
return groupSummary;
}
|
Process a chat group summary.
@param {object} groupSummary
@param {boolean} [preProcessed=false]
@returns {ChatRoomGroupSummary}
|
processChatGroupSummary
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
function processChatGroupState(state, preProcessed) {
if (state === null) {
return state;
}
if (!preProcessed) {
state = preProcessObject(state);
}
state.chat_rooms = (state.chat_rooms || []).map(v => processChatRoomState(v, true));
return state;
}
|
@param {object} state
@param {boolean} [preProcessed=false]
@returns {ChatRoomGroupState}
|
processChatGroupState
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
function processUserChatGroupState(state, preProcessed) {
if (!preProcessed) {
state = preProcessObject(state);
}
state.user_chat_room_state = processUserChatRoomState(state.user_chat_room_state, true);
state.unread_indicator_muted = !!state.unread_indicator_muted;
return state;
}
|
@param {object} state
@param {boolean} [preProcessed=false]
@returns {UserChatRoomGroupState}
|
processUserChatGroupState
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
function processUserChatRoomState(state, preProcessed) {
if (!preProcessed) {
state = preProcessObject(state);
}
state.unread_indicator_muted = !!state.unread_indicator_muted;
return state;
}
|
@param {object} state
@param {boolean} [preProcessed=false]
@returns {UserChatRoomState}
|
processUserChatRoomState
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
function processChatRoomState(state, preProcessed) {
if (!preProcessed) {
state = preProcessObject(state);
}
state.voice_allowed = !!state.voice_allowed;
state.members_in_voice = state.members_in_voice.map(m => SteamID.fromIndividualAccountID(m));
return state;
}
|
@param {object} state
@param {boolean} [preProcessed=false]
@returns {object}
|
processChatRoomState
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
function processChatMentions(mentions) {
if (!mentions) {
return mentions;
}
if (mentions.mention_accountids) {
mentions.mention_steamids = mentions.mention_accountids.map(acctid => SteamID.fromIndividualAccountID(acctid));
delete mentions.mention_accountids;
}
return mentions;
}
|
@param {object} mentions
@returns {{mention_all: boolean, mention_here: boolean, mention_steamids: SteamID[]}}
|
processChatMentions
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
function preProcessObject(obj) {
for (let key in obj) {
if (!Object.hasOwnProperty.call(obj, key)) {
continue;
}
let val = obj[key];
if (key.match(/^steamid_/) && typeof val === 'string' && val != '0') {
obj[key] = new SteamID(val.toString());
} 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);
} else if (Array.isArray(val) && val.every(isDataObject)) {
obj[key] = val.map(v => preProcessObject(v));
}
}
return obj;
}
|
Pre-process a generic chat object.
@param {object} obj
@returns {object}
|
preProcessObject
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
function isDataObject(val) {
return val !== null && typeof val === 'object' && (val.constructor.name == 'Object' || val.constructor.name == '');
}
|
Pre-process a generic chat object.
@param {object} obj
@returns {object}
|
isDataObject
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
function convertDateToUnix(date) {
if (date instanceof Date) {
return Math.floor(date.getTime() / 1000);
} else if (typeof date !== 'number') {
throw new Error('Timestamp must be a Date object or a numeric Unix timestamp');
} else if (date > 1420088400000) {
return Math.floor(date / 1000);
} else {
return date;
}
}
|
Pre-process a generic chat object.
@param {object} obj
@returns {object}
|
convertDateToUnix
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
function parseBbCode(str) {
if (typeof str != 'string') {
// Don't try to process non-string values, e.g. null
return str;
}
// Steam will put a backslash in front of a bracket for a BBCode tag that shouldn't be parsed as BBCode, but our
// parser doesn't ignore those. Let's just replace "\\[" with some string that's very improbable to exist in a Steam
// chat message, then replace it again later.
let replacement = Crypto.randomBytes(32).toString('hex');
str = str.replace(/\\\[/g, replacement);
let parsed = BBCode.parse(str, {
onlyAllowTags: [
'emoticon',
'code',
'pre',
'img',
'url',
'spoiler',
'quote',
'random',
'flip',
'tradeofferlink',
'tradeoffer',
'sticker',
'gameinvite',
'og',
'roomeffect'
]
});
return collapseStrings(parsed.map(processTagNode));
function processTagNode(node) {
if (node.tag == 'url') {
// we only need to post-process attributes in url tags
for (let i in node.attrs) {
if (node.attrs[i] == i) {
// The URL argument gets parsed with the name as its value
node.attrs.url = node.attrs[i];
delete node.attrs[i];
}
}
}
if (node.content) {
node.content = collapseStrings(node.content.map(processTagNode));
}
return node;
}
function collapseStrings(arr) {
// Turn sequences of strings into single strings
let strStart = null;
let newContent = [];
for (let i = 0; i < arr.length; i++) {
if (typeof arr[i] === 'string') {
arr[i] = arr[i].replace(new RegExp(replacement, 'g'), '['); // only put in the bracket without the backslash because this is now "parsed"
if (strStart === null) {
// This is a string item and we haven't found the start of a string yet
strStart = i;
}
}
if (typeof arr[i] !== 'string') {
// This is not a string item
if (strStart !== null) {
// We found the end of a string
newContent.push(arr.slice(strStart, i).join(''));
}
newContent.push(arr[i]); // push this item (probably a TagNode)
strStart = null;
}
}
if (strStart !== null) {
newContent.push(arr.slice(strStart, arr.length).join(''));
}
return newContent;
}
}
|
@param {string} str
@returns {(string|BBCodeNode)[]}
|
parseBbCode
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
function processTagNode(node) {
if (node.tag == 'url') {
// we only need to post-process attributes in url tags
for (let i in node.attrs) {
if (node.attrs[i] == i) {
// The URL argument gets parsed with the name as its value
node.attrs.url = node.attrs[i];
delete node.attrs[i];
}
}
}
if (node.content) {
node.content = collapseStrings(node.content.map(processTagNode));
}
return node;
}
|
@param {string} str
@returns {(string|BBCodeNode)[]}
|
processTagNode
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
function collapseStrings(arr) {
// Turn sequences of strings into single strings
let strStart = null;
let newContent = [];
for (let i = 0; i < arr.length; i++) {
if (typeof arr[i] === 'string') {
arr[i] = arr[i].replace(new RegExp(replacement, 'g'), '['); // only put in the bracket without the backslash because this is now "parsed"
if (strStart === null) {
// This is a string item and we haven't found the start of a string yet
strStart = i;
}
}
if (typeof arr[i] !== 'string') {
// This is not a string item
if (strStart !== null) {
// We found the end of a string
newContent.push(arr.slice(strStart, i).join(''));
}
newContent.push(arr[i]); // push this item (probably a TagNode)
strStart = null;
}
}
if (strStart !== null) {
newContent.push(arr.slice(strStart, arr.length).join(''));
}
return newContent;
}
|
@param {string} str
@returns {(string|BBCodeNode)[]}
|
collapseStrings
|
javascript
|
DoctorMcKay/node-steam-user
|
components/chatroom.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/chatroom.js
|
MIT
|
getAssetClassInfo(language, appid, classes, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, ['descriptions'], callback, (resolve, reject) => {
this._sendUnified('Econ.GetAssetClassInfo#1', {language, appid, classes}, (body) => {
resolve({descriptions: body.descriptions});
});
});
}
|
Get the list of currently-available content servers.
@param {string} language
@param {int} appid
@param {{classid: int, instanceid?: int}[]} classes
@param {function} [callback]
@returns {Promise}
|
getAssetClassInfo
|
javascript
|
DoctorMcKay/node-steam-user
|
components/econ.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/econ.js
|
MIT
|
getTradeURL(callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, (resolve, reject) => {
this._sendUnified('Econ.GetTradeOfferAccessToken#1', {}, (body) => {
resolve({
token: body.trade_offer_access_token,
url: 'https://steamcommunity.com/tradeoffer/new/?partner=' + this.steamID.accountid + '&token=' + body.trade_offer_access_token
});
});
});
}
|
Gets your account's trade URL.
@param {function} [callback]
@returns {Promise}
|
getTradeURL
|
javascript
|
DoctorMcKay/node-steam-user
|
components/econ.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/econ.js
|
MIT
|
changeTradeURL(callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, (resolve, reject) => {
this._sendUnified('Econ.GetTradeOfferAccessToken#1', {generate_new_token: true}, (body) => {
resolve({
token: body.trade_offer_access_token,
url: 'https://steamcommunity.com/tradeoffer/new/?partner=' + this.steamID.accountid + '&token=' + body.trade_offer_access_token
});
});
});
}
|
Makes a new trade URL for your account.
@param {function} [callback]
@returns {Promise}
|
changeTradeURL
|
javascript
|
DoctorMcKay/node-steam-user
|
components/econ.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/econ.js
|
MIT
|
getEmoticonList(callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, (resolve, reject) => {
this._sendUnified('Player.GetEmoticonList#1', {}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
let emoticons = {};
body.emoticons.forEach((emoticon) => {
for (let i in emoticon) {
if (i.match(/^time_/)) {
emoticon[i] = emoticon[i] ? new Date(emoticon[i] * 1000) : null;
} else if (i == 'use_count' && emoticon[i] === null) {
emoticon[i] = 0;
}
}
emoticons[emoticon.name] = emoticon;
});
resolve({emoticons});
});
});
}
|
Gets the list of emoticons your account can use.
@param {function} [callback]
@returns {Promise}
|
getEmoticonList
|
javascript
|
DoctorMcKay/node-steam-user
|
components/econ.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/econ.js
|
MIT
|
getOwnedProfileItems(options, callback) {
if (typeof options == 'function') {
callback = options;
options = {};
}
options = options || {};
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, false, (resolve, reject) => {
this._sendUnified('Player.GetProfileItemsOwned#1', {language: options.language || 'english'}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
for (let i in body) {
if (Array.isArray(body[i])) {
body[i] = body[i].map(processProfileItem);
}
}
resolve(body);
});
});
}
|
Get a listing of profile items you own.
@param {{language?: string}} [options]
@param {function} [callback]
@returns {Promise}
|
getOwnedProfileItems
|
javascript
|
DoctorMcKay/node-steam-user
|
components/econ.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/econ.js
|
MIT
|
getEquippedProfileItems(steamID, options, callback) {
if (typeof options == 'function') {
callback = options;
options = {};
}
options = options || {};
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, false, (resolve, reject) => {
steamID = Helpers.steamID(steamID);
this._sendUnified('Player.GetProfileItemsEquipped#1', {
steamid: steamID.toString(),
language: options.language || 'english'
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
for (let i in body) {
body[i] = processProfileItem(body[i]);
}
resolve(body);
});
});
}
|
Get a user's equipped profile items.
@param {SteamID|string} steamID - Either a SteamID object or a string that can parse into one
@param {{language?: string}} [options]
@param {function} [callback]
@returns {Promise}
|
getEquippedProfileItems
|
javascript
|
DoctorMcKay/node-steam-user
|
components/econ.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/econ.js
|
MIT
|
setProfileBackground(backgroundAssetID, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, true, (resolve, reject) => {
this._sendUnified('Player.SetProfileBackground#1', {communityitemid: backgroundAssetID}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
resolve();
});
});
}
|
Change your current profile background.
@param {number|string} backgroundAssetID
@param {function} [callback]
|
setProfileBackground
|
javascript
|
DoctorMcKay/node-steam-user
|
components/econ.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/econ.js
|
MIT
|
function processProfileItem(item) {
if (!Object.keys(item).some(k => item[k] !== null)) {
return null;
}
['image_large', 'image_small', 'movie_webm', 'movie_mp4'].forEach((key) => {
if (item[key]) {
item[key] = 'https://steamcdn-a.akamaihd.net/steamcommunity/public/images/' + item[key];
}
});
return item;
}
|
Change your current profile background.
@param {number|string} backgroundAssetID
@param {function} [callback]
|
processProfileItem
|
javascript
|
DoctorMcKay/node-steam-user
|
components/econ.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/econ.js
|
MIT
|
addAuthorizedBorrowers(borrowersSteamID, callback) {
return StdLib.Promises.timeoutCallbackPromise(5000, null, callback, true, (resolve, reject) => {
if (!Array.isArray(borrowersSteamID)) {
borrowersSteamID = [borrowersSteamID];
}
this._sendUnified('DeviceAuth.AddAuthorizedBorrowers#1', {
steamid: this.steamID.getSteamID64(),
steamid_borrower: borrowersSteamID.map(sid => Helpers.steamID(sid).getSteamID64())
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
return err ? reject(err) : resolve();
});
});
}
|
Add new borrowers.
@param {SteamID[]|string[]|SteamID|string} borrowersSteamID
@param {function} [callback]
@returns {Promise}
|
addAuthorizedBorrowers
|
javascript
|
DoctorMcKay/node-steam-user
|
components/familysharing.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/familysharing.js
|
MIT
|
removeAuthorizedBorrowers(borrowersSteamID, callback) {
return StdLib.Promises.timeoutCallbackPromise(5000, null, callback, true, (resolve, reject) => {
if (!Array.isArray(borrowersSteamID)) {
return reject(new Error('The \'borrowersSteamID\' argument must be an array'));
}
this._sendUnified('DeviceAuth.RemoveAuthorizedBorrowers#1', {
steamid: this.steamID.getSteamID64(),
steamid_borrower: borrowersSteamID.map(sid => Helpers.steamID(sid).getSteamID64())
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
return err ? reject(err) : resolve();
});
});
}
|
Remove borrowers.
@param {SteamID[]|string[]} borrowersSteamID
@param {function} [callback]
@returns {Promise}
|
removeAuthorizedBorrowers
|
javascript
|
DoctorMcKay/node-steam-user
|
components/familysharing.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/familysharing.js
|
MIT
|
getAuthorizedBorrowers(options, callback) {
return StdLib.Promises.timeoutCallbackPromise(5000, null, callback, (resolve, reject) => {
if (typeof options == 'function') {
callback = options;
}
options = options || {};
this._sendUnified('DeviceAuth.GetAuthorizedBorrowers#1', {
steamid: this.steamID.getSteamID64(),
include_canceled: options.includeCanceled || false,
include_pending: options.includePending || false
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
return err ? reject(err) : resolve({
borrowers: body.borrowers.map((borrower) => {
return {
steamid: new SteamID(borrower.steamid),
isPending: borrower.is_pending,
isCanceled: borrower.is_canceled,
timeCreated: new Date(borrower.time_created * 1000)
};
})
});
});
});
}
|
Retrieve a list of Steam accounts authorized to borrow your library.
@param {{includeCanceled?: boolean, includePending?: boolean}} [options]
@param {function} [callback]
@returns {Promise}
|
getAuthorizedBorrowers
|
javascript
|
DoctorMcKay/node-steam-user
|
components/familysharing.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/familysharing.js
|
MIT
|
getAuthorizedSharingDevices(options, callback) {
if (typeof options == 'function') {
callback = options;
options = {};
}
options = options || {};
return StdLib.Promises.timeoutCallbackPromise(5000, null, callback, (resolve, reject) => {
this._sendUnified('DeviceAuth.GetOwnAuthorizedDevices#1', {
steamid: this.steamID.getSteamID64(),
includeCancelled: !!options.includeCanceled
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
return err ? reject(err) : resolve({
devices: body.devices.map((device) => {
return {
deviceToken: device.auth_device_token,
deviceName: device.device_name,
isPending: device.is_pending,
isCanceled: device.is_canceled,
isLimited: device.is_limited,
lastTimeUsed: device.last_time_used ? new Date(device.last_time_used * 1000) : null,
lastBorrower: device.last_borrower_id && device.last_borrower_id != '76561197960265728' ? new SteamID(device.last_borrower_id) : null,
lastAppPlayed: device.last_app_played || null
};
})
});
});
});
}
|
Get a list of devices we have authorized.
@param {{includeCanceled?: boolean}} [options]
@param {function} [callback]
@returns {Promise}
|
getAuthorizedSharingDevices
|
javascript
|
DoctorMcKay/node-steam-user
|
components/familysharing.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/familysharing.js
|
MIT
|
authorizeLocalSharingDevice(deviceName, callback) {
return StdLib.Promises.timeoutCallbackPromise(5000, null, callback, true, (resolve, reject) => {
if (!deviceName) {
return reject(new Error('The \'deviceName\' argument is required.'));
}
this._send(EMsg.ClientAuthorizeLocalDeviceRequest, {
device_description: deviceName,
owner_account_id: this.steamID.accountid
}, (body) => {
let err = Helpers.eresultError(body.eresult);
return err ? reject(err) : resolve({deviceToken: body.authed_device_token});
});
});
}
|
Authorize local device for library sharing.
@param {string} deviceName
@param {function} [callback]
@returns {Promise}
|
authorizeLocalSharingDevice
|
javascript
|
DoctorMcKay/node-steam-user
|
components/familysharing.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/familysharing.js
|
MIT
|
deauthorizeSharingDevice(deviceToken, callback) {
return StdLib.Promises.timeoutCallbackPromise(5000, null, callback, true, (resolve, reject) => {
if (typeof deviceToken == 'object' && typeof deviceToken.deviceToken == 'string') {
deviceToken = deviceToken.deviceToken;
}
if (typeof deviceToken != 'string') {
return reject(new Error('The \'deviceToken\' parameter is required.'));
}
this._send(EMsg.ClientDeauthorizeDeviceRequest, {
deauthorization_account_id: this.steamID.accountid,
deauthorization_device_token: deviceToken
}, (body) => {
let err = Helpers.eresultError(body.eresult);
return err ? reject(err) : resolve();
});
});
}
|
Deauthorize a device from family sharing.
@param {string|{deviceToken: string}} deviceToken
@param {function} [callback]
|
deauthorizeSharingDevice
|
javascript
|
DoctorMcKay/node-steam-user
|
components/familysharing.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/familysharing.js
|
MIT
|
setPersona(state, name) {
this._send(EMsg.ClientChangeStatus, {
persona_state: state,
player_name: name
});
}
|
Set your persona online state and optionally name.
@memberOf SteamUser
@param {EPersonaState} state - Your new online state
@param {string} [name] - Optional. Set a new profile name.
|
setPersona
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
setUIMode(mode) {
this._send(EMsg.ClientCurrentUIMode, {uimode: mode});
}
|
Set your current UI mode (displays next to your Steam online status in friends)
@param {EClientUIMode} mode - Your new UI mode
|
setUIMode
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
addFriend(steamID, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, ['personaName'], callback, true, (resolve, reject) => {
this._send(EMsg.ClientAddFriend, {steamid_to_add: Helpers.steamID(steamID).getSteamID64()}, (body) => {
if (body.eresult != EResult.OK) {
return reject(Helpers.eresultError(body.eresult));
}
resolve({
personaName: body.persona_name_added
});
});
});
}
|
Send (or accept) a friend invitiation.
@param {(SteamID|string)} steamID - Either a SteamID object of the user to add, or a string which can parse into one.
@param {function} [callback] - Optional. Called with `err` and `name` parameters on completion.
|
addFriend
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
removeFriend(steamID) {
if (typeof steamID === 'string') {
steamID = new SteamID(steamID);
}
this._send(EMsg.ClientRemoveFriend, {friendid: steamID.getSteamID64()});
}
|
Remove a friend from your friends list (or decline an invitiation)
@param {(SteamID|string)} steamID - Either a SteamID object of the user to remove, or a string which can parse into one.
|
removeFriend
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
blockUser(steamID, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, true, (resolve, reject) => {
if (typeof steamID === 'string') {
steamID = new SteamID(steamID);
}
let buffer = ByteBuffer.allocate(17, ByteBuffer.LITTLE_ENDIAN);
buffer.writeUint64(this.steamID.getSteamID64());
buffer.writeUint64(steamID.getSteamID64());
buffer.writeUint8(1);
this._send(EMsg.ClientSetIgnoreFriend, buffer.flip(), (body) => {
body.readUint64(); // unknown
let err = Helpers.eresultError(body.readUint32());
return err ? reject(err) : resolve();
});
});
}
|
Block all communication with a user.
@param {(SteamID|string)} steamID - Either a SteamID object of the user to block, or a string which can parse into one.
@param {SteamUser~genericEResultCallback} [callback] - Optional. Called with an `err` parameter on completion.
@return {Promise}
|
blockUser
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
unblockUser(steamID, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, true, (resolve, reject) => {
if (typeof steamID === 'string') {
steamID = new SteamID(steamID);
}
let buffer = ByteBuffer.allocate(17, ByteBuffer.LITTLE_ENDIAN);
buffer.writeUint64(this.steamID.getSteamID64());
buffer.writeUint64(steamID.getSteamID64());
buffer.writeUint8(0);
this._send(EMsg.ClientSetIgnoreFriend, buffer.flip(), (body) => {
body.readUint64(); // unknown
let err = Helpers.eresultError(body.readUint32());
return err ? reject(err) : resolve();
});
});
}
|
Unblock all communication with a user.
@param {(SteamID|string)} steamID - Either a SteamID object of the user to unblock, or a string which can parse into one.
@param {SteamUser~genericEResultCallback} [callback] - Optional. Called with an `err` parameter on completion.
@return {Promise}
|
unblockUser
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
listQuickInviteLinks(callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, false, (resolve, reject) => {
this._sendUnified('UserAccount.GetFriendInviteTokens#1', {}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
body.tokens.forEach((token) => processInviteToken(this.steamID, token));
resolve(body);
});
});
}
|
Get a list of friend quick-invite links for your account.
@param {function} [callback]
@returns {Promise}
|
listQuickInviteLinks
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
revokeQuickInviteLink(linkOrToken, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, true, (resolve, reject) => {
if (linkOrToken.includes('/')) {
// It's a link
let parts = linkOrToken.split('/');
parts = parts.filter(part => !!part); // remove any trailing slash
linkOrToken = parts[parts.length - 1];
}
this._sendUnified('UserAccount.RevokeFriendInviteToken#1', {
invite_token: linkOrToken
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
// No data
resolve();
});
});
}
|
Revoke an active quick-invite link.
@param {string} linkOrToken - Either the full link, or just the token from the link
@param {function} [callback]
@returns {Promise}
|
revokeQuickInviteLink
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
getQuickInviteLinkSteamID(link) {
let match = link.match(/^https?:\/\/s\.team\/p\/([^/]+)\/([^/]+)/);
if (!match) {
return null;
}
return Helpers.parseFriendCode(match[1]);
}
|
Get the SteamID to whom a quick-invite link belongs.
@param {string} link
@returns {SteamID|null} - null if the link isn't well-formed
|
getQuickInviteLinkSteamID
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
checkQuickInviteLinkValidity(link, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, false, (resolve, reject) => {
let match = link.match(/^https?:\/\/s\.team\/p\/([^/]+)\/([^/]+)/);
if (!match) {
return reject(new Error('Malformed quick-invite link'));
}
let steamID = Helpers.parseFriendCode(match[1]);
let token = match[2];
this._sendUnified('UserAccount.ViewFriendInviteToken#1', {
steamid: steamID.toString(),
invite_token: token
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
body.steamid = Helpers.steamID(body.steamid);
body.invite_duration = body.invite_duration ? parseInt(body.invite_duration, 10) : null;
resolve(body);
});
});
}
|
Check whether a given quick-invite link is valid.
@param {string} link
@param {function} [callback]
@returns {Promise<{valid: boolean, steamid: SteamID, invite_duration?: int}>}
|
checkQuickInviteLinkValidity
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
redeemQuickInviteLink(link, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, null, callback, true, (resolve, reject) => {
let match = link.match(/^https?:\/\/s\.team\/p\/([^/]+)\/([^/]+)/);
if (!match) {
return reject(new Error('Malformed quick-invite link'));
}
let steamID = Helpers.parseFriendCode(match[1]);
let token = match[2];
this._sendUnified('UserAccount.RedeemFriendInviteToken#1', {
steamid: steamID.toString(),
invite_token: token
}, (body, hdr) => {
let err = Helpers.eresultError(hdr.proto);
if (err) {
return reject(err);
}
// No response data
resolve();
});
});
}
|
Redeem a quick-invite link and add the sender to your friends list.
@param {string} link
@param {function} [callback]
@returns {Promise}
|
redeemQuickInviteLink
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
getPersonas(steamids, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, ['personas'], callback, true, (resolve, reject) => {
const Flags = EClientPersonaStateFlag;
let flags = Flags.Status | Flags.PlayerName | Flags.QueryPort | Flags.SourceID | Flags.Presence |
Flags.Metadata | Flags.LastSeen | Flags.UserClanRank | Flags.GameExtraInfo | Flags.GameDataBlob |
Flags.ClanData | Flags.Facebook | Flags.RichPresence | Flags.Broadcast | Flags.Watching;
let ids = steamids.map((id) => {
if (typeof id === 'string') {
return (new SteamID(id)).getSteamID64();
}
return id.toString();
});
this._send(EMsg.ClientRequestFriendData, {
friends: ids,
persona_state_requested: flags
});
// Handle response
let output = {};
ids.forEach((id) => {
Helpers.onceTimeout(10000, this, 'user#' + id, receive);
});
function receive(err, sid, user) {
if (err) {
return reject(err);
}
let sid64 = sid.getSteamID64();
output[sid64] = user;
let index = ids.indexOf(sid64);
if (index != -1) {
ids.splice(index, 1);
}
if (ids.length === 0) {
resolve({personas: output});
}
}
});
}
|
Requests information about one or more user profiles.
@param {(SteamID[]|string[])} steamids - An array of SteamID objects or strings which can parse into them.
@param {function} [callback] - Optional. Called with `err`, and an object whose keys are 64-bit SteamIDs as strings, and whose values are persona objects.
@return {Promise}
|
getPersonas
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
function receive(err, sid, user) {
if (err) {
return reject(err);
}
let sid64 = sid.getSteamID64();
output[sid64] = user;
let index = ids.indexOf(sid64);
if (index != -1) {
ids.splice(index, 1);
}
if (ids.length === 0) {
resolve({personas: output});
}
}
|
Requests information about one or more user profiles.
@param {(SteamID[]|string[])} steamids - An array of SteamID objects or strings which can parse into them.
@param {function} [callback] - Optional. Called with `err`, and an object whose keys are 64-bit SteamIDs as strings, and whose values are persona objects.
@return {Promise}
|
receive
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
getSteamLevels(steamids, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, ['users'], callback, (resolve, reject) => {
let accountids = steamids.map((steamID) => {
if (typeof steamID === 'string') {
return (new SteamID(steamID)).accountid;
} else {
return steamID.accountid;
}
});
this._send(EMsg.ClientFSGetFriendsSteamLevels, {accountids}, (body) => {
let output = {};
let sid = new SteamID();
sid.universe = SteamID.Universe.PUBLIC;
sid.type = SteamID.Type.INDIVIDUAL;
sid.instance = SteamID.Instance.DESKTOP;
(body.friends || []).forEach((user) => {
sid.accountid = user.accountid;
output[sid.getSteamID64()] = user.level;
});
resolve({users: output});
});
});
}
|
Gets the Steam Level of one or more Steam users.
@param {(SteamID[]|string[])} steamids - An array of SteamID objects, or strings which can parse into one.
@param {function} [callback] - Called on completion with `err`, and an object whose keys are 64-bit SteamIDs as strings, and whose values are Steam Level numbers.
@return {Promise}
|
getSteamLevels
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
getGameBadgeLevel(appid, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, ['steamLevel', 'regularBadgeLevel', 'foilBadgeLevel'], callback, (resolve, reject) => {
this._sendUnified('Player.GetGameBadgeLevels#1', {appid}, (body) => {
let regular = 0;
let foil = 0;
(body.badges || []).forEach((badge) => {
if (badge.series != 1) {
return;
}
if (badge.border_color == 0) {
regular = badge.level;
} else if (badge.border_color == 1) {
foil = badge.level;
}
});
resolve({
// these two level properties exist because we were using playerLevel while the docs said steamLevel
steamLevel: body.player_level,
playerLevel: body.player_level,
regularBadgeLevel: regular,
foilBadgeLevel: foil
});
});
});
}
|
Get the level of your game badge (and also your Steam level).
@param {int} appid - AppID of game in question
@param {function} [callback]
@returns {Promise}
|
getGameBadgeLevel
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
inviteToGroup(userSteamID, groupSteamID) {
let buffer = ByteBuffer.allocate(17, ByteBuffer.LITTLE_ENDIAN);
buffer.writeUint64(Helpers.steamID(userSteamID).toString());
buffer.writeUint64(Helpers.steamID(groupSteamID).toString());
buffer.writeUint8(1); // unknown
this._send(EMsg.ClientInviteUserToClan, buffer.flip());
}
|
Invites a user to a Steam group. Only send group invites in response to a user's request; sending automated group
invites is a violation of the Steam Subscriber Agreement and can get you banned.
@param {(SteamID|string)} userSteamID - The SteamID of the user you're inviting as a SteamID object, or a string that can parse into one
@param {(SteamID|string)} groupSteamID - The SteamID of the group you're inviting the user to as a SteamID object, or a string that can parse into one
|
inviteToGroup
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
respondToGroupInvite(groupSteamID, accept) {
let buffer = ByteBuffer.allocate(9, ByteBuffer.LITTLE_ENDIAN);
buffer.writeUint64(Helpers.steamID(groupSteamID).toString());
buffer.writeUint8(accept ? 1 : 0);
this._send(EMsg.ClientAcknowledgeClanInvite, buffer.flip());
}
|
Respond to an incoming group invite.
@param {(SteamID|string)} groupSteamID - The group you were invited to, as a SteamID object or a string which can parse into one
@param {boolean} accept - true to join the group, false to ignore invitation
|
respondToGroupInvite
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
createFriendsGroup(groupName, callback) {
return StdLib.Promises.timeoutCallbackPromise(10000, ['groupID'], callback, true, (resolve, reject) => {
this._send(EMsg.AMClientCreateFriendsGroup, {
groupname: groupName
}, (body) => {
if (body.eresult != EResult.OK) {
return reject(Helpers.eresultError(body.eresult));
}
this.myFriendGroups[body.groupid] = {
name: groupName,
members: []
};
return resolve({groupID: body.groupid});
});
});
}
|
Creates a friends group (or tag)
@param {string} groupName - The name to create the friends group with
@param {function} [callback]
@return {Promise}
|
createFriendsGroup
|
javascript
|
DoctorMcKay/node-steam-user
|
components/friends.js
|
https://github.com/DoctorMcKay/node-steam-user/blob/master/components/friends.js
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.