mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
requested changes
This commit is contained in:
parent
3aad2c5dd2
commit
cee8ce308b
@ -485,7 +485,7 @@ export class Mjolnir {
|
|||||||
return await this.client.doRequest("PUT", endpoint, null, body);
|
return await this.client.doRequest("PUT", endpoint, null, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async unSuspendSynapseUser(userId: string): Promise<any> {
|
public async unsuspendSynapseUser(userId: string): Promise<any> {
|
||||||
const endpoint = `/_synapse/admin/v1/suspend/${userId}`;
|
const endpoint = `/_synapse/admin/v1/suspend/${userId}`;
|
||||||
const body = {"suspend": false}
|
const body = {"suspend": false}
|
||||||
return await this.client.doRequest("PUT", endpoint, null, body);
|
return await this.client.doRequest("PUT", endpoint, null, body);
|
||||||
|
@ -44,7 +44,7 @@ import { parse as tokenize } from "shell-quote";
|
|||||||
import { execSinceCommand } from "./SinceCommand";
|
import { execSinceCommand } from "./SinceCommand";
|
||||||
import { execSetupProtectedRoom } from "./SetupDecentralizedReportingCommand";
|
import { execSetupProtectedRoom } from "./SetupDecentralizedReportingCommand";
|
||||||
import {execSuspendCommand} from "./SuspendCommand";
|
import {execSuspendCommand} from "./SuspendCommand";
|
||||||
import {execUnSuspendCommand} from "./unSuspendCommand";
|
import {execUnsuspendCommand} from "./UnsuspendCommand";
|
||||||
|
|
||||||
|
|
||||||
export const COMMAND_PREFIX = "!mjolnir";
|
export const COMMAND_PREFIX = "!mjolnir";
|
||||||
@ -133,7 +133,7 @@ export async function handleCommand(roomId: string, event: { content: { body: st
|
|||||||
} else if (parts[1] === 'suspend' && parts.length > 2) {
|
} else if (parts[1] === 'suspend' && parts.length > 2) {
|
||||||
return await execSuspendCommand(roomId, event, mjolnir, parts);
|
return await execSuspendCommand(roomId, event, mjolnir, parts);
|
||||||
} else if (parts[1] === 'unsuspend' && parts.length > 2) {
|
} else if (parts[1] === 'unsuspend' && parts.length > 2) {
|
||||||
return await execUnSuspendCommand(roomId, event, mjolnir, parts)
|
return await execUnsuspendCommand(roomId, event, mjolnir, parts)
|
||||||
} else {
|
} else {
|
||||||
// Help menu
|
// Help menu
|
||||||
const menu = "" +
|
const menu = "" +
|
||||||
@ -176,10 +176,8 @@ export async function handleCommand(roomId: string, event: { content: { body: st
|
|||||||
"!mjolnir shutdown room <room alias/ID> [message] - Uses the bot's account to shut down a room, preventing access to the room on this server\n" +
|
"!mjolnir shutdown room <room alias/ID> [message] - Uses the bot's account to shut down a room, preventing access to the room on this server\n" +
|
||||||
"!mjolnir powerlevel <user ID> <power level> [room alias/ID] - Sets the power level of the user in the specified room (or all protected rooms)\n" +
|
"!mjolnir powerlevel <user ID> <power level> [room alias/ID] - Sets the power level of the user in the specified room (or all protected rooms)\n" +
|
||||||
"!mjolnir make admin <room alias> [user alias/ID] - Make the specified user or the bot itself admin of the room\n" +
|
"!mjolnir make admin <room alias> [user alias/ID] - Make the specified user or the bot itself admin of the room\n" +
|
||||||
"!mjolnir suspend <user ID> - Suspend the specified user"
|
"!mjolnir suspend <user ID> - Suspend the specified user" +
|
||||||
+
|
"!mjolnir unsuspend <user ID> - Unsuspend the specified user" +
|
||||||
"!mjolnir unsuspend <user ID> - Unsuspend the specified user"
|
|
||||||
+
|
|
||||||
"!mjolnir help - This menu\n"
|
"!mjolnir help - This menu\n"
|
||||||
const html = `<b>Mjolnir help:</b><br><pre><code>${htmlEscape(menu)}</code></pre>`;
|
const html = `<b>Mjolnir help:</b><br><pre><code>${htmlEscape(menu)}</code></pre>`;
|
||||||
const text = `Mjolnir help:\n${menu}`;
|
const text = `Mjolnir help:\n${menu}`;
|
||||||
|
@ -18,7 +18,7 @@ import {Mjolnir} from "../Mjolnir";
|
|||||||
import {RichReply} from "matrix-bot-sdk";
|
import {RichReply} from "matrix-bot-sdk";
|
||||||
|
|
||||||
export async function execSuspendCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
|
export async function execSuspendCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
|
||||||
const victim = parts[2];
|
const target = parts[2];
|
||||||
|
|
||||||
const isAdmin = await mjolnir.isSynapseAdmin();
|
const isAdmin = await mjolnir.isSynapseAdmin();
|
||||||
if (!isAdmin) {
|
if (!isAdmin) {
|
||||||
@ -29,8 +29,8 @@ export async function execSuspendCommand(roomId: string, event: any, mjolnir: Mj
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await mjolnir.suspendSynapseUser(victim);
|
await mjolnir.suspendSynapseUser(target);
|
||||||
const msg = `User ${victim} has been suspended.`
|
const msg = `User ${target} has been suspended.`
|
||||||
const confirmation = RichReply.createFor(roomId, event, msg, msg);
|
const confirmation = RichReply.createFor(roomId, event, msg, msg);
|
||||||
confirmation['msgtype'] = "m.notice";
|
confirmation['msgtype'] = "m.notice";
|
||||||
await mjolnir.client.sendMessage(roomId, confirmation)
|
await mjolnir.client.sendMessage(roomId, confirmation)
|
||||||
|
@ -17,8 +17,8 @@ limitations under the License.
|
|||||||
import {Mjolnir} from "../Mjolnir";
|
import {Mjolnir} from "../Mjolnir";
|
||||||
import {RichReply} from "matrix-bot-sdk";
|
import {RichReply} from "matrix-bot-sdk";
|
||||||
|
|
||||||
export async function execUnSuspendCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
|
export async function execUnsuspendCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
|
||||||
const victim = parts[2];
|
const target = parts[2];
|
||||||
|
|
||||||
const isAdmin = await mjolnir.isSynapseAdmin();
|
const isAdmin = await mjolnir.isSynapseAdmin();
|
||||||
if (!isAdmin) {
|
if (!isAdmin) {
|
||||||
@ -29,8 +29,8 @@ export async function execUnSuspendCommand(roomId: string, event: any, mjolnir:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await mjolnir.unSuspendSynapseUser(victim);
|
await mjolnir.unsuspendSynapseUser(target);
|
||||||
const msg = `User ${victim}'s suspension has been reversed.`
|
const msg = `User ${target}'s suspension has been reversed.`
|
||||||
const confirmation = RichReply.createFor(roomId, event, msg, msg);
|
const confirmation = RichReply.createFor(roomId, event, msg, msg);
|
||||||
confirmation['msgtype'] = "m.notice";
|
confirmation['msgtype'] = "m.notice";
|
||||||
mjolnir.client.sendMessage(roomId, confirmation)
|
mjolnir.client.sendMessage(roomId, confirmation)
|
Loading…
Reference in New Issue
Block a user