mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
rename onReactionTo to getFirstReaction
This commit is contained in:
parent
1a65122b0d
commit
7ee3ce1dd2
@ -9,7 +9,7 @@ import { MatrixClient } from "matrix-bot-sdk";
|
||||
* @param targetEventThunk A function that produces an event ID when called. This event ID is then used to listen for a reaction.
|
||||
* @returns The reaction event.
|
||||
*/
|
||||
export async function onReactionTo(client: MatrixClient, targetRoom: string, reactionKey: string, targetEventThunk: () => Promise<string>): Promise<any> {
|
||||
export async function getFirstReaction(client: MatrixClient, targetRoom: string, reactionKey: string, targetEventThunk: () => Promise<string>): Promise<any> {
|
||||
let reactionEvents = [];
|
||||
const addEvent = function (roomId, event) {
|
||||
if (roomId !== targetRoom) return;
|
||||
|
@ -4,7 +4,7 @@ import config from "../../../src/config";
|
||||
import { newTestUser } from "../clientHelper";
|
||||
import { getMessagesByUserIn } from "../../../src/utils";
|
||||
import { LogService } from "matrix-bot-sdk";
|
||||
import { onReactionTo } from "./commandUtils";
|
||||
import { getFirstReaction } from "./commandUtils";
|
||||
|
||||
describe("Test: The redaction command", function () {
|
||||
it('Mjölnir redacts all of the events sent by a spammer when instructed to by giving their id and a room id.', async function() {
|
||||
@ -34,7 +34,7 @@ import { onReactionTo } from "./commandUtils";
|
||||
|
||||
try {
|
||||
moderator.start();
|
||||
await onReactionTo(moderator, this.mjolnir.managementRoomId, '✅', async () => {
|
||||
await getFirstReaction(moderator, this.mjolnir.managementRoomId, '✅', async () => {
|
||||
return await moderator.sendMessage(this.mjolnir.managementRoomId, { msgtype: 'm.text', body: `!mjolnir redact ${badUserId} ${targetRoom}` });
|
||||
});
|
||||
} finally {
|
||||
@ -81,7 +81,7 @@ import { onReactionTo } from "./commandUtils";
|
||||
|
||||
try {
|
||||
moderator.start();
|
||||
await onReactionTo(moderator, this.mjolnir.managementRoomId, '✅', async () => {
|
||||
await getFirstReaction(moderator, this.mjolnir.managementRoomId, '✅', async () => {
|
||||
return await moderator.sendMessage(this.mjolnir.managementRoomId, { msgtype: 'm.text', body: `!mjolnir redact ${badUserId}` });
|
||||
});
|
||||
} finally {
|
||||
@ -117,7 +117,7 @@ import { onReactionTo } from "./commandUtils";
|
||||
|
||||
try {
|
||||
moderator.start();
|
||||
await onReactionTo(moderator, this.mjolnir.managementRoomId, '✅', async () => {
|
||||
await getFirstReaction(moderator, this.mjolnir.managementRoomId, '✅', async () => {
|
||||
return await moderator.sendMessage(this.mjolnir.managementRoomId, {msgtype: 'm.text', body: `!mjolnir redact https://matrix.to/#/${encodeURIComponent(targetRoom)}/${encodeURIComponent(eventToRedact)}`});
|
||||
});
|
||||
} finally {
|
||||
|
Loading…
Reference in New Issue
Block a user