diff --git a/index.js b/index.js index 807b49f..f4c59c6 100644 --- a/index.js +++ b/index.js @@ -9,13 +9,18 @@ const db = new sqlite("db/ooye.db") const sync = new HeatSync() -Object.assign(passthrough, { config, sync, db }) +Object.assign(passthrough, {config, sync, db}) const DiscordClient = require("./d2m/discord-client") const discord = new DiscordClient(config.discordToken) passthrough.discord = discord +const as = require("./m2d/appservice") +passthrough.as = as + +sync.require("./m2d/event-dispatcher") + ;(async () => { await discord.cloud.connect() console.log("Discord gateway started") diff --git a/m2d/appservice.js b/m2d/appservice.js new file mode 100644 index 0000000..e99a822 --- /dev/null +++ b/m2d/appservice.js @@ -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 diff --git a/m2d/event-dispatcher.js b/m2d/event-dispatcher.js new file mode 100644 index 0000000..136aae0 --- /dev/null +++ b/m2d/event-dispatcher.js @@ -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) +}) diff --git a/passthrough.js b/passthrough.js index 8ef75db..16de1bb 100644 --- a/passthrough.js +++ b/passthrough.js @@ -7,6 +7,7 @@ * @property {import("./d2m/discord-client")} discord * @property {import("heatsync")} sync * @property {import("better-sqlite3/lib/database")} db + * @property {import("matrix-appservice").AppService} as */ /** @type {Passthrough} */ // @ts-ignore