Skip to content

Commit

Permalink
added detailed commands information (#17)
Browse files Browse the repository at this point in the history
Added commands as a detail every time the bot replies. This way we don't
need to call `help` and it can be minimized.

This resolves #15

It is shown in the following way:

---

Enabled `auto-merge` in Pull Request


<details><summary> <b>Available commands</b> </summary>


- `/merge`: Enables auto-merge for Pull Request
- `/merge cancel`: Cancels auto-merge for Pull Request
- `/merge help`: Shows this menu

For more information see the
[documentation](https://github.com/paritytech/auto-merge-bot)

</details>
  • Loading branch information
Bullrich committed Sep 30, 2023
1 parent 1d19925 commit 3031251
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ const BOT_COMMAND = "/merge";
type Command = "merge" | "cancel" | "help";

const botCommands = `
**Available commands**
- \`/merge\`: Enables auto-merge for Pull Request
- \`/merge cancel\`: Cancels auto-merge for Pull Request
- \`/merge help\`: Shows this menu
For more information see the [documentation](https://github.com/paritytech/auto-merge-bot)
`;

const detailCommands = `
<details><summary> <b>Available commands</b> </summary>
${botCommands}
</details>
`;

export class Bot {
constructor(
private readonly comment: IssueComment,
Expand Down Expand Up @@ -91,21 +96,21 @@ export class Bot {
await this.commentsApi.reactToComment(this.comment.id, "+1");
await merger.enableAutoMerge();
await this.commentsApi.comment(
"Enabled `auto-merge` in Pull Request",
"Enabled `auto-merge` in Pull Request\n\n" + detailCommands,
);
break;
// `/merge cancel`
case "cancel":
await this.commentsApi.reactToComment(this.comment.id, "+1");
await merger.disableAutoMerge();
await this.commentsApi.comment(
"Disabled `auto-merge` in Pull Request",
"Disabled `auto-merge` in Pull Request\n\n" + detailCommands,
);
break;
// `/merge help`
case "help":
await this.commentsApi.comment(
"## Auto-Merge-Bot\n" + botCommands,
"## Auto-Merge-Bot\n\n" + "**Available commands**" + botCommands,
true,
);
break;
Expand All @@ -115,7 +120,7 @@ export class Bot {
await this.commentsApi.comment(
"## Auto-Merge-Bot\n" +
`Command \`${command}\` not recognized.\n\n` +
botCommands,
detailCommands,
true,
);
}
Expand Down

0 comments on commit 3031251

Please sign in to comment.