-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
82 lines (77 loc) · 2.52 KB
/
example.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
require('dotenv').config();
let token = process.env.SLACK_BOT_TOKEN;
const SlackBot = require('./src/BaseBot');
const bot = new SlackBot({
token: token,
name: process.env.SLACK_BOT_NAME,
});
/**
* auth magic token
* @link https://slack.com/oauth/authorize?client_id=CLIENT_ID&scope=client+admin&redirect_uri=CALLBACK_URL
* @help https://github.com/blaskovicz/cut-me-some-slack#creating-a-slack-access-token
*/
let interactiveOptions = {
"text": "Would you like to play a game?",
"attachments": [
{
"text": "Choose a game to play",
"fallback": "You are unable to choose a game",
"callback_id": "welcome_button",
"color": "#3AA3E3",
"attachment_type": "default",
"actions": [
{
"name": "game",
"text": "Chess",
"type": "button",
"value": "chess"
},
{
"name": "game",
"text": "Falken's Maze",
"type": "button",
"value": "maze"
},
{
"name": "game",
"text": "Thermonuclear War",
"style": "danger",
"type": "button",
"value": "war",
"confirm": {
"title": "Are you sure?",
"text": "Wouldn't you prefer a good game of chess?",
"ok_text": "Yes",
"dismiss_text": "No"
}
}
]
}
]
};
/**
* this is example
*/
bot.on('message.groups.pinned_item', (route, routeMention) => {
route(/hello|hi/gi, async function (response, classMessage) {
let res = await classMessage.reply('Ваше сообщение было архивировано!');
});
// routeMention('allo', async function (response, classMessage) {
// classMessage.reply('hello', {
// icon_emoji: ':piggy:'
// });
// });
});
bot.on('conversation', async (route, response) => {
// first argument callback_id
route('like_service', function (responseInitiator, classConversation) {
response.end('ok');
});
});
bot.on('command', async (route, response) => {
route('/time', (responseInitiator, classCommand) => {
// console.log(responseInitiator);
console.log(classCommand.base.team.id);
response.end();
});
});