mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-09-29 20:56:23 +00:00
this doesn't need to be global
This commit is contained in:
parent
a9df41c37d
commit
d845612f51
38
src/index.ts
38
src/index.ts
@ -40,24 +40,26 @@ if (config.health.healthz.enabled) {
|
|||||||
Healthz.listen();
|
Healthz.listen();
|
||||||
}
|
}
|
||||||
|
|
||||||
let bot: Mjolnir | null = null;
|
|
||||||
(async function () {
|
(async function () {
|
||||||
const storagePath = path.isAbsolute(config.dataPath) ? config.dataPath : path.join(__dirname, '../', config.dataPath);
|
let bot: Mjolnir | null = null;
|
||||||
const storage = new SimpleFsStorageProvider(path.join(storagePath, "bot.json"));
|
try {
|
||||||
|
const storagePath = path.isAbsolute(config.dataPath) ? config.dataPath : path.join(__dirname, '../', config.dataPath);
|
||||||
|
const storage = new SimpleFsStorageProvider(path.join(storagePath, "bot.json"));
|
||||||
|
|
||||||
let client: MatrixClient;
|
let client: MatrixClient;
|
||||||
if (config.pantalaimon.use) {
|
if (config.pantalaimon.use) {
|
||||||
const pantalaimon = new PantalaimonClient(config.homeserverUrl, storage);
|
const pantalaimon = new PantalaimonClient(config.homeserverUrl, storage);
|
||||||
client = await pantalaimon.createClientWithCredentials(config.pantalaimon.username, config.pantalaimon.password);
|
client = await pantalaimon.createClientWithCredentials(config.pantalaimon.username, config.pantalaimon.password);
|
||||||
} else {
|
} else {
|
||||||
client = new MatrixClient(config.homeserverUrl, config.accessToken, storage);
|
client = new MatrixClient(config.homeserverUrl, config.accessToken, storage);
|
||||||
|
}
|
||||||
|
patchMatrixClient();
|
||||||
|
config.RUNTIME.client = client;
|
||||||
|
|
||||||
|
bot = await Mjolnir.setupMjolnirFromConfig(client);
|
||||||
|
await bot.start();
|
||||||
|
} catch (err) {
|
||||||
|
bot?.logMessage(LogLevel.ERROR, "index", err);
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
patchMatrixClient();
|
})();
|
||||||
config.RUNTIME.client = client;
|
|
||||||
|
|
||||||
bot = await Mjolnir.setupMjolnirFromConfig(client);
|
|
||||||
await bot.start();
|
|
||||||
})().catch(err => {
|
|
||||||
bot?.logMessage(LogLevel.ERROR, "index", err);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
|
Loading…
Reference in New Issue
Block a user