Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 9f31c7334c382d848e9de42ddc48af62dd8ba7e2
  • master par défaut
  • script
  • new-devel
  • devel
  • timingView-edit
  • fix-mpv
7 résultats

Ass.hh

Blame
    • Kubat's avatar
      a4bd9bcd
      BUILD: New folder hierarchy · a4bd9bcd
      Kubat a rédigé
      Two main folders: Lib and UI. The Lib is specialized in Document and
      Ass, the UI is specialized for private DocumentViews (private document
      views) and others (future ScriptViews, etc)
      BUILD: New folder hierarchy
      Kubat a rédigé
      Two main folders: Lib and UI. The Lib is specialized in Document and
      Ass, the UI is specialized for private DocumentViews (private document
      views) and others (future ScriptViews, etc)
    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) {