-
Notifications
You must be signed in to change notification settings - Fork 0
/
response.js
56 lines (46 loc) · 1.48 KB
/
response.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Response Display module
var dustfs = require('dustfs');
var moment = require('moment');
//Init
var response = function(slack, data) {
this.slack = slack;
this.data = data;
// Load up the dust templates
dustfs.dirs('templates');
};
response.prototype.slackWrapper = function(err, out) {
this.slack.sendMsg(this.data.channel, out);
};
response.prototype.greeting = function(){
username = '@' + this.slack.getUser(this.data.user).name;
dustfs.render('greeting.dust', {username: username}, this.slackWrapper.bind(this));
};
response.prototype.badAPIKey = function(){
dustfs.render('badAPIKey.dust', {}, this.slackWrapper.bind(this));
};
response.prototype.listProjects = function(projects){
dustfs.render('listProjects.dust', {
projects_length: projects.length,
projects: projects
}, this.slackWrapper.bind(this));
};
response.prototype.help = function(){
dustfs.render('help.dust', {}, this.slackWrapper.bind(this));
};
response.prototype.viewProject = function(report) {
var project = report.title.project;
var totalHours = report.totals.reduce(function(a,b){
return a + b;
});
dustfs.render('viewProject.dust', {
project: project,
totalHours: moment.duration(totalHours)
}, this.slackWrapper.bind(this));
};
response.prototype.workspaceSelection = function(workspaces){
dustfs.render('workspaceSelection.dust', {
workspace_length: workspaces.length,
workspaces: workspaces
}, this.slackWrapper.bind(this));
};
module.exports = response;