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

Modified missing report system as per [#545]

This commit is contained in:
reality 2013-08-12 21:58:30 +00:00
parent e06c1647c4
commit 154a0b30fe
3 changed files with 44 additions and 16 deletions

View File

@ -35,6 +35,21 @@ var pages = function(dbot) {
'notifies': notifies
});
});
},
'/report/:server/missing/:user': function(req, res) {
var server = req.params.server,
nick = req.params.user;
dbot.api.users.resolveUser(server, nick, function(user) {
var notifies = this.pending[user.id];
console.log(notifies);
res.render('missing_notifies', {
'name': dbot.config.name,
'user': nick,
'notifies': notifies
});
}.bind(this));
}
};
};

View File

@ -28,9 +28,13 @@ var report = function(dbot) {
});
}, function() {
offlineUsers = perOps;
console.log(offlineUsers);
_.each(offlineUsers, function(id) {
if(!this.pending[id]) this.pending[id] = [];
this.pending[id].push(message);
this.pending[id].push({
'time': new Date().getTime(),
'message': message
});
}.bind(this));
}.bind(this));
}
@ -50,26 +54,26 @@ var report = function(dbot) {
this.listener = function(event) {
if(_.has(this.pending, event.rUser.id)) {
var i=0,
pending = this.pending[event.rUser.id];
var notifyUser = function(pending) {
if(i >= pending.length) {
delete this.pending[event.rUser.id];
return;
}
dbot.say(event.server, event.user, pending[i]);
setTimeout(function() {
i++; notifyUser(pending);
}, 5000);
}.bind(this);
notifyUser(pending);
dbot.say(event.server, event.user, dbot.t('missed_notifies', {
'user': event.rUser.primaryNick,
'link': dbot.api.web.getUrl('report/' + event.server +
'/missing/' + event.rUser.primaryNick)
}));
}
}.bind(this);
this.on = 'JOIN';
var commands = {
'~clearmissing': function(event) {
if(_.has(this.pending, event.rUser.id)) {
var count = this.pending[event.rUser.id].length;
delete this.pending[event.rUser.id];
event.reply(dbot.t('cleared_notifies', { 'count': count }));
} else {
event.reply(dbot.t('no_missed_notifies'));
}
},
'~report': function(event) {
var channelName = event.input[1],
nick = event.input[2],

View File

@ -8,6 +8,15 @@
"fr": "Attention : {reporter} a reporté {reported} dans {channel}. Raison donnée : \"{reason}\"",
"it": "Attentzone : {reporter} ha segnalato {reported} in {channel}. Motivo : \"{reason}\""
},
"missed_notifies": {
"en": "{user}, you have some missed notifications (clear these once you have read them using ~clearmissing) - {link}"
},
"cleared_notifies": {
"en": "{count} pending notifications cleared."
},
"no_missed_notifies": {
"en": "No missing notifications were available to clear."
},
"reported": {
"en": "Thank you, {reported} has been reported to the channel administrators.",
"na'vi": "Irayo si ngari, fìtsengìri ayeyktan omum teri {reported}it set.",