Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 56bd16dfdffbd8b8ff1413f3d015daa132ae19f0
  • master par défaut
  • 1-baka-export
  • meson
  • assdraw
  • old-master
  • v3.2.2
  • v3.2.1
  • v3.2.0
  • v3.1.3
  • v3.1.2
  • v3.1.1
  • v3.1.0
  • v3.0.4
  • v3.0.3
  • v3.0.2
  • v3.0.1
  • v3.0.0
  • v2.1.3
  • v2.1.4
  • v2.1.5
  • v2.1.6
  • v2.1.0
  • v2.1.1
  • v2.1.2
  • v2.1.7
26 résultats

git_version.h

Blame
  • toolshelper.ts 1,39 Kio
    import { DiscordBridgeConfig } from "../src/config";
    import { Appservice } from "matrix-bot-sdk";
    import { DiscordStore } from "../src/store";
    import * as yaml from "js-yaml";
    import * as fs from "fs";
    
    export class ToolsHelper {
        public static getToolDependencies(
            configFile: string, regFile: string = "./discord-registration.yaml", needsStore: boolean = true): {
            store: DiscordStore|null,
            appservice: Appservice,
            config: DiscordBridgeConfig,
        } {
            const registration = yaml.safeLoad(fs.readFileSync(regFile, "utf8"));
            const config: DiscordBridgeConfig = Object.assign(
                new DiscordBridgeConfig(), yaml.safeLoad(fs.readFileSync(configFile, "utf8")));
            config.applyEnvironmentOverrides(process.env);
            if (registration === null) {
                throw Error("Failed to parse registration file");
            }
    
            const appservice = new Appservice({
                bindAddress: "notathing",
                homeserverName: config.bridge.domain,
                homeserverUrl: config.bridge.homeserverUrl,
                port: 0,
                // We assume the registration is well formed
                registration: registration as any,
            });
    
            const store = needsStore ? new DiscordStore(config.database ? config.database.filename : "discord.db") : null;
            return {
                appservice,
                config,
                store,
            };
        }
    }