diff --git a/modules/report/pages.js b/modules/report/pages.js new file mode 100644 index 0000000..8ecc841 --- /dev/null +++ b/modules/report/pages.js @@ -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); +}; diff --git a/modules/report/report.js b/modules/report/report.js index e123b2e..ceb327c 100644 --- a/modules/report/report.js +++ b/modules/report/report.js @@ -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 diff --git a/views/report/channels.jade b/views/report/channels.jade new file mode 100644 index 0000000..b2a0b7e --- /dev/null +++ b/views/report/channels.jade @@ -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} diff --git a/views/report/notifies.jade b/views/report/notifies.jade new file mode 100644 index 0000000..1b4c04d --- /dev/null +++ b/views/report/notifies.jade @@ -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} diff --git a/views/report/servers.jade b/views/report/servers.jade new file mode 100644 index 0000000..924eb19 --- /dev/null +++ b/views/report/servers.jade @@ -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}