forked from GitHub/dbot
poll uses event.rUser [#511]
This commit is contained in:
parent
f924686871
commit
7e2b717d0a
@ -16,6 +16,7 @@ var dns = function(dbot) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
'~rdns': function(event) {
|
'~rdns': function(event) {
|
||||||
ip = event.params[1];
|
ip = event.params[1];
|
||||||
dnsmod.reverse(ip, function (error, domain) {
|
dnsmod.reverse(ip, function (error, domain) {
|
||||||
|
@ -55,9 +55,6 @@ var commands = function(dbot) {
|
|||||||
if(this.config.network_name[event.server]) {
|
if(this.config.network_name[event.server]) {
|
||||||
network = this.config.network_name[event.server];
|
network = this.config.network_name[event.server];
|
||||||
}
|
}
|
||||||
console.log(timeout);
|
|
||||||
console.log(banee);
|
|
||||||
console.log(reason);
|
|
||||||
|
|
||||||
dbot.api.nickserv.getUserHost(event.server, banee, function(host) {
|
dbot.api.nickserv.getUserHost(event.server, banee, function(host) {
|
||||||
// Add host record entry
|
// Add host record entry
|
||||||
|
@ -13,11 +13,10 @@ var commands = function(dbot) {
|
|||||||
_.each(options, function(item, index, list) { list[index] = [ item, 0 ]; })
|
_.each(options, function(item, index, list) { list[index] = [ item, 0 ]; })
|
||||||
votes = _.object(options);
|
votes = _.object(options);
|
||||||
|
|
||||||
dbot.api.users.resolveUser(event.server, event.user, function(user) {
|
|
||||||
this.db.create('poll', name, {
|
this.db.create('poll', name, {
|
||||||
'name': name,
|
'name': name,
|
||||||
'description': description,
|
'description': description,
|
||||||
'owner': user.id,
|
'owner': event.rUser.id,
|
||||||
'votes': votes,
|
'votes': votes,
|
||||||
'votees': {}
|
'votees': {}
|
||||||
}, function(err, value) {
|
}, function(err, value) {
|
||||||
@ -31,17 +30,15 @@ var commands = function(dbot) {
|
|||||||
event.reply(dbot.t('poll_exists', { 'name': name }));
|
event.reply(dbot.t('poll_exists', { 'name': name }));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}.bind(this));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
'~addoption': function(event) {
|
'~addoption': function(event) {
|
||||||
var name = event.input[1].toLowerCase(),
|
var name = event.input[1].toLowerCase(),
|
||||||
option = event.input[2].toLowerCase();
|
option = event.input[2].toLowerCase();
|
||||||
|
|
||||||
dbot.api.users.resolveUser(event.server, event.user, function(user) {
|
|
||||||
this.db.read('poll', name, function(err, poll) {
|
this.db.read('poll', name, function(err, poll) {
|
||||||
if(!err) {
|
if(!err) {
|
||||||
if(poll.owner === user.id) {
|
if(poll.owner === event.rUser.id) {
|
||||||
if(!_.has(poll.votes, option)) {
|
if(!_.has(poll.votes, option)) {
|
||||||
poll.votes[option] = 0;
|
poll.votes[option] = 0;
|
||||||
this.db.save('poll', name, poll, function(err) {
|
this.db.save('poll', name, poll, function(err) {
|
||||||
@ -70,17 +67,15 @@ var commands = function(dbot) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}.bind(this));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
'~rmoption': function(event) {
|
'~rmoption': function(event) {
|
||||||
var name = event.input[1].toLowerCase(),
|
var name = event.input[1].toLowerCase(),
|
||||||
option = event.input[2].toLowerCase();
|
option = event.input[2].toLowerCase();
|
||||||
|
|
||||||
dbot.api.users.resolveUser(event.server, event.user, function(user) {
|
|
||||||
this.db.read('poll', name, function(err, poll) {
|
this.db.read('poll', name, function(err, poll) {
|
||||||
if(!err) {
|
if(!err) {
|
||||||
if(poll.owner === user.id) {
|
if(poll.owner === event.rUser.id) {
|
||||||
if(_.has(poll.votes, option)) {
|
if(_.has(poll.votes, option)) {
|
||||||
delete poll.votes[option];
|
delete poll.votes[option];
|
||||||
|
|
||||||
@ -103,25 +98,23 @@ var commands = function(dbot) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}.bind(this));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
'~vote': function(event) {
|
'~vote': function(event) {
|
||||||
var name = event.input[1].toLowerCase(),
|
var name = event.input[1].toLowerCase(),
|
||||||
vote = event.input[2].toLowerCase();
|
vote = event.input[2].toLowerCase();
|
||||||
|
|
||||||
dbot.api.users.resolveUser(event.server, event.user, function(user) {
|
|
||||||
this.db.read('poll', name, function(err, poll) {
|
this.db.read('poll', name, function(err, poll) {
|
||||||
if(!err) {
|
if(!err) {
|
||||||
if(_.has(poll.votes, vote)) {
|
if(_.has(poll.votes, vote)) {
|
||||||
if(_.has(poll.votees, user.id)) {
|
if(_.has(poll.votees, event.rUser.id)) {
|
||||||
var oldVote = poll.votees[user.id];
|
var oldVote = poll.votees[event.rUser.id];
|
||||||
poll.votes[oldVote]--;
|
poll.votes[oldVote]--;
|
||||||
poll.votes[vote]++;
|
poll.votes[vote]++;
|
||||||
poll.votees[user.id] = vote;
|
poll.votees[event.rUser.id] = vote;
|
||||||
} else {
|
} else {
|
||||||
poll.votes[vote]++;
|
poll.votes[vote]++;
|
||||||
poll.votees[user.id] = vote;
|
poll.votees[event.rUser.id] = vote;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.db.save('poll', name, poll, function(err) {
|
this.db.save('poll', name, poll, function(err) {
|
||||||
@ -141,7 +134,6 @@ var commands = function(dbot) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}.bind(this));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
'~pdesc': function(event) {
|
'~pdesc': function(event) {
|
||||||
|
Loading…
Reference in New Issue
Block a user