From 4465d2ddaffbd0174831225f34553e6ecd895b33 Mon Sep 17 00:00:00 2001 From: Nabhag Motivaras Date: Tue, 21 Mar 2023 01:44:56 +0530 Subject: [PATCH] feat: added /notion help & helperMessage --- oauth2/commands/NotionCommand.ts | 6 ++++++ oauth2/enums/cmdparams.ts | 3 ++- oauth2/lib/helperMessage.ts | 35 ++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 oauth2/lib/helperMessage.ts diff --git a/oauth2/commands/NotionCommand.ts b/oauth2/commands/NotionCommand.ts index 43aa569..0a776df 100644 --- a/oauth2/commands/NotionCommand.ts +++ b/oauth2/commands/NotionCommand.ts @@ -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 { @@ -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); } } } diff --git a/oauth2/enums/cmdparams.ts b/oauth2/enums/cmdparams.ts index f1d0175..27bb8f6 100644 --- a/oauth2/enums/cmdparams.ts +++ b/oauth2/enums/cmdparams.ts @@ -2,4 +2,5 @@ export enum CmdParameters { LOGIN = "login", LOGOUT = "logout", TEST = "test", -} \ No newline at end of file + HELP = "help", +} diff --git a/oauth2/lib/helperMessage.ts b/oauth2/lib/helperMessage.ts new file mode 100644 index 0000000..d3d5fbd --- /dev/null +++ b/oauth2/lib/helperMessage.ts @@ -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()); +}