mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-03-23 21:50:10 +08:00
Added editing events to CSteamGroup
This commit is contained in:
parent
38e3eefb33
commit
c970eee9d3
@ -7,24 +7,24 @@ SteamCommunity.prototype.getSteamGroup = function(id, callback) {
|
||||
if(typeof id !== 'string' && !Helpers.isSteamID(id)) {
|
||||
throw new Error("id parameter should be a group URL string or a SteamID object");
|
||||
}
|
||||
|
||||
|
||||
if(typeof id === 'object' && (id.universe != SteamID.Universe.PUBLIC || id.type != SteamID.Type.CLAN)) {
|
||||
throw new Error("SteamID must stand for a clan account in the public universe");
|
||||
}
|
||||
|
||||
|
||||
var self = this;
|
||||
this.httpRequest("https://steamcommunity.com/" + (typeof id === 'string' ? "groups/" + id : "gid/" + id.toString()) + "/memberslistxml/?xml=1", function(err, response, body) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
xml2js.parseString(body, function(err, result) {
|
||||
if(err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
callback(null, new CSteamGroup(self, result.memberList));
|
||||
});
|
||||
}, "steamcommunity");
|
||||
@ -32,7 +32,7 @@ SteamCommunity.prototype.getSteamGroup = function(id, callback) {
|
||||
|
||||
function CSteamGroup(community, groupData) {
|
||||
this._community = community;
|
||||
|
||||
|
||||
this.steamID = new SteamID(groupData.groupID64[0]);
|
||||
this.name = groupData.groupDetails[0].groupName[0];
|
||||
this.url = groupData.groupDetails[0].groupURL[0];
|
||||
@ -48,7 +48,7 @@ function CSteamGroup(community, groupData) {
|
||||
CSteamGroup.prototype.getAvatarURL = function(size, protocol) {
|
||||
size = size || '';
|
||||
protocol = protocol || 'http://';
|
||||
|
||||
|
||||
var url = protocol + "steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/" + this.avatarHash.substring(0, 2) + "/" + this.avatarHash;
|
||||
if(size == 'full' || size == 'medium') {
|
||||
return url + "_" + size + ".jpg";
|
||||
@ -62,7 +62,7 @@ CSteamGroup.prototype.getMembers = function(addresses, callback) {
|
||||
callback = addresses;
|
||||
addresses = null;
|
||||
}
|
||||
|
||||
|
||||
this._community.getGroupMembers(this.steamID, callback, null, null, addresses, 0);
|
||||
};
|
||||
|
||||
@ -94,6 +94,10 @@ CSteamGroup.prototype.scheduleEvent = function(name, type, description, time, se
|
||||
this._community.scheduleGroupEvent(this.steamID, name, type, description, time, server, callback);
|
||||
};
|
||||
|
||||
CSteamGroup.prototype.editEvent = function(id, name, type, description, time, server, callback) {
|
||||
this._community.editGroupEvent(this.steamID, id, name, type, description, time, server, callback);
|
||||
};
|
||||
|
||||
CSteamGroup.prototype.setPlayerOfTheWeek = function(steamID, callback) {
|
||||
this._community.setGroupPlayerOfTheWeek(this.steamID, steamID, callback);
|
||||
};
|
||||
|
@ -120,7 +120,7 @@ SteamCommunity.prototype.getAllGroupAnnouncements = function(gid, time, callback
|
||||
|
||||
var self = this;
|
||||
this.httpRequest({
|
||||
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/rss/"
|
||||
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/rss/"
|
||||
}, function(err, response, body) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
@ -286,6 +286,64 @@ SteamCommunity.prototype.scheduleGroupEvent = function(gid, name, type, descript
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.editGroupEvent = function (gid, id, name, type, description, time, server, callback) {
|
||||
if (typeof gid === 'string') {
|
||||
gid = new SteamID(gid);
|
||||
}
|
||||
|
||||
// Event types: ChatEvent - Chat, OtherEvent - A lil somethin somethin, PartyEvent - Party!, MeetingEvent - Important meeting, SpecialCauseEvent - Special cause (charity ball?), MusicAndArtsEvent - Music or Art type thing, SportsEvent - Sporting endeavor, TripEvent - Out of town excursion
|
||||
// Passing a number for type will make it a game event for that appid
|
||||
|
||||
if (typeof server === 'function') {
|
||||
callback = server;
|
||||
server = {"ip": "", "password": ""};
|
||||
} else if (typeof server === 'string') {
|
||||
server = {"ip": server, "password": ""};
|
||||
} else {
|
||||
server = {"ip": "", "password": ""};
|
||||
}
|
||||
|
||||
var form = {
|
||||
"sessionid": this.getSessionID(),
|
||||
"action": "updateEvent",
|
||||
"eventID": id,
|
||||
"tzOffset": new Date().getTimezoneOffset() * -60,
|
||||
"name": name,
|
||||
"type": (typeof type === 'number' || !isNaN(parseInt(type, 10)) ? "GameEvent" : type),
|
||||
"appID": (typeof type === 'number' || !isNaN(parseInt(type, 10)) ? type : ''),
|
||||
"serverIP": server.ip,
|
||||
"serverPassword": server.password,
|
||||
"notes": description,
|
||||
"eventQuickTime": "now"
|
||||
};
|
||||
|
||||
if (time === null) {
|
||||
form.startDate = 'MM/DD/YY';
|
||||
form.startHour = '12';
|
||||
form.startMinute = '00';
|
||||
form.startAMPM = 'PM';
|
||||
form.timeChoice = 'quick';
|
||||
} else {
|
||||
form.startDate = (time.getMonth() + 1 < 10 ? '0' : '') + (time.getMonth() + 1) + '/' + (time.getDate() < 10 ? '0' : '') + time.getDate() + '/' + time.getFullYear().toString().substring(2);
|
||||
form.startHour = (time.getHours() === 0 ? '12' : (time.getHours() > 12 ? time.getHours() - 12 : time.getHours()));
|
||||
form.startMinute = (time.getMinutes() < 10 ? '0' : '') + time.getMinutes();
|
||||
form.startAMPM = (time.getHours() <= 12 ? 'AM' : 'PM');
|
||||
form.timeChoice = 'specific';
|
||||
}
|
||||
|
||||
var self = this;
|
||||
this.httpRequestPost({
|
||||
"uri": "https://steamcommunity.com/gid/" + gid.toString() + "/eventEdit",
|
||||
"form": form
|
||||
}, function(err, response, body) {
|
||||
if(!callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
callback(err || null);
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.setGroupPlayerOfTheWeek = function(gid, steamID, callback) {
|
||||
if(typeof gid === 'string') {
|
||||
gid = new SteamID(gid);
|
||||
|
Loading…
Reference in New Issue
Block a user