How to use the matrix-appservice-bridge.AppServiceRegistration.fromObject function in matrix-appservice-bridge

To help you get started, we’ve selected a few matrix-appservice-bridge 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 / addRoomsToDirectory.ts View on Github external
if (options.help) {
    /* tslint:disable:no-console */
    console.log(usage([
    {
        content: "A tool to set all the bridged rooms to visible in the directory.",
        header: "Add rooms to directory",
    },
    {
        header: "Options",
        optionList: optionDefinitions,
    },
    ]));
    process.exit(0);
}
const yamlConfig = yaml.safeLoad(fs.readFileSync("./discord-registration.yaml", "utf8"));
const registration = AppServiceRegistration.fromObject(yamlConfig);
const config: DiscordBridgeConfig = yaml.safeLoad(fs.readFileSync(options.config, "utf8")) as DiscordBridgeConfig;

if (registration === null) {
    throw new Error("Failed to parse registration file");
}

const clientFactory = new ClientFactory({
    appServiceUserId: `@${registration.sender_localpart}:${config.bridge.domain}`,
    token: registration.as_token,
    url: config.bridge.homeserverUrl,
});

const bridge = new Bridge({
    controller: {
        onEvent: () => { },
    },
github Half-Shot / matrix-appservice-discord / tools / chanfix.ts View on Github external
console.log(usage([
    {
        content: "A tool to fix channels of rooms already bridged " +
        "to matrix, to make sure their names, icons etc. are correctly.",
        header: "Fix bridged channels",
    },
    {
        header: "Options",
        optionList: optionDefinitions,
    },
    ]));
    process.exit(0);
}

const yamlConfig = yaml.safeLoad(fs.readFileSync("./discord-registration.yaml", "utf8"));
const registration = AppServiceRegistration.fromObject(yamlConfig);
const config = new DiscordBridgeConfig();
config.applyConfig(yaml.safeLoad(fs.readFileSync(options.config, "utf8")) as DiscordBridgeConfig);
config.applyEnvironmentOverrides(process.env);

if (registration === null) {
    throw new Error("Failed to parse registration file");
}

const botUserId = `@${registration.sender_localpart}:${config.bridge.domain}`;
const clientFactory = new ClientFactory({
    appServiceUserId: botUserId,
    token: registration.as_token,
    url: config.bridge.homeserverUrl,
});

const bridge = new Bridge({
github Half-Shot / matrix-appservice-discord / tools / adminme.ts View on Github external
]));
    process.exit(0);
}

if (!options.roomid) {
    console.error("Missing roomid parameter. Check -h");
    process.exit(1);
}

if (!options.userid) {
    console.error("Missing userid parameter. Check -h");
    process.exit(1);
}

const yamlConfig = yaml.safeLoad(fs.readFileSync("discord-registration.yaml", "utf8"));
const registration = AppServiceRegistration.fromObject(yamlConfig);
const config: DiscordBridgeConfig = yaml.safeLoad(fs.readFileSync(options.config, "utf8")) as DiscordBridgeConfig;

if (registration === null) {
    throw new Error("Failed to parse registration file");
}

const clientFactory = new ClientFactory({
    appServiceUserId: `@${registration.sender_localpart}:${config.bridge.domain}`,
    token: registration.as_token,
    url: config.bridge.homeserverUrl,
});
const client = clientFactory.getClientAs();
const intent = new Intent(client, client, {registered: true});

async function run() {
    try {
github Half-Shot / matrix-appservice-discord / tools / ghostfix.ts View on Github external
console.log(usage([
    {
        content: "A tool to fix usernames of ghosts already in " +
        "matrix rooms, to make sure they represent the correct discord usernames.",
        header: "Fix usernames of joined ghosts",
    },
    {
        header: "Options",
        optionList: optionDefinitions,
    },
    ]));
    process.exit(0);
}

const yamlConfig = yaml.safeLoad(fs.readFileSync("./discord-registration.yaml", "utf8"));
const registration = AppServiceRegistration.fromObject(yamlConfig);
const config = new DiscordBridgeConfig();
config.applyConfig(yaml.safeLoad(fs.readFileSync(options.config, "utf8")) as DiscordBridgeConfig);
config.applyEnvironmentOverrides(process.env);

if (registration === null) {
    throw new Error("Failed to parse registration file");
}

const botUserId = `@${registration.sender_localpart}:${config.bridge.domain}`;
const clientFactory = new ClientFactory({
    appServiceUserId: botUserId,
    token: registration.as_token,
    url: config.bridge.homeserverUrl,
});

const bridge = new Bridge({
github Half-Shot / matrix-appservice-discord / src / discordas.ts View on Github external
async function run(port: number, fileConfig: DiscordBridgeConfig) {
    const config = new DiscordBridgeConfig();
    config.applyConfig(fileConfig);
    config.applyEnvironmentOverrides(process.env);
    Log.Configure(config.logging);
    log.info("Starting Discord AS");
    const yamlConfig = yaml.safeLoad(fs.readFileSync(cli.opts.registrationPath, "utf8"));
    const registration = AppServiceRegistration.fromObject(yamlConfig);
    if (registration === null) {
        throw new Error("Failed to parse registration file");
    }

    const botUserId = `@${registration.sender_localpart}:${config.bridge.domain}`;
    const clientFactory = new ClientFactory({
        appServiceUserId: botUserId,
        token: registration.as_token,
        url: config.bridge.homeserverUrl,
    });
    const store = new DiscordStore(config.database);

    const callbacks: { [id: string]: callbackFn; } = {};

    const bridge = new Bridge({
        clientFactory,
github Half-Shot / matrix-appservice-twitter / twitter-as.js View on Github external
run: function (port, config) {

        //Read registration file

    var regObj = yaml.safeLoad(fs.readFileSync("twitter-registration.yaml", 'utf8'));
    regObj = AppServiceRegistration.fromObject(regObj);
    if (regObj === null) {
      throw new Error("Failed to parse registration file");
    }

    var room_handler;

    var clientFactory = new ClientFactory(
      {
        sdk: require("matrix-js-sdk"),
        url: config.bridge.homeserverUrl,
        token: regObj.as_token,
        appServiceUserId: "@" + regObj.sender_localpart + ":" + config.bridge.domain
      }
        );

    bridge = new Bridge({