From 8256e7920a26d3e40e77ac056a5591f7b3a4127d Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Tue, 31 Aug 2021 16:36:42 +0200 Subject: [PATCH] telegram bridge matrix --- hosts/architect/matrix.nix | 58 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/hosts/architect/matrix.nix b/hosts/architect/matrix.nix index 12711cd..a009dd6 100644 --- a/hosts/architect/matrix.nix +++ b/hosts/architect/matrix.nix @@ -1,4 +1,4 @@ -{ pkgs, config, ... }: +{ pkgs, config, tmp, ... }: with import ./network.nix; { @@ -11,7 +11,10 @@ with import ./network.nix; registration_shared_secret = "runas!"; dynamic_thumbnails = true; enable_registration = true; - app_service_config_files = [ "/var/lib/matrix-synapse/discord-registration.yaml" ]; + app_service_config_files = [ + "/var/lib/matrix-synapse/discord-registration.yaml" + "/var/lib/matrix-synapse/telegram-registration.yaml" + ]; extraConfig = '' auto_join_rooms: - "#infra:matrix.giugl.io" @@ -79,7 +82,7 @@ with import ./network.nix; enableACME = true; forceSSL = true; - root = pkgs.element-web.override { + root = pkgs.unstable.element-web.override { conf = { default_server_config."m.homeserver" = { "base_url" = "https://${matrixdomain}"; @@ -90,6 +93,7 @@ with import ./network.nix; }; }; + # discord bridge matrix-appservice-discord = { enable = true; environmentFile = /secrets/matrix-appservice-discord/tokens.env; @@ -103,8 +107,56 @@ with import ./network.nix; }; }; }; + + # telegram bridge + + mautrix-telegram = { + enable = true; + environmentFile = /secrets/mautrix-telegram/mautrix-telegram.env; + + settings = { + homeserver = { + address = "https://${matrixdomain}"; + domain = "${matrixdomain}"; + }; + + appservice = { + provisioning.enabled = false; + id = "telegram"; + }; + + bridge = { + permissions = { + "@pepe:${matrixdomain}" = "admin"; + "${matrixdomain}" = "puppeting"; + }; + + # Animated stickers conversion requires additional packages in the + # service's path. + # If this isn't a fresh installation, clearing the bridge's uploaded + # file cache might be necessary (make a database backup first!): + # delete from telegram_file where \ + # mime_type in ('application/gzip', 'application/octet-stream') + animated_sticker = { + target = "gif"; + args = { + width = 256; + height = 256; + fps = 30; # only for webm + background = "020202"; # only for gif, transparency not supported + }; + }; + }; + }; }; + }; + + systemd.services.mautrix-telegram.path = with pkgs; [ + lottieconverter # for animated stickers conversion, unfree package + ffmpeg # if converting animated stickers to webm (very slow!) + ]; + networking.extraHosts = '' 127.0.0.1 ${matrixdomain} ${matrixwebdomain} ${architect-lan} ${matrixdomain} ${matrixwebdomain}