How to use the matrix-appservice-bridge.Logging 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-appservice-slack / lib / BaseSlackHandler.js View on Github external
"use strict";

const rp = require('request-promise');
const Promise = require('bluebird');
const promiseWhile = require("./promiseWhile");
const getSlackFileUrl = require("./substitutions").getSlackFileUrl;
const log = require("matrix-appservice-bridge").Logging.get("BaseSlackHandler");

const CHANNEL_ID_REGEX = /<#(\w+)\|?\w*?>/g;
const CHANNEL_ID_REGEX_FIRST = /<#(\w+)\|?\w*?>/;

// (if the message is an emote, the format is <@ID|nick>, but in normal msgs it's just <@ID>
const USER_ID_REGEX = /<@(\w+)\|?\w*?>/g;
const USER_ID_REGEX_FIRST = /<@(\w+)\|?\w*?>/;

/**
 * @constructor
 * @param {Main} main the toplevel bridge instance through which to
 * communicate with matrix.
 */
function BaseSlackHandler(main) {
    this._main = main;
}
github matrix-org / matrix-appservice-slack / lib / substitutions.js View on Github external
"use strict";

const log = require("matrix-appservice-bridge").Logging.get("substitutions");
const emoji = require("node-emoji");

// Ordered
var SUBSTITUTION_PAIRS = [];

function add(slack, matrix) {
    SUBSTITUTION_PAIRS.push({
        slack: slack,
        matrix: matrix
    });
}

// slack -> matrix substitutions are performed top -> bottom
// matrix -> slack substitutions are performed bottom -> top
//
// The ordering here matters because some characters are present in both the
github matrix-org / matrix-appservice-slack / lib / SlackGhost.js View on Github external
"use strict";

var rp = require('request-promise');
const Slackdown = require('Slackdown');
const log = require("matrix-appservice-bridge").Logging.get("SlackGhost");
const BridgeLib = require("matrix-appservice-bridge");
const StoredEvent = BridgeLib.StoredEvent;

// How long in milliseconds to cache user info lookups.
var USER_CACHE_TIMEOUT = 10 * 60 * 1000;  // 10 minutes

