add appservice listener
This commit is contained in:
parent
740ddc36d1
commit
d70199f890
4 changed files with 23 additions and 1 deletions
7
index.js
7
index.js
|
@ -9,13 +9,18 @@ const db = new sqlite("db/ooye.db")
|
||||||
|
|
||||||
const sync = new HeatSync()
|
const sync = new HeatSync()
|
||||||
|
|
||||||
Object.assign(passthrough, { config, sync, db })
|
Object.assign(passthrough, {config, sync, db})
|
||||||
|
|
||||||
const DiscordClient = require("./d2m/discord-client")
|
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
8
m2d/appservice.js
Normal 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
8
m2d/event-dispatcher.js
Normal 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)
|
||||||
|
})
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue