mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-02-07 22:59:35 +08:00
commit
1efac6bc70
@ -114,6 +114,14 @@ CSteamGroup.prototype.getHistory = function(page, callback) {
|
|||||||
this._community.getGroupHistory(this.steamID, page, callback);
|
this._community.getGroupHistory(this.steamID, page, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
CSteamGroup.prototype.getAllComments = function(from, count, callback) {
|
||||||
|
this._community.getAllGroupComments(this.steamID, from, count, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
CSteamGroup.prototype.deleteComment = function(cid, callback) {
|
||||||
|
this._community.deleteGroupComment(this.steamID, cid, callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get requests to join this restricted group.
|
* Get requests to join this restricted group.
|
||||||
* @param {function} callback - First argument is null/Error, second is array of SteamID objects
|
* @param {function} callback - First argument is null/Error, second is array of SteamID objects
|
||||||
|
@ -2,6 +2,7 @@ var SteamCommunity = require('../index.js');
|
|||||||
var SteamID = require('steamid');
|
var SteamID = require('steamid');
|
||||||
var xml2js = require('xml2js');
|
var xml2js = require('xml2js');
|
||||||
var Cheerio = require('cheerio');
|
var Cheerio = require('cheerio');
|
||||||
|
var Helpers = require('./helpers.js');
|
||||||
var EResult = SteamCommunity.EResult;
|
var EResult = SteamCommunity.EResult;
|
||||||
|
|
||||||
SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link, addresses, addressIdx) {
|
SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link, addresses, addressIdx) {
|
||||||
@ -519,6 +520,70 @@ SteamCommunity.prototype.getGroupHistory = function(gid, page, callback) {
|
|||||||
}, "steamcommunity");
|
}, "steamcommunity");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.getAllGroupComments = function(gid, from, count, callback) {
|
||||||
|
var options = {
|
||||||
|
uri: "http://steamcommunity.com/comment/Clan/render/" + gid.getSteamID64() + "/-1/",
|
||||||
|
form: {
|
||||||
|
start: from,
|
||||||
|
count: count
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
this.httpRequestPost(options, function(err, response, body) {
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var comments = [];
|
||||||
|
|
||||||
|
var $ = Cheerio.load(JSON.parse(body).comments_html);
|
||||||
|
|
||||||
|
$(".commentthread_comment_content").each(function () {
|
||||||
|
var comment = {};
|
||||||
|
var cachedSelector;
|
||||||
|
|
||||||
|
var $selector = $(this).find(".commentthread_author_link");
|
||||||
|
comment.authorName = $($selector).find("bdi").text();
|
||||||
|
comment.authorId = $($selector).attr("href").replace(/http:\/\/steamcommunity.com\/(id|profiles)\//, "");
|
||||||
|
comment.date = Helpers.decodeSteamTime($(this).find(".commentthread_comment_timestamp").text().trim());
|
||||||
|
|
||||||
|
$selector = $(this).find(".commentthread_comment_text");
|
||||||
|
comment.commentId = $($selector).attr("id").replace("comment_content_", "");
|
||||||
|
comment.text = $($selector).html().trim();
|
||||||
|
|
||||||
|
comments.push(comment);
|
||||||
|
});
|
||||||
|
|
||||||
|
callback(null, comments);
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
|
SteamCommunity.prototype.deleteGroupComment = function(gid, cid, callback) {
|
||||||
|
|
||||||
|
if(typeof cid !== 'string') {
|
||||||
|
cid = cid.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
uri: "http://steamcommunity.com/comment/Clan/delete/" + gid.getSteamID64() + "/-1/",
|
||||||
|
form: {
|
||||||
|
sessionid: this.getSessionID(),
|
||||||
|
gidcomment: cid
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
this.httpRequestPost(options, function(err, response, body) {
|
||||||
|
if(!callback) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(err || null);
|
||||||
|
}, "steamcommunity");
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get requests to join a restricted group.
|
* Get requests to join a restricted group.
|
||||||
* @param {SteamID|string} gid - The SteamID of the group you want to manage
|
* @param {SteamID|string} gid - The SteamID of the group you want to manage
|
||||||
|
@ -13,11 +13,26 @@ exports.isSteamID = function(input) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.decodeSteamTime = function(time) {
|
exports.decodeSteamTime = function(time) {
|
||||||
|
var date = new Date();
|
||||||
|
|
||||||
|
if (time.includes("@")) {
|
||||||
var parts = time.split('@');
|
var parts = time.split('@');
|
||||||
if (!parts[0].match(/,/)) {
|
if (!parts[0].includes(",")) {
|
||||||
// no year, assume current year
|
// no year, assume current year
|
||||||
parts[0] += ", " + (new Date()).getFullYear();
|
parts[0] += ", " + date.getFullYear();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Date(parts.join('@').replace(/(am|pm)/, ' $1') + " UTC"); // add a space so JS can decode it
|
date = new Date(parts.join('@').replace(/(am|pm)/, ' $1') + " UTC"); // add a space so JS can decode it
|
||||||
|
} else {
|
||||||
|
// Relative date
|
||||||
|
var amount = time.replace(/(\d) (minutes|hour|hours) ago/, "$1");
|
||||||
|
|
||||||
|
if(time.includes("minutes")) {
|
||||||
|
date.setMinutes(date.getMinutes() - amount);
|
||||||
|
} else if(time.match(/hour|hours/)) {
|
||||||
|
date.setHours(date.getHours() - amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return date;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user