Added ability to deleteAnnoucement

This commit is contained in:
Shaun Barratt 2016-01-17 02:27:11 +00:00
parent 4223d88fd1
commit 27ef78cc4b
3 changed files with 58 additions and 7 deletions

View File

@ -88,6 +88,10 @@ CSteamGroup.prototype.editAnnouncement = function(annoucementID, headline, conte
this._community.editGroupAnnouncement(this.steamID, annoucementID, headline, content, callback)
};
CSteamGroup.prototype.deleteAnnouncement = function(annoucementID, headline, content, callback) {
this._community.deleteGroupAnnouncement(this.steamID, annoucementID, headline, content, callback)
};
CSteamGroup.prototype.scheduleEvent = function(name, type, description, time, server, callback) {
this._community.scheduleGroupEvent(this.steamID, name, type, description, time, server, callback);
};

View File

@ -246,6 +246,34 @@ SteamCommunity.prototype.editGroupAnnouncement = function(gid, aid, headline, co
})
};
SteamCommunity.prototype.deleteGroupAnnouncement = function(gid, aid, callback) {
if(typeof gid === 'string') {
gid = new SteamID(gid);
}
var self = this;
var submitData = {
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements/delete/" + aid + "?sessionID=" + this.getSessionID(),
}
this.request.get(submitData, function(err, response, body) {
if(!callback) {
return;
}
if(self._checkHttpError(err, response, callback)) {
return;
}
if(self._checkCommunityError(body, callback)) {
return;
}
callback(null);
})
};
SteamCommunity.prototype.scheduleGroupEvent = function(gid, name, type, description, time, server, callback) {
if(typeof gid === 'string') {
gid = new SteamID(gid);

View File

@ -54,7 +54,7 @@ function doLogin(accountName, password, authCode, twoFactorCode) {
}
group.getAllAnnouncements(function(err, announcements) {
if(announcements.length === 0) {
return console.log("This group has no announcements");
}
@ -63,12 +63,19 @@ function doLogin(accountName, password, authCode, twoFactorCode) {
console.log("[%s] %s %s: %s", announcements[i].date, announcements[i].aid, announcements[i].author, announcements[i].content);
};
rl.question("Annoucement ID: ", function(aid) {
rl.question("New title: ", function(header) {
rl.question("New body: ", function(content) {
// EW THE PYRAMID!
editAnnouncement(group, aid, header, content);
});
rl.question("Would you like to delete delete or edit an annoucement? (Type edit/delete): ", function(choice) {
rl.question("Annoucement ID: ", function(aid) {
if(choice === 'edit') {
rl.question("New title: ", function(header) {
rl.question("New body: ", function(content) {
// EW THE PYRAMID!
// Try replace this with delete!
editAnnouncement(group, aid, header, content);
});
});
} else {
deleteAnnouncement(group, aid);
}
});
});
});
@ -88,3 +95,15 @@ function editAnnouncement(group, aid, header, content) {
}
});
}
function deleteAnnouncement(group, aid) {
// group.deleteAnnouncement(aid);
// Or
group.deleteAnnouncement(aid, function(err) {
if(!err) {
console.log("Deleted");
} else {
console.log("Error deleting announcement.");
}
})
}