Commit 748e29c6 authored by Grant's avatar Grant
Browse files

add alive ping to matrix

parent e5a82376
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -9,3 +9,7 @@ Discord.login(process.env.DISCORD_TOKEN);
Matrix.for("_discord_bot").then(() => {
  console.log("_discord_bot registered");
});

Matrix.sendAlivePing().then((data) => {
  console.log("Alive ping result", data);
});
+8 −0
Original line number Diff line number Diff line
@@ -450,6 +450,14 @@ export class Matrix {
      .map((match) => match?.[0])
      .filter((a) => a) as any;
  }

  static async sendAlivePing() {
    return await this.fetch(
      `/_matrix/client/v1/appservice/${process.env.MATRIX_AS_ID}/ping`,
      "POST",
      {}
    );
  }
}

type IUsername = `_discord_${string}`;
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ class MatrixHandler_ {

    for (const event of events) {
      console.log("[Matrix->]", event);

      switch (event.type) {
        case "m.room.member": {
          const event2: MatrixRoomMembership = event as any;
+4 −0
Original line number Diff line number Diff line
@@ -6,6 +6,10 @@ declare global {
       * Outgoing token (-> matrix)
       */
      MATRIX_AS_TOKEN: string;
      /**
       * What AS identifier we're registered as
       */
      MATRIX_AS_ID: string;
      /**
       * Incoming token (-> express)
       */