-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathAccessCommands.tsx
53 lines (48 loc) · 2.05 KB
/
AccessCommands.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Copyright (C) 2022 Gnuxie <[email protected]>
* All rights reserved.
*/
import { defineInterfaceCommand, findTableCommand } from "../../commands/interface-manager/InterfaceCommand";
import { findPresentationType, parameters, ParsedKeywords } from "../../commands/interface-manager/ParameterParsing";
import { AppserviceContext } from "./AppserviceCommandHandler";
import { UserID, ActionResult } from "matrix-protection-suite"
import { defineMatrixInterfaceAdaptor } from "../../commands/interface-manager/MatrixInterfaceAdaptor";
import { tickCrossRenderer } from "../../commands/interface-manager/MatrixHelpRenderer";
defineInterfaceCommand({
designator: ["allow"],
table: "appservice bot",
parameters: parameters([
{
name: 'user',
acceptor: findPresentationType('UserID'),
description: 'The user that should be allowed to provision a bot'
}
]),
command: async function (this: AppserviceContext, _keywords: ParsedKeywords, user: UserID): Promise<ActionResult<void>> {
return await this.appservice.accessControl.allow(user.toString());
},
summary: "Allow a user to provision themselves a draupnir using the appservice."
})
defineMatrixInterfaceAdaptor({
interfaceCommand: findTableCommand("appservice bot", "allow"),
renderer: tickCrossRenderer,
});
defineInterfaceCommand({
designator: ["remove"],
table: "appservice bot",
parameters: parameters([
{
name: 'user',
acceptor: findPresentationType('UserID'),
description: 'The user which shall not be allowed to provision bots anymore'
}
]),
command: async function (this: AppserviceContext, _keywords: ParsedKeywords, user: UserID): Promise<ActionResult<void>> {
return await this.appservice.accessControl.remove(user.toString());
},
summary: "Stop a user from using any provisioned draupnir in the appservice."
})
defineMatrixInterfaceAdaptor({
interfaceCommand: findTableCommand("appservice bot", "remove"),
renderer: tickCrossRenderer,
});