mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-10-22 09:01:59 +00:00
Add commands for managing a personal ban list
This commit is contained in:
1 parent
41cc36e4c6
commit
39b59dbee1
10 files changed
+122
-9
No files matched your search
@@ -26,6 +26,13 @@ export const ROOM_RULE_TYPES = [RULE_ROOM, "org.matrix.mjolnir.rule.room"];
|
||||
export const SERVER_RULE_TYPES = [RULE_SERVER, "org.matrix.mjolnir.rule.server"];
|
||||
export const ALL_RULE_TYPES = [...USER_RULE_TYPES, ...ROOM_RULE_TYPES, ...SERVER_RULE_TYPES];
|
||||
|
||||
export function ruleTypeToStable(rule: string, unstable = true): string {
|
||||
if (USER_RULE_TYPES.includes(rule)) return unstable ? USER_RULE_TYPES[USER_RULE_TYPES.length - 1] : RULE_USER;
|
||||
if (ROOM_RULE_TYPES.includes(rule)) return unstable ? ROOM_RULE_TYPES[ROOM_RULE_TYPES.length - 1] : RULE_ROOM;
|
||||
if (SERVER_RULE_TYPES.includes(rule)) return unstable ? SERVER_RULE_TYPES[SERVER_RULE_TYPES.length - 1] : RULE_SERVER;
|
||||
return null;
|
||||
}
|
||||
|
||||
export default class BanList {
|
||||
private rules: ListRule[] = [];
|
||||
|
||||
|
||||
@@ -19,6 +19,11 @@ import { MatrixGlob } from "matrix-bot-sdk/lib/MatrixGlob";
|
||||
export const RECOMMENDATION_BAN = "m.ban";
|
||||
export const RECOMMENDATION_BAN_TYPES = [RECOMMENDATION_BAN, "org.matrix.mjolnir.ban"];
|
||||
|
||||
export function recommendationToStable(recommendation: string, unstable = true): string {
|
||||
if (RECOMMENDATION_BAN_TYPES.includes(recommendation)) return unstable ? RECOMMENDATION_BAN_TYPES[RECOMMENDATION_BAN_TYPES.length - 1] : RECOMMENDATION_BAN;
|
||||
return null;
|
||||
}
|
||||
|
||||
export class ListRule {
|
||||
|
||||
private glob: MatrixGlob;
|
||||
|
||||
Reference in new issue
Block a user