Skip to content

Commit

Permalink
Merge pull request #23 from Nabhag8848/feat/helper
Browse files Browse the repository at this point in the history
[FEAT] added `/notion help`
  • Loading branch information
Nabhag8848 authored Mar 20, 2023
2 parents 903b439 + 4465d2d commit acad50a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
6 changes: 6 additions & 0 deletions oauth2/commands/NotionCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
SlashCommandContext,
} from "@rocket.chat/apps-engine/definition/slashcommands";
import { CmdParameters } from "../enums/cmdparams";
import { helperMessage } from "../lib/helperMessage";
import { OAuth2App } from "../OAuth2App";

export class NotionCommand implements ISlashCommand {
Expand Down Expand Up @@ -41,7 +42,12 @@ export class NotionCommand implements ISlashCommand {
oauth2Instance.test(read, http, modify, persis, context);
break;
}
case CmdParameters.HELP: {
await helperMessage(read, http, modify, persis, context);
break;
}
default: {
await helperMessage(read, http, modify, persis, context);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion oauth2/enums/cmdparams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export enum CmdParameters {
LOGIN = "login",
LOGOUT = "logout",
TEST = "test",
}
HELP = "help",
}
35 changes: 35 additions & 0 deletions oauth2/lib/helperMessage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
IHttp,
IModify,
IPersistence,
IRead,
} from "@rocket.chat/apps-engine/definition/accessors";
import { SlashCommandContext } from "@rocket.chat/apps-engine/definition/slashcommands";

export async function helperMessage(
read: IRead,
http: IHttp,
modify: IModify,
persis: IPersistence,
context: SlashCommandContext
) {
const helperMessage = `:wave: Need some help with \`/notion\`?
Use \`/notion\` to Authorize through 🚀💬 following arguments available:
\xa0\xa0• To login your Notion account \`/notion login\`.
\xa0\xa0• To logout your Notion account \`/notion logout\`.
\xa0\xa0• To check your status of Authorization with Notion \`/notion test\`.
\xa0\xa0• To get help of Usage use \`/notion help\`.
`;

const messageBuilder = modify
.getCreator()
.startMessage()
.setRoom(context.getRoom())
.setGroupable(false)
.setParseUrls(false)
.setText(helperMessage);

await modify
.getNotifier()
.notifyUser(context.getSender(), messageBuilder.getMessage());
}

0 comments on commit acad50a

Please sign in to comment.