|
|
@@ -75,6 +75,19 @@ class SlackBotService extends S2sMessageHandlable {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ async helpCommand(client, body) {
|
|
|
+ const message = '*Help*\n growi-bot usage\n `/growi [command] [args]`\n\n Create new page\n `create`\n\n Search pages\n `search [keyword]`';
|
|
|
+ client.chat.postEphemeral({
|
|
|
+ channel: body.channel_id,
|
|
|
+ user: body.user_id,
|
|
|
+ text: 'Help',
|
|
|
+ blocks: [
|
|
|
+ this.generateMarkdownSectionBlock(message),
|
|
|
+ ],
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
getKeywords(args) {
|
|
|
const keywordsArr = args.slice(1);
|
|
|
const keywords = keywordsArr.join(' ');
|
|
|
@@ -143,7 +156,7 @@ class SlackBotService extends S2sMessageHandlable {
|
|
|
async shareSearchResults(client, payload) {
|
|
|
client.chat.postMessage({
|
|
|
channel: payload.channel.id,
|
|
|
- text: payload.actions[0].value,
|
|
|
+ text: JSON.parse(payload.actions[0].value).pageList,
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -197,7 +210,9 @@ class SlackBotService extends S2sMessageHandlable {
|
|
|
},
|
|
|
style: 'primary',
|
|
|
action_id: 'shareSearchResults',
|
|
|
- value: `${keywordsAndDesc} \n\n ${urls.join('\n')}`,
|
|
|
+ value: JSON.stringify({
|
|
|
+ offset, body, args, pageList: `${keywordsAndDesc} \n\n ${urls.join('\n')}`,
|
|
|
+ }),
|
|
|
},
|
|
|
],
|
|
|
};
|
|
|
@@ -265,6 +280,7 @@ class SlackBotService extends S2sMessageHandlable {
|
|
|
this.generateInputSectionBlock('path', 'Path', 'path_input', false, '/path'),
|
|
|
this.generateInputSectionBlock('contents', 'Contents', 'contents_input', true, 'Input with Markdown...'),
|
|
|
],
|
|
|
+ private_metadata: JSON.stringify({ channelId: body.channel_id }),
|
|
|
},
|
|
|
});
|
|
|
}
|
|
|
@@ -297,7 +313,16 @@ class SlackBotService extends S2sMessageHandlable {
|
|
|
|
|
|
// generate a dummy id because Operation to create a page needs ObjectId
|
|
|
const dummyObjectIdOfUser = new mongoose.Types.ObjectId();
|
|
|
- await Page.create(path, contentsBody, dummyObjectIdOfUser, {});
|
|
|
+ const page = await Page.create(path, contentsBody, dummyObjectIdOfUser, {});
|
|
|
+
|
|
|
+ // Send a message when page creation is complete
|
|
|
+ const growiUri = this.crowi.appService.getSiteUrl();
|
|
|
+ const channelId = JSON.parse(payload.view.private_metadata).channelId;
|
|
|
+ await client.chat.postEphemeral({
|
|
|
+ channel: channelId,
|
|
|
+ user: payload.user.id,
|
|
|
+ text: `The page <${decodeURI(growiUri + path)} | ${decodeURI(`${growiUri}/${page._id}`)}> has been created.`,
|
|
|
+ });
|
|
|
}
|
|
|
catch (err) {
|
|
|
client.chat.postMessage({
|