2024-09-14 12:50:00 +00:00
|
|
|
#!/usr/bin/env node
|
2023-04-25 20:06:08 +00:00
|
|
|
// @ts-check
|
|
|
|
|
2023-05-04 20:25:00 +00:00
|
|
|
const sqlite = require("better-sqlite3")
|
2024-09-12 05:11:35 +00:00
|
|
|
const migrate = require("./src/db/migrate")
|
2023-03-05 16:05:35 +00:00
|
|
|
const HeatSync = require("heatsync")
|
2022-12-07 00:10:31 +00:00
|
|
|
|
2024-09-13 11:47:11 +00:00
|
|
|
const {reg} = require("./src/matrix/read-registration")
|
2024-09-12 05:11:35 +00:00
|
|
|
const passthrough = require("./src/passthrough")
|
|
|
|
const db = new sqlite("src/db/ooye.db")
|
2023-03-05 16:05:35 +00:00
|
|
|
|
2024-08-26 14:17:10 +00:00
|
|
|
/** @type {import("heatsync").default} */ // @ts-ignore
|
2023-03-05 16:05:35 +00:00
|
|
|
const sync = new HeatSync()
|
|
|
|
|
2024-09-13 11:47:11 +00:00
|
|
|
Object.assign(passthrough, {sync, db})
|
2023-03-05 16:05:35 +00:00
|
|
|
|
2024-09-12 05:11:35 +00:00
|
|
|
const DiscordClient = require("./src/d2m/discord-client")
|
2022-12-07 00:10:31 +00:00
|
|
|
|
2024-09-13 11:47:11 +00:00
|
|
|
const discord = new DiscordClient(reg.ooye.discord_token)
|
2023-03-05 16:05:35 +00:00
|
|
|
passthrough.discord = discord
|
|
|
|
|
2024-09-12 05:11:35 +00:00
|
|
|
const {as} = require("./src/matrix/appservice")
|
2023-06-28 20:08:17 +00:00
|
|
|
passthrough.as = as
|
|
|
|
|
2024-09-12 05:11:35 +00:00
|
|
|
const orm = sync.require("./src/db/orm")
|
2023-09-14 00:32:27 +00:00
|
|
|
passthrough.from = orm.from
|
|
|
|
passthrough.select = orm.select
|
|
|
|
|
2024-09-12 05:11:35 +00:00
|
|
|
const power = require("./src/matrix/power.js")
|
2024-09-13 11:47:11 +00:00
|
|
|
sync.require("./src/m2d/event-dispatcher")
|
2023-06-28 20:08:17 +00:00
|
|
|
|
2023-03-05 16:05:35 +00:00
|
|
|
;(async () => {
|
2023-09-30 12:24:05 +00:00
|
|
|
await migrate.migrate(db)
|
2023-03-05 16:05:35 +00:00
|
|
|
await discord.cloud.connect()
|
|
|
|
console.log("Discord gateway started")
|
2024-09-12 15:16:03 +00:00
|
|
|
sync.require("./src/web/server")
|
2024-08-27 14:53:27 +00:00
|
|
|
await power.applyPower()
|
2023-03-05 16:05:35 +00:00
|
|
|
|
2024-09-12 05:11:35 +00:00
|
|
|
require("./src/stdin")
|
2023-03-05 16:05:35 +00:00
|
|
|
})()
|