summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/rbot/plugins/poll.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/data/rbot/plugins/poll.rb b/data/rbot/plugins/poll.rb
index 33e2b4d8..4dc28e69 100644
--- a/data/rbot/plugins/poll.rb
+++ b/data/rbot/plugins/poll.rb
@@ -118,6 +118,18 @@ class PollPlugin < Plugin
init_reg_entry :running, Hash.new
init_reg_entry :archives, Hash.new
init_reg_entry :last_poll_id, 0
+ running = @registry[:running]
+ now = Time.now
+ running.each do |id, poll|
+ duration = poll.ends_at - Time.now
+ if duration > 0
+ # keep the poll running
+ @bot.timer.add_once(duration) { count_votes(poll.id) }
+ else
+ # the poll expired while the bot was out, end it
+ count_votes(poll.id)
+ end
+ end
end
def authors_running_count(victim)