-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslash_commands.js
67 lines (62 loc) · 2.39 KB
/
slash_commands.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
58
59
60
61
62
63
64
65
66
67
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
const {SlackDialog} = require('botbuilder-adapter-slack');
var artCli = require('artifactory-client-node');
var art = new artCli.artifactory();
var repositories = new artCli.repositories();
var security = new artCli.security();
module.exports = function (controller) {
controller.ready(async () => {
if (process.env.MYTEAM) {
let bot = await controller.spawn(process.env.MYTEAM);
await bot.startConversationInChannel(process.env.MYCHAN, process.env.MYUSER);
bot.say('I AM AWOKEN.');
}
});
controller.on('slash_command', async (bot, message) => {
if (message.text === 'help') {
await bot.replyPrivate(message, 'Here to help');
} else if (message.text === 'ping') {
var ping = art.ping();
ping.then(function (result) {
bot.replyPrivate(message, `Artifactory status is: ${result}`);
}, function (err) {
console.log(err);
});
} else if (message.text === 'system') {
var system = art.system();
system.then(function (result) {
bot.replyPrivate(message, `${result}`);
}, function (err) {
console.log(err);
});
} else if (message.text === 'version') {
var version = art.getVersion();
version.then(function (result) {
bot.replyPrivate(message, `${result}`);
}, function (err) {
console.log(err);
});
} else if (message.text === 'storage') {
var storage = art.getStorage();
storage.then(function (result) {
bot.replyPrivate(message, `${result}`);
}, function (err) {
console.log(err);
});
} else if (message.text === 'getApiKey') {
var getApiKey = security.getApiKey();
getApiKey.then(function (result) {
bot.replyPrivate(message, `${result}`);
}, function (err) {
console.log(err);
});
}
// set http status
// bot.httpBody({text:'You can send an immediate response using bot.httpBody()'});
// bot.httpBody({text:'Executed command: ' + `${message.text}`});
bot.httpStatus(200);
});
};