1
0
Fork 0

add appservice listener

This commit is contained in:
Cadence Ember 2023-06-29 08:08:17 +12:00
parent 740ddc36d1
commit d70199f890
4 changed files with 23 additions and 1 deletions

View file

@ -16,6 +16,11 @@ const DiscordClient = require("./d2m/discord-client")
const discord = new DiscordClient(config.discordToken) const discord = new DiscordClient(config.discordToken)
passthrough.discord = discord passthrough.discord = discord
const as = require("./m2d/appservice")
passthrough.as = as
sync.require("./m2d/event-dispatcher")
;(async () => { ;(async () => {
await discord.cloud.connect() await discord.cloud.connect()
console.log("Discord gateway started") console.log("Discord gateway started")

8
m2d/appservice.js Normal file
View file

@ -0,0 +1,8 @@
const reg = require("../matrix/read-registration")
const AppService = require("matrix-appservice").AppService
const as = new AppService({
homeserverToken: reg.hs_token
})
as.listen(+(new URL(reg.url).port))
module.exports = as

8
m2d/event-dispatcher.js Normal file
View file

@ -0,0 +1,8 @@
const assert = require("assert").strict
const {sync, as} = require("../passthrough")
// Grab Matrix events we care about for the bridge, check them, and pass them on
sync.addTemporaryListener(as, "type:m.room.message", event => {
console.log(event)
})

View file

@ -7,6 +7,7 @@
* @property {import("./d2m/discord-client")} discord * @property {import("./d2m/discord-client")} discord
* @property {import("heatsync")} sync * @property {import("heatsync")} sync
* @property {import("better-sqlite3/lib/database")} db * @property {import("better-sqlite3/lib/database")} db
* @property {import("matrix-appservice").AppService} as
*/ */
/** @type {Passthrough} */ /** @type {Passthrough} */
// @ts-ignore // @ts-ignore