From 2d517079d9d9f9e5510ac53133e917ddfaf77719 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 14 Sep 2017 16:08:51 -0600 Subject: [PATCH] Add unresponsive /ignore and /unignore commands Signed-off-by: Travis Ralston --- src/SlashCommands.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/SlashCommands.js b/src/SlashCommands.js index e5378d4347..b72ea341b5 100644 --- a/src/SlashCommands.js +++ b/src/SlashCommands.js @@ -240,6 +240,35 @@ const commands = { return reject(this.getUsage()); }), + ignore: new Command("ignore", "", function(roomId, args) { + if (args) { + const matches = args.match(/^(\S+)$/); + if (matches) { + const ignoredUsers = MatrixClientPeg.get().getIgnoredUsers(); + ignoredUsers.push(matches[1]); // de-duped internally below + return success( + MatrixClientPeg.get().setIgnoredUsers(ignoredUsers), + ); + } + } + return reject(this.getUsage()); + }), + + unignore: new Command("unignore", "", function(roomId, args) { + if (args) { + const matches = args.match(/^(\S+)$/); + if (matches) { + const ignoredUsers = MatrixClientPeg.get().getIgnoredUsers(); + const index = ignoredUsers.indexOf(matches[1]); + if (index !== -1) ignoredUsers.splice(index, 1); + return success( + MatrixClientPeg.get().setIgnoredUsers(ignoredUsers), + ); + } + } + return reject(this.getUsage()); + }), + // Define the power level of a user op: new Command("op", " []", function(roomId, args) { if (args) {