3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-23 20:39:25 +01:00

something something channel users

This commit is contained in:
reality 2014-04-11 23:19:31 +00:00
parent 5644675b74
commit f48e4c3942
2 changed files with 8 additions and 17 deletions

View File

@ -17,7 +17,7 @@ var quotes = function(dbot) {
var ref = this.internalAPI.cleanRef(quoteRefs[0].replace(/^~~/,'').replace(/~~$/,'').trim());
if(ref === '-nicks-') {
dbot.api.users.getRandomChannelUser(server, channel, function(user) {
quote = quote.replace('~~' + ref + '~~', user.currentNick);
quote = quote.replace('~~' + ref + '~~', user);
this.internalAPI.interpolatedQuote(server, channel,
username, key, quote, callback);
}.bind(this));

View File

@ -89,22 +89,13 @@ var api = function(dbot) {
},
'getRandomChannelUser': function(server, cName, callback) {
var channel;
this.db.search('channel_users', {
'server': server,
'name': cName
}, function(result) {
channel = result;
}, function(err) {
if(!err && channel) {
if(!_.isUndefined(channel.users)) {
var randomUser = channel.users[_.random(0, channel.users.length - 1)];
this.api.getUser(randomUser, callback);
if(_.has(dbot.instance.connections[server].channels, cName)) {
var nicks = _.keys(dbot.instance.connections[server].channels[cName].nicks);
var randomUser = nicks[_.random(0, nicks.length -1)]
callback(randomUser);
} else {
callback(false);
}
}
}.bind(this));
},
'getAllUsers': function(callback) {