From 07f8a129d5b84f33703e075d4d545ffa04ad470b Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 16 Feb 2013 17:37:23 +0000 Subject: [PATCH] provisional poll thing. only commiting so i can switch branch w/e [#272] --- database.js | 6 +++-- modules/poll/commands.js | 49 +++++++++++++++++++++------------------- modules/poll/config.json | 9 +++++++- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/database.js b/database.js index 4f191ea..15f0e8d 100644 --- a/database.js +++ b/database.js @@ -1,7 +1,6 @@ var databank = require('databank'), Databank = databank.Databank, DatabankObject = databank.DatabankObject; - //DatabankStore = require('connect-databank')(express); /** * Multiplex databank objects @@ -15,10 +14,13 @@ var DatabaseDriver = function() { */ DatabaseDriver.prototype.createDB = function(name, driver, callback, schema) { var params = { 'schema': schema }; + + if(driver == 'disk') params.dir = 'db'; + this.databanks[name] = Databank.get(driver, params); this.databanks[name].connect({}, function(err) { if(err) { - console.log('Didn\'t manage to connect to the data source.'); + console.log('Didn\'t manage to connect to the data source - ' + err); } else { callback(this.databanks[name]); } diff --git a/modules/poll/commands.js b/modules/poll/commands.js index ac36252..dca7c60 100644 --- a/modules/poll/commands.js +++ b/modules/poll/commands.js @@ -7,30 +7,33 @@ var commands = function(dbot) { var name = event.input[1].toLowerCase(), options = event.input[2].toLowerCase().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': dbot.api.users.resolveUser(event.server, event.user), - 'votes': {}, - 'votees': {} - }; - for(var i=0;i