mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2026-08-22 14:43:29 +08:00
Merge branch 'master' into feature-get-friends-list
This commit is contained in:
@@ -154,6 +154,14 @@ CSteamUser.prototype.comment = function(message, callback) {
|
|||||||
this._community.postUserComment(this.steamID, message, callback);
|
this._community.postUserComment(this.steamID, message, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CSteamUser.prototype.deleteComment = function(commentID, callback) {
|
||||||
|
this._community.deleteUserComment(this.steamID, commentID, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
CSteamUser.prototype.getComments = function(options, callback) {
|
||||||
|
this._community.getUserComments(this.steamID, options, callback);
|
||||||
|
};
|
||||||
|
|
||||||
CSteamUser.prototype.inviteToGroup = function(groupID, callback) {
|
CSteamUser.prototype.inviteToGroup = function(groupID, callback) {
|
||||||
this._community.inviteUserToGroup(this.steamID, groupID, callback);
|
this._community.inviteUserToGroup(this.steamID, groupID, callback);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ SteamCommunity.prototype.postUserComment = function(userID, message, callback) {
|
|||||||
"uri": "https://steamcommunity.com/comment/Profile/post/" + userID.toString() + "/-1",
|
"uri": "https://steamcommunity.com/comment/Profile/post/" + userID.toString() + "/-1",
|
||||||
"form": {
|
"form": {
|
||||||
"comment": message,
|
"comment": message,
|
||||||
"count": 6,
|
"count": 1,
|
||||||
"sessionid": this.getSessionID()
|
"sessionid": this.getSessionID()
|
||||||
},
|
},
|
||||||
"json": true
|
"json": true
|
||||||
@@ -151,9 +151,109 @@ SteamCommunity.prototype.postUserComment = function(userID, message, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(body.success) {
|
if(body.success) {
|
||||||
|
const $ = Cheerio.load(body.comments_html);
|
||||||
|
const commentID = $('.commentthread_comment').attr('id').split('_')[1];
|
||||||
|
|
||||||
|
callback(null, commentID);
|
||||||
|
} else if(body.error) {
|
||||||
|
callback(new Error(body.error));
|
||||||
|
} else {
|
||||||
|
callback(new Error("Unknown error"));
|
||||||
|
}
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.deleteUserComment = function(userID, commentID, callback) {
|
||||||
|
if(typeof userID === 'string') {
|
||||||
|
userID = new SteamID(userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
this.httpRequestPost({
|
||||||
|
"uri": "https://steamcommunity.com/comment/Profile/delete/" + userID.toString() + "/-1",
|
||||||
|
"form": {
|
||||||
|
"gidcomment": commentID,
|
||||||
|
"start": 0,
|
||||||
|
"count": 1,
|
||||||
|
"sessionid": this.getSessionID(),
|
||||||
|
"feature2": -1
|
||||||
|
},
|
||||||
|
"json": true
|
||||||
|
}, function(err, response, body) {
|
||||||
|
if(!callback) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(body.success && !body.comments_html.includes(commentID)) {
|
||||||
callback(null);
|
callback(null);
|
||||||
} else if(body.error) {
|
} else if(body.error) {
|
||||||
callback(new Error(body.error));
|
callback(new Error(body.error));
|
||||||
|
} else if(body.comments_html.includes(commentID)) {
|
||||||
|
callback(new Error("Failed to delete comment"));
|
||||||
|
} else {
|
||||||
|
callback(new Error("Unknown error"));
|
||||||
|
}
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.getUserComments = function(userID, options, callback) {
|
||||||
|
if(typeof userID === 'string') {
|
||||||
|
userID = new SteamID(userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof options === 'function') {
|
||||||
|
callback = options;
|
||||||
|
options = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
var form = Object.assign({
|
||||||
|
"start": 0,
|
||||||
|
"count": 0,
|
||||||
|
"feature2": -1,
|
||||||
|
"sessionid": this.getSessionID()
|
||||||
|
}, options);
|
||||||
|
|
||||||
|
this.httpRequestPost({
|
||||||
|
"uri": "https://steamcommunity.com/comment/Profile/render/" + userID.toString() + "/-1",
|
||||||
|
"form": form,
|
||||||
|
"json": true
|
||||||
|
}, function(err, response, body) {
|
||||||
|
if(!callback) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(body.success) {
|
||||||
|
const $ = Cheerio.load(body.comments_html);
|
||||||
|
const comments = $(".commentthread_comment.responsive_body_text[id]").map((i, elem) => {
|
||||||
|
var $elem = $(elem),
|
||||||
|
$commentContent = $elem.find(".commentthread_comment_text");
|
||||||
|
return {
|
||||||
|
id: $elem.attr("id").split("_")[1],
|
||||||
|
author: {
|
||||||
|
id: new SteamID("[U:1:" + $elem.find("[data-miniprofile]").data("miniprofile") + "]"),
|
||||||
|
name: $elem.find("bdi").text(),
|
||||||
|
avatar: $elem.find(".playerAvatar img[src]").attr("src"),
|
||||||
|
state: $elem.find(".playerAvatar").attr("class").split(" ").pop()
|
||||||
|
},
|
||||||
|
date: new Date($elem.find(".commentthread_comment_timestamp").data("timestamp") * 1000),
|
||||||
|
text: $commentContent.text(),
|
||||||
|
html: $commentContent.html()
|
||||||
|
}
|
||||||
|
}).get();
|
||||||
|
|
||||||
|
callback(null, comments, body.total_count);
|
||||||
|
} else if(body.error) {
|
||||||
|
callback(new Error(body.error));
|
||||||
} else {
|
} else {
|
||||||
callback(new Error("Unknown error"));
|
callback(new Error("Unknown error"));
|
||||||
}
|
}
|
||||||
|
|||||||
4
index.js
4
index.js
@@ -304,8 +304,8 @@ SteamCommunity.prototype.setCookies = function(cookies) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.getSessionID = function() {
|
SteamCommunity.prototype.getSessionID = function(host = "http://steamcommunity.com") {
|
||||||
var cookies = this._jar.getCookieString("http://steamcommunity.com").split(';');
|
var cookies = this._jar.getCookieString(host).split(';');
|
||||||
for(var i = 0; i < cookies.length; i++) {
|
for(var i = 0; i < cookies.length; i++) {
|
||||||
var match = cookies[i].trim().match(/([^=]+)=(.+)/);
|
var match = cookies[i].trim().match(/([^=]+)=(.+)/);
|
||||||
if(match[1] == 'sessionid') {
|
if(match[1] == 'sessionid') {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ module.exports = {
|
|||||||
"Snooze": 4,
|
"Snooze": 4,
|
||||||
"LookingToTrade": 5,
|
"LookingToTrade": 5,
|
||||||
"LookingToPlay": 6,
|
"LookingToPlay": 6,
|
||||||
"Max": 7,
|
"Invisible": 7,
|
||||||
|
|
||||||
// Value-to-name mapping for convenience
|
// Value-to-name mapping for convenience
|
||||||
"0": "Offline",
|
"0": "Offline",
|
||||||
@@ -19,5 +19,5 @@ module.exports = {
|
|||||||
"4": "Snooze",
|
"4": "Snooze",
|
||||||
"5": "LookingToTrade",
|
"5": "LookingToTrade",
|
||||||
"6": "LookingToPlay",
|
"6": "LookingToPlay",
|
||||||
"7": "Max",
|
"7": "Invisible",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
"HasRichPresence": 1,
|
"HasRichPresence": 1,
|
||||||
"InJoinableGame": 2,
|
"InJoinableGame": 2,
|
||||||
"Golden": 4, // removed "no longer has any effect"
|
"Golden": 4,
|
||||||
|
"RemotePlayTogether": 8,
|
||||||
"OnlineUsingWeb": 256, // removed "renamed to ClientTypeWeb"
|
"OnlineUsingWeb": 256, // removed "renamed to ClientTypeWeb"
|
||||||
"ClientTypeWeb": 256,
|
"ClientTypeWeb": 256,
|
||||||
"OnlineUsingMobile": 512, // removed "renamed to ClientTypeMobile"
|
"OnlineUsingMobile": 512, // removed "renamed to ClientTypeMobile"
|
||||||
@@ -14,14 +15,18 @@ module.exports = {
|
|||||||
"OnlineUsingVR": 2048, // removed "renamed to ClientTypeVR"
|
"OnlineUsingVR": 2048, // removed "renamed to ClientTypeVR"
|
||||||
"ClientTypeVR": 2048,
|
"ClientTypeVR": 2048,
|
||||||
"LaunchTypeGamepad": 4096,
|
"LaunchTypeGamepad": 4096,
|
||||||
|
"LaunchTypeCompatTool": 8192,
|
||||||
|
|
||||||
// Value-to-name mapping for convenience
|
// Value-to-name mapping for convenience
|
||||||
"1": "HasRichPresence",
|
"1": "HasRichPresence",
|
||||||
"2": "InJoinableGame",
|
"2": "InJoinableGame",
|
||||||
"4": "Golden",
|
"4": "Golden",
|
||||||
|
"8": "RemotePlayTogether",
|
||||||
"256": "ClientTypeWeb",
|
"256": "ClientTypeWeb",
|
||||||
"512": "ClientTypeMobile",
|
"512": "ClientTypeMobile",
|
||||||
"1024": "ClientTypeTenfoot",
|
"1024": "ClientTypeTenfoot",
|
||||||
"2048": "ClientTypeVR",
|
"2048": "ClientTypeVR",
|
||||||
"4096": "LaunchTypeGamepad",
|
"4096": "LaunchTypeGamepad",
|
||||||
|
"8192": "LaunchTypeCompatTool",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,13 @@ module.exports = {
|
|||||||
"WGNetworkSendExceeded": 110,
|
"WGNetworkSendExceeded": 110,
|
||||||
"AccountNotFriends": 111,
|
"AccountNotFriends": 111,
|
||||||
"LimitedUserAccount": 112,
|
"LimitedUserAccount": 112,
|
||||||
|
"CantRemoveItem": 113,
|
||||||
|
"AccountHasBeenDeleted": 114,
|
||||||
|
"AccountHasAnExistingUserCancelledLicense": 115,
|
||||||
|
"DeniedDueToCommunityCooldown": 116,
|
||||||
|
"NoLauncherSpecified": 117,
|
||||||
|
"MustAgreeToSSA": 118,
|
||||||
|
"ClientNoLongerSupported": 119,
|
||||||
|
|
||||||
// Value-to-name mapping for convenience
|
// Value-to-name mapping for convenience
|
||||||
"0": "Invalid",
|
"0": "Invalid",
|
||||||
@@ -237,4 +244,11 @@ module.exports = {
|
|||||||
"110": "WGNetworkSendExceeded",
|
"110": "WGNetworkSendExceeded",
|
||||||
"111": "AccountNotFriends",
|
"111": "AccountNotFriends",
|
||||||
"112": "LimitedUserAccount",
|
"112": "LimitedUserAccount",
|
||||||
|
"113": "CantRemoveItem",
|
||||||
|
"114": "AccountHasBeenDeleted",
|
||||||
|
"115": "AccountHasAnExistingUserCancelledLicense",
|
||||||
|
"116": "DeniedDueToCommunityCooldown",
|
||||||
|
"117": "NoLauncherSpecified",
|
||||||
|
"118": "MustAgreeToSSA",
|
||||||
|
"119": "ClientNoLongerSupported",
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user