generateRegistration: function (registration, callback) { registration.setId(AppServiceRegistration.generateToken()); registration.setHomeserverToken(AppServiceRegistration.generateToken()); registration.setAppServiceToken(AppServiceRegistration.generateToken()); registration.setRateLimited(false); // disabled because webhooks can get spammy if (!registration.getSenderLocalpart()) { const config = cli.getConfig(); registration.setSenderLocalpart(config.webhookBot.localpart); } registration.addRegexPattern("users", "@_webhook.*", true); callback(registration); },
const cli = new Cli({ registrationPath: "appservice-registration-webhooks.yaml", enableRegistration: true, enableLocalpart: true, bridgeConfig: { affectsRegistration: true, schema: path.join(__dirname, "config/schema.yml"), defaults: { homeserver: { url: "http://*****:*****@_webhook.*", true); callback(registration); }, run: function (port, config, registration) { LogService.configure(config.logging); LogService.info("index", "Preparing database..."); let bridge = null; WebhookStore.prepare() .then(() => { LogService.info("index", "Preparing bridge..."); bridge = WebhookBridge.init(config, registration); return WebhookBridge.run(port); }) .then(() => { if (config.provisioning.secret !== "CHANGE_ME") WebService.setSharedToken(config.provisioning.secret); else LogService.warn("index", "No provisioning API token is set - the provisioning API will not work for this bridge"); WebService.setApp(bridge.appService.app); return WebService.start(config.web.hookUrlBase); }) .catch(err => { LogService.error("Init", "Failed to start bridge"); throw err; }); } });