forked from homeyer/gocodebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
57 lines (45 loc) · 1.47 KB
/
index.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
57
require('./keep-alive');
var Botkit = require('botkit');
var GitHub = require("github");
var Jarvis = require('./jarvis');
var chalk = require('chalk');
var github = new GitHub({
version: "3.0.0",
debug: true,
timeout: 2000,
headers: {
"user-agent": "gocodebot"
}
});
github.authenticate({
type: "oauth",
token: process.env.GITHUB_API_TOKEN
});
var controller = Botkit.slackbot();
controller.spawn({
token: process.env.SLACK_BOT_TOKEN
}).startRTM(function(err){
if (err) {
throw new Error(err);
}
});
controller.hears(['create team'], ['direct_message', 'direct_mention'], function(bot, message){
bot.startConversation(message, function(err, convo) {
convo.say('I can do that.');
var jarvis = new Jarvis(github);
jarvis.createTeam(convo, function(){
jarvis.addTeamMembers(convo, function(){
jarvis.createContent(convo, function(url){
convo.say(`Ok, we’re all set. You have an invitation email waiting for you. You can also visit https://github.com/${process.env.GITHUB_ORGANIZATION} and click the "View Invitation" button at the top.`);
convo.say(`After accepting your invitation you can get started at: https://github.com/${process.env.GITHUB_ORGANIZATION}/${jarvis.team.name}`);
convo.next();
});
});
});
});
});
// controller.hears(['add (.*) to (.*)'], ['direct_message', 'direct_mention'], function(bot, message){
//
// var jarvis = new Jarvis(github);
//
// })