-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup.js
78 lines (61 loc) · 1.76 KB
/
backup.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
const { createEventAdapter } = require('@slack/events-api');
const slackSigningSecret = SLACK_SIGNING_SECRET;
const http = require('http');
const slackEvents = createEventAdapter(slackSigningSecret);
const port = 3000;
//${server.address().port}
const startServer = async () => {
// Start the built-in server
const server = await slackEvents.start(port);
// Log a message when the server is ready
console.log(`Listening for events on ${server.address().port}`);
}
startServer();
const bot = new SlackBot({
token: oathToken,
name: 'bOwlBot'
});
// Start Handler
bot.on('start', () => {
const params = {
icon_emoji: ':smiley:'
}
bot.postMessageToChannel('general', 'Get ready to eat!', params);
})
const request = require('request-promise');
const getData = async function() {
const json = await request({
url: 'https://next.json-generator.com/api/json/get/4kkDelMju',
json: true
});
return json.map(person => ({
age: person.age,
email: person.email,
}))
}
//const inquiry = https://api.gnavi.co.jp/RestSearchAPI/v3/?keyid=${GnaviRestAPIKey}&latitude=${location.lat}&longitude=${location.log}&hit_per_page=${HIT_PER_PAGE}&range=${RANGE}&offset=${restNumber}`;
const sendRquest = async function() {
try {
const people = await getData();
console.log(people)
const slackBody = {
mkdwn: true,
text: '<!channel_name>Slack Msg',
attachments: people.map(person => ({
color: 'good',
text: `*${person.email}* and their name is ${person.email}`,
}))
}
const res = await request({
url: `https://hooks.slack.com/services/${webHook}`,
method: 'POST',
body: slackBody,
json: true
})
console.log(res)
} catch (e) {
console.log('our error:', e);
}
debugger;
};
sendRquest();