function SlackGhost(opts) {
    this._main = opts.main;

    this._user_id = opts.user_id;
    this._display_name = opts.display_name;
    this._avatar_url = opts.avatar_url;

    this._intent = opts.intent;

    this._atime = null; // last activity time in epoch seconds
github matrix-org / matrix-appservice-slack / lib / SlackGhost.js View on Github external
"use strict";

var url = require('url');
var https = require('https');
var rp = require('request-promise');
const slackdown = require('Slackdown');
const substitutions = require("./substitutions");
const log = require("matrix-appservice-bridge").Logging.get("SlackGhost");

// How long in milliseconds to cache user info lookups.
var USER_CACHE_TIMEOUT = 10 * 60 * 1000;  // 10 minutes

function SlackGhost(opts) {
    this._main = opts.main;

    this._user_id = opts.user_id;
    this._display_name = opts.display_name;
    this._avatar_url = opts.avatar_url;

    this._intent = opts.intent;

    this._atime = null; // last activity time in epoch seconds
}
github matrix-org / matrix-appservice-slack / lib / Main.js View on Github external
"use strict";

const Promise = require('bluebird');
const BridgeLib = require("matrix-appservice-bridge");
const Bridge = BridgeLib.Bridge;
const Metrics = BridgeLib.PrometheusMetrics;
const StateLookup = BridgeLib.StateLookup;
const SlackHookHandler = require("./SlackHookHandler");
const BridgedRoom = require("./BridgedRoom");
const SlackGhost = require("./SlackGhost");
const MatrixUser = require("./MatrixUser"); // NB: this is not BridgeLib.MatrixUser !
const AdminCommands = require("./AdminCommands");
const OAuth2 = require("./OAuth2");
const Provisioning = require("./Provisioning");
const randomstring = require("randomstring");
const log = require("matrix-appservice-bridge").Logging.get("Main");
const rp = require('request-promise');
const Datastore = require('nedb');
const path = require("path");

function Main(config, registration) {
    var self = this;

    this._config = config;
    this._teams = new Map(); //team_id => team.

    if (config.oauth2) {
        this._oauth2 = new OAuth2({
            main: this,
            client_id: config.oauth2.client_id,
            client_secret: config.oauth2.client_secret,
            redirect_prefix: config.oauth2.redirect_prefix || config.inbound_uri_prefix,
github matrix-org / matrix-appservice-slack / lib / SlackHookHandler.js View on Github external
"use strict";

const substitutions = require("./substitutions");
const SlackEventHandler = require('./SlackEventHandler');
const BaseSlackHandler = require('./BaseSlackHandler');
const rp = require('request-promise');
const qs = require("querystring");
const Promise = require('bluebird');
const promiseWhile = require("./promiseWhile");
const util = require("util");
const fs = require("fs");
const log = require("matrix-appservice-bridge").Logging.get("SlackHookHandler");

const PRESERVE_KEYS = [
    "team_domain", "team_id",
    "channel_name", "channel_id",
    "user_name", "user_id",
];

/**
 * @constructor
 * @param {Main} main the toplevel bridge instance through which to
 * communicate with matrix.
 */
function SlackHookHandler(main) {
    this._main = main;
    this.eventHandler = new SlackEventHandler(main);
}
github matrix-org / matrix-appservice-slack / lib / Provisioning.js View on Github external
"use strict";

var Promise = require("bluebird");
const log = require("matrix-appservice-bridge").Logging.get("Provisioning");

function Command(opts) {
    this._params = opts.params;
    this._func   = opts.func;
}

Command.prototype.run = function(service, req, res) {
    var body = req.body;

    var args = [service, req, res];
    for (var i = 0; i < this._params.length; i++) {
        var param = this._params[i];

        if(!(param in body)) {
            res.status(400).json({error: "Required parameter " + param + " missing"});
            return;
github matrix-org / matrix-appservice-slack / src / AdminCommands.js View on Github external
"use strict";
const log = require("matrix-appservice-bridge").Logging.get("AdminCommands");

var AdminCommand = require("./AdminCommand");

var adminCommands = {};

function quotemeta(s) { return s.replace(/\W/g, '\\$&'); }

adminCommands.help = AdminCommand.makeHelpCommand(adminCommands);

adminCommands.list = new AdminCommand({
    desc: "list the linked rooms",
    opts: {
        team: {
            description: "Filter only rooms for this Slack team domain",
            aliases: ['T'],
        },
github matrix-org / matrix-appservice-slack / lib / BridgedRoom.js View on Github external
"use strict";

const Promise = require('bluebird');

const url = require('url');
const substitutions = require("./substitutions");
const rp = require('request-promise');
const emoji = require('node-emoji');
const log = require("matrix-appservice-bridge").Logging.get("BridgedRoom");
const BridgeLib = require("matrix-appservice-bridge");
const StoredEvent = BridgeLib.StoredEvent;

function BridgedRoom(main, opts) {
    this._main = main;

    if (!opts.inbound_id) {
        throw new Error("BridgedRoom requires an inbound ID");
    }
    if (!opts.matrix_room_id) {
        throw new Error("BridgedRoom requires an Matrix Room ID");
    }

    this._matrix_room_id = opts.matrix_room_id;
    this._inbound_id = opts.inbound_id;
    this._slack_channel_name = opts.slack_channel_name;
github matrix-org / matrix-appservice-slack / lib / SlackEventHandler.js View on Github external
"use strict";

const BaseSlackHandler = require('./BaseSlackHandler');
const Promise = require('bluebird');
const util = require("util");
const log = require("matrix-appservice-bridge").Logging.get("SlackEventHandler");

const UnknownEvent = function () {
};
const UnknownChannel = function (channel) {
    this.channel = channel;
};

/**
 * @constructor
 * @param {Main} main the toplevel bridge instance through which to
 * communicate with matrix.
 */
function SlackEventHandler(main) {
    this._main = main;
}