-
Notifications
You must be signed in to change notification settings - Fork 1
/
channel.js
39 lines (38 loc) · 1.01 KB
/
channel.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
const getChannelMeta = require('./util/get-channel-meta');
module.exports = (call) => ({
meta: (name) => getChannelMeta(call, name),
message: async (name, msg) => {
const channel = await getChannelMeta(call, name);
return call('chat.postMessage', {
text: msg,
channel: channel.id
});
},
setTopic: async (name, topic) => {
const channel = await getChannelMeta(call, name);
if (channel.topic?.value === topic) {
return null;
}
return call('conversations.setTopic', {
topic,
channel: channel.id
});
},
setPurpose: async (name, purpose) => {
const channel = await getChannelMeta(call, name);
if (channel.purpose?.value === purpose) {
return null;
}
return call('conversations.setPurpose', {
purpose,
channel: channel.id
});
},
shareFiles: async (name, files) => {
const channel = await getChannelMeta(call, name);
return call('files.share', {
files: files.join(','),
channel: channel.id
});
}
});