mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-03-30 02:10:09 +08:00
Added ability to deleteAnnoucement
This commit is contained in:
parent
4223d88fd1
commit
27ef78cc4b
@ -88,6 +88,10 @@ CSteamGroup.prototype.editAnnouncement = function(annoucementID, headline, conte
|
|||||||
this._community.editGroupAnnouncement(this.steamID, annoucementID, headline, content, callback)
|
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) {
|
CSteamGroup.prototype.scheduleEvent = function(name, type, description, time, server, callback) {
|
||||||
this._community.scheduleGroupEvent(this.steamID, name, type, description, time, server, callback);
|
this._community.scheduleGroupEvent(this.steamID, name, type, description, time, server, callback);
|
||||||
};
|
};
|
||||||
|
@ -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) {
|
SteamCommunity.prototype.scheduleGroupEvent = function(gid, name, type, description, time, server, callback) {
|
||||||
if(typeof gid === 'string') {
|
if(typeof gid === 'string') {
|
||||||
gid = new SteamID(gid);
|
gid = new SteamID(gid);
|
||||||
|
@ -54,7 +54,7 @@ function doLogin(accountName, password, authCode, twoFactorCode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group.getAllAnnouncements(function(err, announcements) {
|
group.getAllAnnouncements(function(err, announcements) {
|
||||||
|
|
||||||
if(announcements.length === 0) {
|
if(announcements.length === 0) {
|
||||||
return console.log("This group has no announcements");
|
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);
|
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("Would you like to delete delete or edit an annoucement? (Type edit/delete): ", function(choice) {
|
||||||
rl.question("New title: ", function(header) {
|
rl.question("Annoucement ID: ", function(aid) {
|
||||||
rl.question("New body: ", function(content) {
|
if(choice === 'edit') {
|
||||||
// EW THE PYRAMID!
|
rl.question("New title: ", function(header) {
|
||||||
editAnnouncement(group, aid, header, content);
|
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.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user