From 2e875e7434ea3c2135bb45107fc7e938dd3ccbc2 Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 15 Jan 2013 16:21:43 +0000 Subject: [PATCH] update poll [#131] --- modules/poll/commands.js | 187 ++++++++++++++++++++++++++++++++ modules/poll/pages.js | 45 ++++++++ modules/poll/poll.js | 226 +-------------------------------------- 3 files changed, 235 insertions(+), 223 deletions(-) create mode 100644 modules/poll/commands.js create mode 100644 modules/poll/pages.js diff --git a/modules/poll/commands.js b/modules/poll/commands.js new file mode 100644 index 0000000..0758f66 --- /dev/null +++ b/modules/poll/commands.js @@ -0,0 +1,187 @@ +var _ = require('underscore')._; + +var commands = function(dbot) { + var polls = dbot.db.polls; + var commands = { + '~newpoll': function(event) { + var name = event.input[1], + options = event.input[2].split(','), + description = event.input[3]; + + if(_.has(polls, name)) { + event.reply(dbot.t('poll_exists', { 'name': name })); + } else { + polls[name] = { + 'name': name, + 'description': description, + 'owner': event.user, + 'votes': {}, + 'votees': {} + }; + for(var i=0;i