Sélectionner une révision Git
text_file_writer.cpp
-
Rodrigo Braz Monteiro a rédigé
Originally committed to SVN as r2473.
Rodrigo Braz Monteiro a rédigéOriginally committed to SVN as r2473.
matrixeventprocessor.ts 19,05 Kio
/*
Copyright 2018, 2019 matrix-appservice-discord
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
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 * as Discord from "discord.js";
import { DiscordBot } from "./bot";
import { DiscordBridgeConfig } from "./config";
import * as escapeStringRegexp from "escape-string-regexp";
import { Util, wrapError } from "./util";
import * as path from "path";
import * as mime from "mime";
import {
Bridge,
BridgeContext,
MatrixUser,
RemoteRoom,
Request,
unstable as Unstable,
} from "matrix-appservice-bridge";
import { Client as MatrixClient } from "matrix-js-sdk";
import { IMatrixEvent, IMatrixEventContent, IMatrixMessage } from "./matrixtypes";
import { MatrixMessageProcessor, IMatrixMessageProcessorParams } from "./matrixmessageprocessor";
import { MatrixCommandHandler } from "./matrixcommandhandler";
import { Log } from "./log";
const log = new Log("MatrixEventProcessor");
const MaxFileSize = 8000000;
const MIN_NAME_LENGTH = 2;
const MAX_NAME_LENGTH = 32;
const DISCORD_AVATAR_WIDTH = 128;
const DISCORD_AVATAR_HEIGHT = 128;
const ROOM_NAME_PARTS = 2;
const AGE_LIMIT = 900000; // 15 * 60 * 1000
export class MatrixEventProcessorOpts {
constructor(
readonly config: DiscordBridgeConfig,
readonly bridge: Bridge,
readonly discord: DiscordBot,
) {
}
}
export interface IMatrixEventProcessorResult {
messageEmbed: Discord.RichEmbed;
replyEmbed?: Discord.RichEmbed;
}
export class MatrixEventProcessor {
private config: DiscordBridgeConfig;
private bridge: Bridge;
private discord: DiscordBot;
private matrixMsgProcessor: MatrixMessageProcessor;
private mxCommandHandler: MatrixCommandHandler;
constructor(opts: MatrixEventProcessorOpts, cm?: MatrixCommandHandler) {