3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-23 20:39:25 +01:00

record notifies

This commit is contained in:
reality 2013-07-06 18:45:21 +00:00
parent 7dfa493f44
commit c5448080bf
5 changed files with 98 additions and 1 deletions

44
modules/report/pages.js Normal file
View File

@ -0,0 +1,44 @@
var _ = require('underscore')._;
var pages = function(dbot) {
return {
'/notify': function(req, res) {
res.render('servers', {
'name': dbot.config.name,
'servers': _.keys(dbot.config.servers)
});
},
'/notify/:server': function(req, res) {
var server = req.params.server;
res.render('channels', {
'name': dbot.config.name,
'server': server,
'channels': _.keys(dbot.instance.servers[server].channels)
});
},
'/notify/:server/:user': function(req, res) {
var server = req.params.server,
channel = req.params.channel,
notifies = [];
this.db.search('notifies', {
'server': server,
'channel': channel
}, function(notify) {
notifies.push(notify);
}, function(err) {
res.render('notifies', {
'name': dbot.config.name,
'server': server,
'notifies': notifies
});
});
}
};
};
exports.fetch = function(dbot) {
return pages(dbot);
};

View File

@ -1,4 +1,5 @@
var _ = require('underscore')._;
var _ = require('underscore')._,
uuid = require('node-uuid');
var report = function(dbot) {
this.api = {
@ -56,6 +57,17 @@ var report = function(dbot) {
'notifier': event.user,
'message': message
}));
var id = uuid.v4();
this.db.save('notifies', id, {
'id': id,
'server': event.server,
'channel': channelName,
'user': event.user,
'time': new Date().getTime(),
'message': message
}, function() {});
event.reply(dbot.t('notified', {
'user': event.user,
'channel': channelName

View File

@ -0,0 +1,10 @@
extends ../layout
block content
h3 Channels on #{server}
div#backlink
a(href='/warning') « Server List
ul#quotelist
-each channel in channels
a(href='/notify/'+server+'/'+encodeURIComponent(channel))
li.quotes #{channel}

View File

@ -0,0 +1,21 @@
extends ../layout
block content
div#backlink
a(href='/notify/'+server) « Server Channels
p
div#profile_datatable
table.table.table-hover.data
thead
tr
th Date
th Channel
th User
th Message
tbody
for notify, key in notifies
tr
td #{new Date(notify.time)}
td #{notify.channel}
td #{notify.user}
td #{notify.message}

10
views/report/servers.jade Normal file
View File

@ -0,0 +1,10 @@
extends ../layout
block content
h3 Servers
div#backlink
a(href='/') « Home
ul#quotelist
-each server in servers
a(href='/notify/'+server)
li.quotes #{server}