3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-03 17:39:28 +01:00

new notes functionality

This commit is contained in:
Luke Slater 2018-02-10 12:35:31 +00:00
parent e62a1c8484
commit 777d738394
2 changed files with 56 additions and 0 deletions

View File

@ -131,6 +131,41 @@ var commands = function(dbot) {
}); });
}, },
'~notes': function(event) {
var tName = event.params[1],
server = event.server;
dbot.api.users.resolveUser(server, tName, function(err, target) {
if(target) {
var notes = {};
this.db.search('warnings', {
'server': server,
'warnee': warnee.id
}, function(warning) {
if(warning.reason.match('#note')) {
notes[warning.time] = warning;
}
}, function(err) {
if(_.size(notes) > 0) {
var nTimes = _.keys(notes).sort(function(a, b) {
return parseInt(a) - parseInt(b);
});
var n = 0;
_.each(nTimes, function(key) {
event.reply('['+n+'][\u00036note\u000f][' + moment(parseInt(time)).format('DD/MM/YYYY') + '] ' + notes[key].reason);
n++;
});
} else {
event.reply('No notes found for ' + tName);
}
});
} else {
event.reply(event.params[1] + ' not found.');
}
}.bind(this));
},
'~sustatus': function(event) { '~sustatus': function(event) {
var user = event.input[1]; var user = event.input[1];
if(event.channel == '#tripsit.me') { if(event.channel == '#tripsit.me') {
@ -415,6 +450,7 @@ var commands = function(dbot) {
commands['~ustatus'].access = 'power_user'; commands['~ustatus'].access = 'power_user';
commands['~sustatus'].access = 'power_user'; commands['~sustatus'].access = 'power_user';
commands['~ncount'].access = 'power_user'; commands['~ncount'].access = 'power_user';
commands['~notes'].access = 'power_user';
return commands; return commands;
}; };

View File

@ -62,6 +62,24 @@ var warning = function(dbot) {
}); });
}, },
'~addnote': function(event) {
var warner = event.rUser,
server = event.server,
reason = event.input[2];
if(!reason.match('#note')) {
reason += ' #note';
}
this.api.warn(server, warner, event.input[1], reason, event.channel, function(err) {
if(err) {
event.reply(dbot.t('warnee_not_found', { 'user': event.input[1] }));
} else {
event.reply('Note added!');
}
});
},
'~rmwarning': function(event) { '~rmwarning': function(event) {
var user = event.params[1], var user = event.params[1],
index = parseInt(event.params[2]); index = parseInt(event.params[2]);
@ -116,6 +134,7 @@ var warning = function(dbot) {
}.bind(this)); }.bind(this));
}.bind(this)); }.bind(this));
}, },
'~warnings': function(event) { '~warnings': function(event) {
var warnee = event.params[1], var warnee = event.params[1],
server = event.server; server = event.server;
@ -152,6 +171,7 @@ var warning = function(dbot) {
this.commands['~warn'].access = 'power_user'; this.commands['~warn'].access = 'power_user';
this.commands['~rmwarning'].access = 'power_user'; this.commands['~rmwarning'].access = 'power_user';
this.commands['~rmlastwarning'].access = 'power_user'; this.commands['~rmlastwarning'].access = 'power_user';
this.commands['~addnote'].access = 'power_user';
}; };
exports.fetch = function(dbot) { exports.fetch = function(dbot) {