Created
August 23, 2022 21:02
-
-
Save debdutdeb/4fcb5fa6e4082f361aa9022572f9c107 to your computer and use it in GitHub Desktop.
Example app for archiving a room, pr https://github.com/RocketChat/Rocket.Chat.Apps-engine/pull/535 & https://github.com/RocketChat/Rocket.Chat/pull/26317
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
IRead, | |
IModify, | |
IHttp, | |
IPersistence, | |
} from "@rocket.chat/apps-engine/definition/accessors"; | |
import { | |
ISlashCommand, | |
SlashCommandContext, | |
} from "@rocket.chat/apps-engine/definition/slashcommands"; | |
export class ArchiveCommand implements ISlashCommand { | |
public command: string = "archivea"; | |
public i18nParamsExample: string = ""; | |
public i18nDescription: string = ""; | |
public providesPreview: boolean = false; | |
public async executor( | |
context: SlashCommandContext, | |
read: IRead, | |
modify: IModify, | |
http: IHttp, | |
persis: IPersistence | |
): Promise<void> { | |
const success = await modify | |
.getUpdater() | |
.getRoomUpdater() | |
.archiveRoom(context.getRoom()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
IAppAccessors, | |
IConfigurationExtend, | |
IEnvironmentRead, | |
ILogger, | |
} from "@rocket.chat/apps-engine/definition/accessors"; | |
import { App } from "@rocket.chat/apps-engine/definition/App"; | |
import { IAppInfo } from "@rocket.chat/apps-engine/definition/metadata"; | |
import { ArchiveCommand } from "./commands/ArchiveCommand"; | |
export class ArchiveRoomApp extends App { | |
constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) { | |
super(info, logger, accessors); | |
} | |
protected async extendConfiguration( | |
configuration: IConfigurationExtend, | |
environmentRead: IEnvironmentRead | |
): Promise<void> { | |
await configuration.slashCommands.provideSlashCommand( | |
new ArchiveCommand() | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment