Skip to content

Commit

Permalink
updated code to work with latest
Browse files Browse the repository at this point in the history
Code types have changed and now they use `Enums`
  • Loading branch information
Bullrich committed Sep 9, 2024
1 parent 31bdf67 commit 074219d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/bot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { logger } from "#src/logger";
import { getNetworkData } from "#src/papi/index";
import { isAccountPrivileged } from "#src/utils";
import * as mSDK from "matrix-js-sdk";
import { TimelineEvents } from "matrix-js-sdk";
import { AccountId } from "polkadot-api";

const dripRequestHandler = getDripRequestHandlerInstance(polkadotActions);
Expand Down Expand Up @@ -38,20 +39,22 @@ const bot = mSDK.createClient({
});

const sendMessage = (roomId: string, msg: string, formattedMsg?: string) => {
const msgObject: mSDK.IContent = { body: msg, msgtype: "m.text" };
const msgObject: TimelineEvents[mSDK.EventType.RoomMessage] = { body: msg, msgtype: mSDK.MsgType.Text };

if (formattedMsg !== undefined) {
msgObject.format = "org.matrix.custom.html";
msgObject.formatted_body = formattedMsg;
}

bot.sendEvent(roomId, null, "m.room.message", msgObject, "").catch((e) => logger.error(e));
bot.sendEvent(roomId, null, mSDK.EventType.RoomMessage, msgObject, "").catch((e) => logger.error(e));
};

const sendReaction = (roomId: string, eventId: string, emoji: string) => {
const msgObject: mSDK.IContent = { "m.relates_to": { event_id: eventId, key: emoji, rel_type: "m.annotation" } };
const msgObject: TimelineEvents[mSDK.EventType.Reaction] = {
"m.relates_to": { event_id: eventId, key: emoji, rel_type: mSDK.RelationType.Annotation },
};

bot.sendEvent(roomId, null, "m.reaction", msgObject, "").catch((e) => logger.error(e));
bot.sendEvent(roomId, null, mSDK.EventType.Reaction, msgObject, "").catch((e) => logger.error(e));
};

const printHelpMessage = (roomId: string, message = "") =>
Expand Down

0 comments on commit 074219d

Please sign in to comment.