From b6123506d43c88f7d1f8fe50ab25ced5c3fd65dc Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 10 Dec 2020 21:00:37 -0700 Subject: [PATCH] Run chat effects on events sent by widgets too --- src/stores/widgets/StopGapWidgetDriver.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/stores/widgets/StopGapWidgetDriver.ts b/src/stores/widgets/StopGapWidgetDriver.ts index 60988040d3..f0746f2f58 100644 --- a/src/stores/widgets/StopGapWidgetDriver.ts +++ b/src/stores/widgets/StopGapWidgetDriver.ts @@ -39,7 +39,10 @@ import WidgetCapabilitiesPromptDialog, { import { WidgetPermissionCustomisations } from "../../customisations/WidgetPermissions"; import { OIDCState, WidgetPermissionStore } from "./WidgetPermissionStore"; import { WidgetType } from "../../widgets/WidgetType"; -import { EventType } from "matrix-js-sdk/src/@types/event"; +import { EventType, MsgType } from "matrix-js-sdk/src/@types/event"; +import { CHAT_EFFECTS } from "../../effects"; +import { containsEmoji } from "../../effects/utils"; +import dis from "../../dispatcher/dispatcher"; // TODO: Purge this from the universe @@ -123,6 +126,14 @@ export class StopGapWidgetDriver extends WidgetDriver { } else { // message event r = await client.sendEvent(roomId, eventType, content); + + if (eventType === EventType.RoomMessage) { + CHAT_EFFECTS.forEach((effect) => { + if (containsEmoji(content, effect.emojis)) { + dis.dispatch({action: `effects.${effect.command}`}); + } + }); + } } return {roomId, eventId: r.event_id};