diff --git a/lib/channel.js b/lib/channel.js index 39a1453c..020b60b9 100644 --- a/lib/channel.js +++ b/lib/channel.js @@ -2112,6 +2112,14 @@ Channel.prototype.handleOpenPoll = function (user, data) { var obscured = (data.obscured === true); var poll = new Poll(user.name, title, opts, obscured); + var self = this; + if (typeof data.timeout === "number" && !isNaN(data.timeout) && data.timeout > 0) { + poll.timer = setTimeout(function () { + if (self.poll === poll) { + self.handleClosePoll({ name: "[poll timer]", rank: 255 }); + } + }, data.timeout * 1000); + } this.poll = poll; this.sendPoll(this.users, true); this.logger.log("[poll] " + user.name + " Opened Poll: '" + poll.title + "'"); @@ -2131,6 +2139,10 @@ Channel.prototype.handleClosePoll = function (user) { this.sendPollUpdate(this.users); } + if (this.poll.timer) { + clearTimeout(this.poll.timer); + } + this.logger.log("[poll] " + user.name + " closed the active poll"); this.poll = false; this.sendAll("closePoll"); diff --git a/lib/chatcommand.js b/lib/chatcommand.js index 6ef78afd..20ad2160 100644 --- a/lib/chatcommand.js +++ b/lib/chatcommand.js @@ -73,7 +73,6 @@ var handlers = { /* commands that do not send chat messages */ "afk": function (chan, user, msg, meta) { - console.log("/afk => setAfk(!" + user.meta.afk + ")"); user.setAFK(!user.meta.afk); return true; }, diff --git a/www/assets/js/util.js b/www/assets/js/util.js index 8bc493d4..5f542842 100644 --- a/www/assets/js/util.js +++ b/www/assets/js/util.js @@ -720,6 +720,11 @@ function showPollMenu() { .attr("type", "text") .appendTo(menu); + $("").text("Timeout (optional)").appendTo(menu); + var timeout = $("").addClass("form-control") + .attr("type", "text") + .appendTo(menu); + var lbl = $("