-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
108 lines (95 loc) · 3.68 KB
/
Copy pathindex.js
File metadata and controls
108 lines (95 loc) · 3.68 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
var Botkit = require('botkit')
var token = process.env.SLACK_TOKEN
var controller = Botkit.slackbot({
// added for slash command lines 7 thru 11
// json_file_store: './db_slackbutton_slashcommand/',
//}).configureSlackApp({
// clientId: process.env.clientId,
// clientSecret: process.env.clientSecret,
// scopes: ['commands'],
// reconnect to Slack RTM when connection goes bad
retry: Infinity,
debug: false
})
// Assume single team mode if we have a SLACK_TOKEN
if (token) {
console.log('Starting in single-team mode')
controller.spawn({
token: token,
retry: Infinity
}).startRTM(function (err, bot, payload) {
if (err) {
throw new Error(err)
}
// dont know what the following is for - added for slash command 30 -33
// if (!process.env.clientId || !process.env.clientSecret || !process.env.port) {
// console.log('Error: Specify clientId clientSecret and port in environment');
// process.exit(1);
//}
console.log('Connected to Slack RTM')
})
// Otherwise assume multi-team mode - setup beep boop resourcer connection
} else {
console.log('I\'ve been connected for multi-team mode.')
require('beepboop-botkit').start(controller, { debug: true })
}
controller.on('bot_channel_join', function (bot, message) {
bot.reply(message, "Gamebots have been added to your Channel. Type 'start' to begin combat.")
})
//
controller.hears(['hello', 'hi', 'begin'], ['direct_message'], function (bot, message) {
bot.reply(message, 'Greetings <@' + message.user + '>')
bot.reply(message, 'Welcome to Gamebots.ai. You can type:')
bot.reply(message, 'profile: to see your gamebot stats')
bot.reply(message, 'leaderboard: to see active gamebot rankings')
bot.reply(message, 'help: to list gamebot commands')
})
controller.hears('help', ['direct_message', 'direct_mention'], function (bot, message) {
var help = 'These are the gamebot commands: \n' +
'`/bomb (+ @user)` Sets an Electo bomb with a three minute delay.\n' +
'`/laser (+ @user)` Charges a proton laser with a one minute delay.\n' +
'`/shield (+ @user)` to raise a plasma shield to defend for five minutes.\n'
'`/mine + word` set a key word to trigger a 1 minute hydrogen mine.\n'
bot.reply(message, help)
})
//This launches an attachment. Good for launch of the main screen.
controller.hears(['start'], ['direct_message', 'direct_mention'], function (bot, message) {
var text = 'Gamebots.ai is a cloud based game intelligence. Battle your coworkers for control of your slack channel.'
var attachments = [{
fallback: text,
pretext: 'The microgaming system from the future. :sunglasses: :thumbsup:',
title: 'Battle your coworkers.',
image_url: 'https://storage.googleapis.com/beepboophq/_assets/bot-1.22f6fb.png',
title_link: 'https://gamebots.ai/',
text: text,
color: '#662572'
}]
bot.reply(message, {
attachments: attachments
}, function (err, resp) {
console.log(err, resp)
})
})
controller.hears('.*', ['direct_message', 'direct_mention'], function (bot, message) {
bot.reply(message, 'Sorry <@' + message.user + '>, I don\'t understand. \n')
})
// experimentations with slash commands 96 - 115
//controller.setupWebserver(process.env.port,function(err,webserver) {
//
// controller.createWebhookEndpoints(controller.webserver);
//
// controller.createOauthEndpoints(controller.webserver,function(err,req,res) {
// if (err) {
// res.status(500).send('ERROR: ' + err);
// } else {
// res.send('Success!');
// }
// });
//});
//
//controller.on('slash_command',function(bot,message) {
//
// bot.replyPublic(message,'<@' + message.user + '> is cool!');
// bot.replyPrivate(message,'*nudge nudge wink wink*');
//
//});