3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-18 00:22:35 +01:00

Merge pull request #318 from JohnMaguire2013/users

fixes the issue where users are not tracked correctly on some IRCd's
This commit is contained in:
reality 2013-03-21 07:29:48 -07:00
commit ea948a4ae4
3 changed files with 17 additions and 10 deletions

View File

@ -12,12 +12,8 @@ var commands = function(dbot) {
if(aliasCount != 0) {
var aliases = _.first(aliases, 10);
var including = 'including: ';
for(var i=0;i<aliases.length;i++) {
including += aliases[i] + ', ';
}
including = including.slice(0, -2) + '.';
var including = 'including: ' + aliases.join(', ') + '.';
event.reply(dbot.t('primary', {
'user': alias,
'count': aliasCount
@ -26,7 +22,7 @@ var commands = function(dbot) {
event.reply(dbot.t('primary', {
'user': alias,
'count': aliasCount
}));
}).slice(0, -2) + ".");
}
} else if(_.has(knownUsers.aliases, alias)) {
event.reply(dbot.t('alias', {
@ -100,7 +96,11 @@ var commands = function(dbot) {
return false;
}
};
commands['~alias'].regex = [/^~alias ([\d\w[\]{}^|\\`_-]+?)/, 2];
commands['~setaliasparent'].regex = [/^~setaliasparent ([\d\w[\]{}^|\\`_-]+?)/, 2];
commands['~mergeusers'].regex = [/^~mergeusers ([\d\w[\]{}^|\\`_-]+?)\s*?([\d\w[\]{}^|\\`_-]+?)/, 3];
commands['~setaliasparent'].access = 'moderator';
commands['~mergeusers'].access = 'moderator';

5
modules/users/usage.json Normal file
View File

@ -0,0 +1,5 @@
{
"~alias": "~alias [nick]",
"~setaliasparent": "~setaliasparent [nick]",
"~mergeusers": "~mergeusers [primary] [secondary]"
}

View File

@ -38,7 +38,7 @@ var users = function(dbot) {
var knownUsers = this.getServerUsers(event.server);
var nick = event.user;
if(event.action == 'JOIN') {
if(event.action == 'JOIN' && nick != dbot.config.name) {
if(!_.has(knownUsers.channelUsers, event.channel.name)) {
knownUsers.channelUsers[event.channel.name] = [];
}
@ -55,7 +55,9 @@ var users = function(dbot) {
channelUsers.push(nick);
}
} else if(event.action == 'NICK') {
var newNick = event.params.substr(1);
// remove the first character from the NICK message if it is a :,
// due to some IRCd's disregarding RFC 1459 and adding a :
var newNick = (event.params[0] == ":" ? event.params.substr(1) : event.params);
if(!this.api.isKnownUser(newNick)) {
knownUsers.aliases[newNick] = this.api.resolveUser(event.server, event.user);
dbot.api.event.emit('nick_change', [ event.server, newNick ]);