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

To help you get started, we’ve selected a few matrix-appservice 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 matrix-org / matrix-appservice-bridge / lib / bridge.js View on Github external
Bridge.prototype.run = function(port, config, appServiceInstance, hostname) {
    var self = this;

    // Load the registration file into an AppServiceRegistration object.
    if (typeof self.opts.registration === "string") {
        var regObj = yaml.safeLoad(fs.readFileSync(self.opts.registration, 'utf8'));
        self.opts.registration = AppServiceRegistration.fromObject(regObj);
        if (self.opts.registration === null) {
            throw new Error("Failed to parse registration file");
        }
    }

    this._clientFactory = self.opts.clientFactory || new ClientFactory({
        url: self.opts.homeserverUrl,
        token: self.opts.registration.as_token,
        appServiceUserId: (
            "@" + self.opts.registration.sender_localpart + ":" + self.opts.domain
        ),
        clientSchedulerBuilder: function() {
            return new MatrixScheduler(retryAlgorithm, queueAlgorithm);
        },
    });
    this._clientFactory.setLogFunction(function(text, isErr) {
github matrix-org / matrix-appservice-bridge / spec / integ / bridge.spec.js View on Github external
if (!appService._events[name]) {
                appService._events[name] = [];
            }
            appService._events[name].push(fn);
        });
        appService.emit = function(name, obj) {
            var list = appService._events[name] || [];
            var promises = list.map(function(fn) {
                return fn(obj);
            });
            return Promise.all(promises);
        };
        bridgeCtrl = jasmine.createSpyObj("controller", [
            "onEvent", "onAliasQuery", "onUserQuery"
        ]);
        appServiceRegistration = AppServiceRegistration.fromObject({
            id: "an_id",
            hs_token: "h5_t0k3n",
            as_token: "a5_t0k3n",
            url: "http://app-service-url",
            sender_localpart: BOT_LOCALPART,
            namespaces: {
                users: [{
                    exclusive: true,
                    regex: "@virtual_.*"
                }],
                aliases: [{
                    exclusive: true,
                    regex: "#virtual_.*"
                }]
            }
        });
github matrix-org / matrix-appservice-bridge / lib / components / cli.js View on Github external
Cli.prototype._startWithConfig = function(config) {
    this.opts.run(
        this.opts.port, config,
        AppServiceRegistration.fromObject(this._loadYaml(this.opts.registrationPath))
    );
};