How to use the matrix-appservice-bridge.Cli 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 matrix-org / matrix-bifrost / src / Program.ts View on Github external
constructor() {
        this.cli = new Cli({
          bridgeConfig: {
            affectsRegistration: true,
            schema: "./config/config.schema.yaml",
          },
          registrationPath: "purple-registration.yaml",
          generateRegistration: this.generateRegistration,
          run: this.runBridge.bind(this),
        });
        this.cfg = new Config();
        this.deduplicator = new Deduplicator();
        // For testing w/o libpurple.
        // this.purple = new MockPurpleInstance();
        // setTimeout(() => {
        //     (this.purple as MockPurpleInstance).emit("received-im-msg", {
        //         sender: "testacc@localhost/",
        //         message: "test",
github RocketChat / hubot-freddie / src / matrix / genASRegFile.js View on Github external
// Usage:
//
// set the HOMESERVER_SENDER_LOCAL and ROCKETCHAT_USER_PREFIX environment variables
//
// node genASRegFile.js -r -u   # remember to add the registration to the HomeServer!


var Cli = require("matrix-appservice-bridge").Cli;
var Bridge = require("matrix-appservice-bridge").Bridge;
var AppServiceRegistration = require("matrix-appservice-bridge").AppServiceRegistration;

HomeServerSenderLocal = process.env['HOMESERVER_SENDER_LOCAL'] || 'rcbot'
RocketChatUserPrefix = process.env['ROCKETCHAT_USER_PREFIX'] || '@rocketchat_'  // user name prefix for Rocket.Chat users

new Cli({
    registrationPath: "rocketchat-registration.yaml",
    generateRegistration: function(reg, callback) {
        reg.setHomeserverToken(AppServiceRegistration.generateToken());
        reg.setAppServiceToken(AppServiceRegistration.generateToken());
        reg.setSenderLocalpart(HomeServerSenderLocal);
        reg.addRegexPattern("users", RocketChatUserPrefix + ".*", true);
        callback(reg);
    },
    run: function(port, config) {
    }
}).run();
github matrix-hacks / matrix-puppet-facebook / src / index.js View on Github external
const config = require('../config.json');
const { Cli, AppServiceRegistration } = require("matrix-appservice-bridge");
const Puppet = require('./puppet');
const App = require('./app');
const path = require('path');
const puppet = new Puppet(path.join(__dirname, '../config.json' ));

new Cli({
  port: config.port,
  registrationPath: config.registrationPath,
  generateRegistration: function(reg, callback) {
    puppet.associate().then(()=>{
      reg.setId(AppServiceRegistration.generateToken());
      reg.setHomeserverToken(AppServiceRegistration.generateToken());
      reg.setAppServiceToken(AppServiceRegistration.generateToken());
      reg.setSenderLocalpart("groupmebot");
      reg.addRegexPattern("users", "@groupme_.*", true);
      callback(reg);
    }).catch(err=>{
      console.error(err.message);
      process.exit(-1);
    });
  },
  run: function(port) {
github matrix-hacks / matrix-puppet-imessage / bridge.js View on Github external
const storage = nodePersist.create({
  dir:'persist/rooms',
  stringify: JSON.stringify,
  parse: JSON.parse,
  encoding: 'utf8',
  logging: false,
  continuous: true,
  interval: false,
  ttl: false
})
const matrixSdk = require("matrix-js-sdk");
const Promise = require('bluebird');

let lastMsgsFromMyself = [];

new Cli({
  port: config.port,
  registrationPath: config.registrationPath,
  generateRegistration: function(reg, callback) {
    reg.setId(AppServiceRegistration.generateToken());
    reg.setHomeserverToken(AppServiceRegistration.generateToken());
    reg.setAppServiceToken(AppServiceRegistration.generateToken());
    reg.setSenderLocalpart("imessagebot");
    reg.addRegexPattern("users", "@imessage_.*", true);
    callback(reg);
  },
  run: function(port, _config) {
    //console.log(accessDat);
    bridge = new Bridge({
      homeserverUrl: config.bridge.homeserverUrl,
      domain: config.bridge.domain,
      registration: config.bridge.registration,
github huan / matrix-appservice-wechaty / src / matrix-appservice-bridge.ts View on Github external
import {
  Cli,
}         from 'matrix-appservice-bridge'

import {
  generateRegistration,
  run,
}                           from './appservice/'

import {
  MATRIX_APPSERVICE_REGISTRATION_YAML_FILE,
}                                               from './config'

const cli = new Cli({
  generateRegistration,
  registrationPath: MATRIX_APPSERVICE_REGISTRATION_YAML_FILE,
  run,
})

cli.run()
github huan / matrix-appservice-wechaty / src / cli / create-cli.ts View on Github external
export function createCli (): Cli {

  const port             = DEFAULT_PORT
  const registrationPath = REGISTRATION_FILE
  const schema           = SCHEMA_FILE

  const bridgeConfig = {
    schema,
  }

  const cli = new Cli({
    bridgeConfig,
    generateRegistration,
    port,
    registrationPath,
    run,
  })

  return cli
}
github turt2live / matrix-appservice-instagram-media / app.js View on Github external
var Cli = require("matrix-appservice-bridge").Cli;
var AppServiceRegistration = require("matrix-appservice-bridge").AppServiceRegistration;
var log = require("./src/util/LogService");
var path = require("path");
var InstagramBridge = require("./src/InstagramBridge");
var InstagramStore = require("./src/storage/InstagramStore");

new Cli({
    registrationPath: "appservice-registration-instagram.yaml",
    enableRegistration: true,
    enableLocalpart: true,
    bridgeConfig: {
        affectsRegistration: true,
        schema: path.join(__dirname, "config/schema.yml"),
        defaults: {
            homeserver: {
                url: "http://localhost:8008",
                mediaUrl: "http://localhost:8008",
                domain: "localhost"
            },
            instagram: {
                clientId: "",
                clientSecret: "",
                publicUrlBase: "",
github turt2live / matrix-appservice-webhooks / index.js View on Github external
const LogService = require("matrix-js-snippets").LogService;
const Cli = require("matrix-appservice-bridge").Cli;
const AppServiceRegistration = require("matrix-appservice-bridge").AppServiceRegistration;
const path = require("path");
const WebhookStore = require("./src/storage/WebhookStore");
const WebhookBridge = require("./src/WebhookBridge");
const WebService = require("./src/WebService");

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://localhost:8008",
                mediaUrl: "http://localhost:8008",
                domain: "localhost"
            },
            webhookBot: {
                localpart: "_webhook",
                appearance: {
                    displayName: "Webhook Bridge",
github matrix-org / matrix-appservice-slack / src / app.ts View on Github external
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import { Logging, Cli, AppServiceRegistration } from "matrix-appservice-bridge";
import { Main } from "./Main";
import { IConfig } from "./IConfig";

const cli = new Cli({
    bridgeConfig: {
        affectsRegistration: true,
        schema: "config/slack-config-schema.yaml",
    },
    registrationPath: "slack-registration.yaml",
    generateRegistration(reg, callback) {
        const config = cli.getConfig();
        reg.setId(AppServiceRegistration.generateToken());
        reg.setHomeserverToken(AppServiceRegistration.generateToken());
        reg.setAppServiceToken(AppServiceRegistration.generateToken());
        reg.setSenderLocalpart("slackbot");
        reg.addRegexPattern("users", `@${config.username_prefix}.*`, true);
        callback(reg);
    },
    run(port: number, config: IConfig, registration: any) {
        Logging.configure(config.logging || {});
github Half-Shot / matrix-appservice-discord / src / discordas.ts View on Github external
limitations under the License.
*/

import { Cli, Bridge, AppServiceRegistration, ClientFactory, BridgeContext } from "matrix-appservice-bridge";
import * as yaml from "js-yaml";
import * as fs from "fs";
import { DiscordBridgeConfig } from "./config";
import { DiscordBot } from "./bot";
import { DiscordStore } from "./store";
import { Log } from "./log";
import "source-map-support/register";
import { MetricPeg, PrometheusBridgeMetrics } from "./metrics";

const log = new Log("DiscordAS");

const cli = new Cli({
    bridgeConfig: {
        affectsRegistration: true,
        schema: "./config/config.schema.yaml",
    },
    generateRegistration,
    registrationPath: "discord-registration.yaml",
    run,
});

try {
    cli.run();
} catch (err) {
    log.error("Failed to start bridge.");
    log.error(err);
}