How to use the matrix-bot-sdk.Appservice function in matrix-bot-sdk

To help you get started, we’ve selected a few matrix-bot-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Half-Shot / matrix-appservice-discord / tools / toolshelper.ts View on Github external
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 = yaml.safeLoad(fs.readFileSync(configFile, "utf8")) as DiscordBridgeConfig;
        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,
            registration,
        });

        const store = needsStore ? new DiscordStore(config.database ? config.database.filename : "discord.db") : null;
        return {
            appservice,
            config,
            store,
        };
    }
}