3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 14:29:29 +01:00

report uses known users api functionality [#158]

This commit is contained in:
reality 2013-01-20 19:04:12 +00:00
parent e048780cfc
commit 8a66f5b9c6
4 changed files with 14 additions and 2 deletions

View File

@ -9,7 +9,8 @@ var report = function(dbot) {
if(_.has(event.allChannels, channelName)) { if(_.has(event.allChannels, channelName)) {
var channel = event.allChannels[channelName]; var channel = event.allChannels[channelName];
if(_.has(channel.nicks, nick)) { if(dbot.api.users.isChannelUser(event.server, nick, channelName, true)) {
var nick = dbot.api.users.resolveUser(event.server, nick, true);
var ops = _.filter(channel.nicks, function(user) { var ops = _.filter(channel.nicks, function(user) {
return user.op; return user.op;
}); });

View File

@ -6,7 +6,7 @@
"english": "Thank you, {reported} has been reported to the channel administrators." "english": "Thank you, {reported} has been reported to the channel administrators."
}, },
"user_not_found": { "user_not_found": {
"english": "{reported} does not appear to be in {channel}." "english": "{reported} isn't a known user in {channel}."
}, },
"not_in_channel": { "not_in_channel": {
"english": "I am not present in {channel}." "english": "I am not present in {channel}."

View File

@ -65,6 +65,16 @@ var api = function(dbot) {
nick = nick.name; nick = nick.name;
return _.include(possiNicks, nick); return _.include(possiNicks, nick);
}, this); }, this);
},
'isChannelUser': function(server, user, channel, useLowerCase) {
var knownUsers = this.getServerUsers(server);
var user = this.api.resolveUser(server, user, useLowerCase);
if(!_.has(knownUsers.channelUsers, channel)) {
return false;
}
return _.include(knownUsers.channelUsers[channel], user);
} }
}; };

View File

@ -49,6 +49,7 @@ var users = function(dbot) {
} else { } else {
knownUsers.users.push(nick); knownUsers.users.push(nick);
} }
if(!_.include(channelUsers, nick)) { if(!_.include(channelUsers, nick)) {
channelUsers.push(nick); channelUsers.push(nick);
} }