mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-02-06 07:49:10 +08:00
Updated postUserComment and added deleteUserComment
https://github.com/DoctorMcKay/node-steamcommunity/issues/219
This commit is contained in:
parent
224b7b85e0
commit
f2be027a63
@ -134,7 +134,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
|
||||||
@ -149,9 +149,50 @@ 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 {
|
} else {
|
||||||
callback(new Error("Unknown error"));
|
callback(new Error("Unknown error"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user