mirror of
https://github.com/reality/dbot.git
synced 2024-12-24 11:42:36 +01:00
something something channel users
This commit is contained in:
parent
5644675b74
commit
f48e4c3942
@ -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));
|
||||
|
@ -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);
|
||||
} else {
|
||||
callback(false);
|
||||
}
|
||||
}
|
||||
}.bind(this));
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
||||
'getAllUsers': function(callback) {
|
||||
|
Loading…
Reference in New Issue
Block a user