add appservice listener
This commit is contained in:
parent
740ddc36d1
commit
d70199f890
4 changed files with 23 additions and 1 deletions
5
index.js
5
index.js
|
@ -16,6 +16,11 @@ 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")
|
||||
|
|
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("heatsync")} sync
|
||||
* @property {import("better-sqlite3/lib/database")} db
|
||||
* @property {import("matrix-appservice").AppService} as
|
||||
*/
|
||||
/** @type {Passthrough} */
|
||||
// @ts-ignore
|
||||
|
|
Loading…
Reference in a new issue