From 36837a950063d623d3837ed625284c208373f271 Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Tue, 6 Sep 2022 14:41:32 +0200 Subject: [PATCH 01/18] add relay bot token var --- README.md | 5 +++++ rootfs/etc/confd/templates/config.yaml.tmpl | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 53d65cb..0c7fefd 100644 --- a/README.md +++ b/README.md @@ -31,5 +31,10 @@ Telegram API hash (https://my.telegram.org/apps). ## ADMIN_USER Matrix id of the admin user. +## BOT_TOKEN +- default: disabled + +Token for the relay bot. + # Ports - 8080 diff --git a/rootfs/etc/confd/templates/config.yaml.tmpl b/rootfs/etc/confd/templates/config.yaml.tmpl index c6fe985..619052e 100644 --- a/rootfs/etc/confd/templates/config.yaml.tmpl +++ b/rootfs/etc/confd/templates/config.yaml.tmpl @@ -495,7 +495,7 @@ telegram: api_id: {{ getenv "API_ID" }} api_hash: {{ getenv "API_HASH" }} # (Optional) Create your own bot at https://t.me/BotFather - bot_token: disabled + bot_token: {{ getenv "BOT_TOKEN" "disabled" }} # Should the bridge request missed updates from Telegram when restarting? catch_up: true From bfff34243e8889f8ad1cb345db48645eea8f6e64 Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Fri, 11 Nov 2022 07:31:16 +0000 Subject: [PATCH 02/18] Delete '.gitlab-ci.yml' --- .gitlab-ci.yml | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index c32004e..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,20 +0,0 @@ -variables: - CONTAINER_NAME: thallian/matrix-appservice-telegram - -build: - stage: build - image: - name: gcr.io/kaniko-project/executor:debug - entrypoint: [""] - script: - - mkdir -p /kaniko/.docker - - echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$(printf "%s:%s" "$CI_REGISTRY_USER" "$CI_REGISTRY_PASSWORD" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json - - >- - /kaniko/executor - --cache=false - --context "$CI_PROJECT_DIR" - --dockerfile "$CI_PROJECT_DIR/Dockerfile" - --destination "$CONTAINER_NAME:$CI_COMMIT_SHA" - --destination "$CONTAINER_NAME:$CI_COMMIT_REF_NAME" - --destination "$CONTAINER_NAME:latest" - From b94e090a8b4eb71982c75ee3d93e821d7a2a112d Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Fri, 11 Nov 2022 07:31:58 +0000 Subject: [PATCH 03/18] Add '.woodpecker.yml' --- .woodpecker.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .woodpecker.yml diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..b4844fc --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,11 @@ +pipeline: + publish-docker-image: + image: plugins/kaniko + settings: + repo: docker.io/thallian/matrix-appservice-telegram + tags: latest,${CI_COMMIT_SHA:0:8},${CI_COMMIT_TAG=pre} + dockerfile: Dockerfile + username: + from_secret: DOCKER_USER + password: + from_secret: DOCKER_PW \ No newline at end of file From 67f799c6584e7e6527cba64116263166e7ddf58e Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Tue, 6 Sep 2022 14:41:32 +0200 Subject: [PATCH 04/18] add relay bot token var --- README.md | 5 +++++ rootfs/etc/confd/templates/config.yaml.tmpl | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 53d65cb..0c7fefd 100644 --- a/README.md +++ b/README.md @@ -31,5 +31,10 @@ Telegram API hash (https://my.telegram.org/apps). ## ADMIN_USER Matrix id of the admin user. +## BOT_TOKEN +- default: disabled + +Token for the relay bot. + # Ports - 8080 diff --git a/rootfs/etc/confd/templates/config.yaml.tmpl b/rootfs/etc/confd/templates/config.yaml.tmpl index c6fe985..619052e 100644 --- a/rootfs/etc/confd/templates/config.yaml.tmpl +++ b/rootfs/etc/confd/templates/config.yaml.tmpl @@ -495,7 +495,7 @@ telegram: api_id: {{ getenv "API_ID" }} api_hash: {{ getenv "API_HASH" }} # (Optional) Create your own bot at https://t.me/BotFather - bot_token: disabled + bot_token: {{ getenv "BOT_TOKEN" "disabled" }} # Should the bridge request missed updates from Telegram when restarting? catch_up: true From 4c2a8068d928540100faf213cc4af12165089c8a Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Fri, 18 Nov 2022 09:40:25 +0100 Subject: [PATCH 05/18] push to 5558fc7157361e3c7f721fc7c82a1d5a084a96de --- Dockerfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index d7f3961..a8e91c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ FROM docker.io/alpine:3.16 as builder -ENV VERSION=85b8f5def7a3f40504b8f814437bf7e4507fc3ba +ENV VERSION=5558fc7157361e3c7f721fc7c82a1d5a084a96de RUN apk --no-cache add \ sed \ - gcc \ + gcc \ g++ \ git \ musl-dev \ @@ -12,7 +12,7 @@ RUN apk --no-cache add \ python3-dev \ rust \ cargo \ - py3-pip \ + py3-pip \ py3-wheel \ py3-brotli \ py3-olm \ @@ -56,11 +56,11 @@ RUN addgroup -g 2222 matrix-bridge RUN adduser -h /var/lib/matrix-bridge -u 2222 -D -G matrix-bridge matrix-bridge RUN apk --no-cache add \ - ca-certificates \ - ffmpeg \ - libffi \ + ca-certificates \ + ffmpeg \ + libffi \ python3 \ - py3-brotli \ + py3-brotli \ py3-olm \ py3-qrcode \ py3-pillow \ From 8712844944c7186d4f571fe83a65663e1acd240e Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Fri, 18 Nov 2022 10:36:35 +0100 Subject: [PATCH 06/18] update config file --- rootfs/etc/confd/templates/config.yaml.tmpl | 87 +++++++++++++++------ 1 file changed, 62 insertions(+), 25 deletions(-) diff --git a/rootfs/etc/confd/templates/config.yaml.tmpl b/rootfs/etc/confd/templates/config.yaml.tmpl index 619052e..e69dc1a 100644 --- a/rootfs/etc/confd/templates/config.yaml.tmpl +++ b/rootfs/etc/confd/templates/config.yaml.tmpl @@ -7,7 +7,9 @@ homeserver: # Whether or not to verify the SSL certificate of the homeserver. # Only applies if address starts with https:// verify_ssl: true - asmux: false + # What software is the homeserver running? + # Standard Matrix homeservers like Synapse, Dendrite and Conduit should just use "standard" here. + software: standard # Number of retries for all HTTP requests if the homeserver isn't reachable. http_retry_count: 4 # The URL to push real-time bridge status to. @@ -30,7 +32,7 @@ appservice: tls_key: false # The hostname and port where this appservice should listen. - hostname: 0.0.0.0 + hostname: :: port: 29317 # The maximum body size of appservice API requests (from the homeserver) in mebibytes # Usually 1 is enough, but on high-traffic bridges you might need to increase this to avoid 413s @@ -45,6 +47,7 @@ appservice: # https://magicstack.github.io/asyncpg/current/api/index.html#asyncpg.pool.create_pool # https://docs.python.org/3/library/sqlite3.html#sqlite3.connect # For sqlite, min_size is used as the connection thread pool size and max_size is ignored. + # Additionally, SQLite supports init_commands as an array of SQL queries to run on connect (e.g. to set PRAGMAs). database_opts: min_size: 1 max_size: 10 @@ -166,7 +169,10 @@ bridge: sync_update_limit: 0 # Number of most recently active dialogs to create portals for when syncing chats. # Set to 0 to remove limit. - sync_create_limit: 30 + sync_create_limit: 15 + # Should all chats be scheduled to be created later? + # This is best used in combination with MSC2716 infinite backfill. + sync_deferred_create_all: false # Whether or not to sync and create portals for direct chats at startup. sync_direct_chats: false # The maximum number of simultaneous Telegram deletions to handle. @@ -221,6 +227,9 @@ bridge: # Whether or not created rooms should have federation enabled. # If false, created portal rooms will never be federated. federate_rooms: true + # Should the bridge send all unicode reactions as custom emoji reactions to Telegram? + # By default, the bridge only uses custom emojis for unicode emojis that aren't allowed in reactions. + always_custom_emoji_reaction: false # Settings for converting animated stickers. animated_sticker: # Format to which animated stickers should be converted. @@ -255,6 +264,8 @@ bridge: # Default to encryption, force-enable encryption in all portals the bridge creates # This will cause the bridge bot to be in private chats for the encryption to work properly. default: true + # Whether to use MSC2409/MSC3202 instead of /sync long polling for receiving encryption-related data. + appservice: false # Require encryption, drop any unencrypted messages. require: false # Enable key sharing? If enabled, key requests for rooms where users are in will be fulfilled. @@ -329,34 +340,60 @@ bridge: create_group_on_invite: true # Settings for backfilling messages from Telegram. backfill: - # Whether or not the Telegram ghosts of logged in Matrix users should be - # invited to private chats when backfilling history from Telegram. This is - # usually needed to prevent rate limits and to allow timestamp massaging. - invite_own_puppet: true - # Maximum number of messages to backfill without using a takeout. - # The first time a takeout is used, the user has to manually approve it from a different - # device. If initial_limit or missed_limit are higher than this value, the bridge will ask - # the user to accept the takeout after logging in before syncing any chats. - takeout_limit: 100 - # Maximum number of messages to backfill initially. - # Set to 0 to disable backfilling when creating portal, or -1 to disable the limit. + # Allow backfilling at all? + enable: true + # Use MSC2716 for backfilling? # - # N.B. Initial backfill will only start after member sync. Make sure your - # max_initial_member_sync is set to a low enough value so it doesn't take forever. - initial_limit: 0 - # Maximum number of messages to backfill if messages were missed while the bridge was - # disconnected. Note that this only works for logged in users and only if the chat isn't - # older than sync_update_limit - # Set to 0 to disable backfilling missed messages. - missed_limit: 50 - # If using double puppeting, should notifications be disabled - # while the initial backfill is in progress? - disable_notifications: false + # This requires a server with MSC2716 support, which is currently an experimental feature in Synapse. + # It can be enabled by setting experimental_features -> msc2716_enabled to true in homeserver.yaml. + msc2716: false + # Use double puppets for backfilling? + # + # If using MSC2716, the double puppets must be in the appservice's user ID namespace + # (because the bridge can't use the double puppet access token with batch sending). + # + # Even without MSC2716, bridging old messages with correct timestamps requires the double + # puppets to be in an appservice namespace, or the server to be modified to allow + # overriding timestamps anyway. + double_puppet_backfill: false # Whether or not to enable backfilling in normal groups. # Normal groups have numerous technical problems in Telegram, and backfilling normal groups # will likely cause problems if there are multiple Matrix users in the group. normal_groups: false + # If a backfilled chat is older than this number of hours, mark it as read even if it's unread on Telegram. + # Set to -1 to let any chat be unread. + unread_hours_threshold: 720 + + # Forward backfilling limits. These apply to both MSC2716 and legacy backfill. + # + # Using a negative initial limit is not recommended, as it would try to backfill everything in a single batch. + # MSC2716 and the incremental settings are meant for backfilling everything incrementally rather than at once. + forward: + # Number of messages to backfill immediately after creating a portal. + initial_limit: 10 + # Number of messages to backfill when syncing chats. + sync_limit: 100 + + # Settings for incremental backfill of history. These only apply when using MSC2716. + incremental: + # Maximum number of messages to backfill per batch. + messages_per_batch: 100 + # The number of seconds to wait after backfilling the batch of messages. + post_batch_delay: 20 + # The maximum number of batches to backfill per portal, split by the chat type. + # If set to -1, all messages in the chat will eventually be backfilled. + max_batches: + # Direct chats + user: -1 + # Normal groups. Note that the normal_groups option above must be enabled + # for these to be backfilled. + normal_group: -1 + # Supergroups + supergroup: 10 + # Broadcast channels + channel: -1 + # Overrides for base power levels. initial_power_level_overrides: user: {} From 5048243b6643b6d223902c3bc2b0e146525a8d3c Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Fri, 18 Nov 2022 10:40:42 +0100 Subject: [PATCH 07/18] update config file --- rootfs/etc/confd/templates/config.yaml.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/etc/confd/templates/config.yaml.tmpl b/rootfs/etc/confd/templates/config.yaml.tmpl index e69dc1a..f08704d 100644 --- a/rootfs/etc/confd/templates/config.yaml.tmpl +++ b/rootfs/etc/confd/templates/config.yaml.tmpl @@ -26,7 +26,7 @@ homeserver: # Changing these values requires regeneration of the registration. appservice: # The address that the homeserver can use to connect to this appservice. - address: http://localhost:29317 + address: http://{{getenv "HOSTNAME"}}:29317 # When using https:// the TLS certificate and key files for the address. tls_cert: false tls_key: false From dbad285bffcef3d49458e6660f9f43aef433e73c Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Sun, 20 Nov 2022 14:11:32 +0100 Subject: [PATCH 08/18] try to listen on ipv6 as well --- rootfs/etc/confd/templates/config.yaml.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/etc/confd/templates/config.yaml.tmpl b/rootfs/etc/confd/templates/config.yaml.tmpl index f08704d..b390fd3 100644 --- a/rootfs/etc/confd/templates/config.yaml.tmpl +++ b/rootfs/etc/confd/templates/config.yaml.tmpl @@ -32,7 +32,7 @@ appservice: tls_key: false # The hostname and port where this appservice should listen. - hostname: :: + hostname: [::] port: 29317 # The maximum body size of appservice API requests (from the homeserver) in mebibytes # Usually 1 is enough, but on high-traffic bridges you might need to increase this to avoid 413s From 00f1128297d3676c9db6d9613359abd164e38266 Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Thu, 24 Nov 2022 08:27:49 +0100 Subject: [PATCH 09/18] push to 24b33845 --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index a8e91c9..2a0963d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -FROM docker.io/alpine:3.16 as builder +FROM docker.io/alpine:3.17 as builder -ENV VERSION=5558fc7157361e3c7f721fc7c82a1d5a084a96de +ENV VERSION=24b33845707689b735292464f5d6235737a7df21 RUN apk --no-cache add \ sed \ @@ -46,7 +46,7 @@ RUN pip3 install --prefix=/install --upgrade -r optional-requirements.txt RUN cp -r mautrix_telegram /install/lib/python3.10/site-packages/ -FROM docker.io/thallian/confd-env:3.16 +FROM docker.io/thallian/confd-env:3.17 ENV FFMPEG_BINARY=/usr/bin/ffmpeg From 77b274973e4be1871d2f01c7dc7ca29c053c37e7 Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Thu, 24 Nov 2022 08:39:10 +0100 Subject: [PATCH 10/18] allow key sharing --- rootfs/etc/confd/templates/config.yaml.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rootfs/etc/confd/templates/config.yaml.tmpl b/rootfs/etc/confd/templates/config.yaml.tmpl index b390fd3..ed14736 100644 --- a/rootfs/etc/confd/templates/config.yaml.tmpl +++ b/rootfs/etc/confd/templates/config.yaml.tmpl @@ -265,12 +265,12 @@ bridge: # This will cause the bridge bot to be in private chats for the encryption to work properly. default: true # Whether to use MSC2409/MSC3202 instead of /sync long polling for receiving encryption-related data. - appservice: false + appservice: true # Require encryption, drop any unencrypted messages. require: false # Enable key sharing? If enabled, key requests for rooms where users are in will be fulfilled. # You must use a client that supports requesting keys from other users to use this feature. - allow_key_sharing: false + allow_key_sharing: true # What level of device verification should be required from users? # # Valid levels: From f0bd0e452b4a009bb0ff96a0a391ce65b7ca3a47 Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Thu, 6 Apr 2023 11:11:56 +0200 Subject: [PATCH 11/18] push to 59ab7be28353b99f41eb18c3baee14355257ae16 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2a0963d..601a4e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM docker.io/alpine:3.17 as builder -ENV VERSION=24b33845707689b735292464f5d6235737a7df21 +ENV VERSION=59ab7be28353b99f41eb18c3baee14355257ae16 RUN apk --no-cache add \ sed \ @@ -46,7 +46,7 @@ RUN pip3 install --prefix=/install --upgrade -r optional-requirements.txt RUN cp -r mautrix_telegram /install/lib/python3.10/site-packages/ -FROM docker.io/thallian/confd-env:3.17 +FROM docker.io/thallian/confd-env:3.17-3.1.3.0 ENV FFMPEG_BINARY=/usr/bin/ffmpeg From 6b3b7b143da3de715cda4e9252c5d3b701595ce6 Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Thu, 6 Apr 2023 13:35:17 +0200 Subject: [PATCH 12/18] use /sync for encryption data --- rootfs/etc/confd/templates/config.yaml.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/etc/confd/templates/config.yaml.tmpl b/rootfs/etc/confd/templates/config.yaml.tmpl index ed14736..c86ba0e 100644 --- a/rootfs/etc/confd/templates/config.yaml.tmpl +++ b/rootfs/etc/confd/templates/config.yaml.tmpl @@ -265,7 +265,7 @@ bridge: # This will cause the bridge bot to be in private chats for the encryption to work properly. default: true # Whether to use MSC2409/MSC3202 instead of /sync long polling for receiving encryption-related data. - appservice: true + appservice: false # Require encryption, drop any unencrypted messages. require: false # Enable key sharing? If enabled, key requests for rooms where users are in will be fulfilled. From 637b01c2d17e77e484dd9df20e3c6f5e79326e63 Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Mon, 31 Jul 2023 11:52:43 +0200 Subject: [PATCH 13/18] push to 23ec6911 --- Dockerfile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 601a4e4..b5e85d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ -FROM docker.io/alpine:3.17 as builder +FROM docker.io/alpine:3.18 as builder -ENV VERSION=59ab7be28353b99f41eb18c3baee14355257ae16 +ENV VERSION=23ec691128d30545c208c06eb4805443e292eb23 RUN apk --no-cache add \ sed \ - gcc \ + gcc \ g++ \ git \ musl-dev \ @@ -12,7 +12,7 @@ RUN apk --no-cache add \ python3-dev \ rust \ cargo \ - py3-pip \ + py3-pip \ py3-wheel \ py3-brotli \ py3-olm \ @@ -43,10 +43,10 @@ WORKDIR /telegram RUN git checkout "$VERSION" RUN pip3 install --prefix=/install --upgrade -r requirements.txt RUN pip3 install --prefix=/install --upgrade -r optional-requirements.txt -RUN cp -r mautrix_telegram /install/lib/python3.10/site-packages/ +RUN cp -r mautrix_telegram /install/lib/python3.11/site-packages/ -FROM docker.io/thallian/confd-env:3.17-3.1.3.0 +FROM docker.io/thallian/confd-env:3.18-3.1.5.0 ENV FFMPEG_BINARY=/usr/bin/ffmpeg @@ -56,11 +56,11 @@ RUN addgroup -g 2222 matrix-bridge RUN adduser -h /var/lib/matrix-bridge -u 2222 -D -G matrix-bridge matrix-bridge RUN apk --no-cache add \ - ca-certificates \ - ffmpeg \ - libffi \ + ca-certificates \ + ffmpeg \ + libffi \ python3 \ - py3-brotli \ + py3-brotli \ py3-olm \ py3-qrcode \ py3-pillow \ @@ -84,7 +84,7 @@ RUN apk --no-cache add \ py3-mako \ py3-setuptools -ENV PYTHONPATH=/usr/lib/python3.10/site-packages:/py-pkgs/lib/python3.10/site-packages/ +ENV PYTHONPATH=/usr/lib/python3.11/site-packages:/py-pkgs/lib/python3.11/site-packages/ WORKDIR /var/lib/matrix-bridge From aad509a99a189c027fe52b8e9b954389159b87bb Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Fri, 22 Sep 2023 11:45:17 +0200 Subject: [PATCH 14/18] push to 23ec691128d30545c208c06eb4805443e292eb23 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b5e85d2..0a26a85 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM docker.io/alpine:3.18 as builder -ENV VERSION=23ec691128d30545c208c06eb4805443e292eb23 +ENV VERSION=22f91d51a318023da74d5a368819595553e3c347 RUN apk --no-cache add \ sed \ From 915ea9eb02ef9794a2268ac44b6e1d0cdbc5ce1a Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Tue, 26 Sep 2023 18:01:29 +0200 Subject: [PATCH 15/18] push to 0.14.2 --- Dockerfile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0a26a85..6ea6e67 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM docker.io/alpine:3.18 as builder -ENV VERSION=22f91d51a318023da74d5a368819595553e3c347 +ENV VERSION=v0.14.2 RUN apk --no-cache add \ sed \ @@ -14,11 +14,9 @@ RUN apk --no-cache add \ cargo \ py3-pip \ py3-wheel \ - py3-brotli \ py3-olm \ py3-qrcode \ py3-pillow \ - py3-phonenumbers \ py3-unpaddedbase64 \ py3-pycryptodome \ py3-pyaes \ @@ -30,13 +28,10 @@ RUN apk --no-cache add \ py3-numpy \ py3-future \ py3-asn1 \ - py3-ruamel.yaml \ py3-magic \ py3-commonmark \ - py3-aiohttp \ py3-yarl \ - py3-mako \ - py3-setuptools + py3-mako RUN git clone https://github.com/mautrix/telegram.git WORKDIR /telegram From 6f4dfc6e92972055ac7c10d08cc2749134929607 Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Tue, 2 Jan 2024 11:56:36 +0100 Subject: [PATCH 16/18] push to 0.15.1 --- .gitea/workflows/container.yaml | 12 ++++++++++++ .woodpecker.yml | 11 ----------- Dockerfile => Containerfile | 7 ++++--- 3 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 .gitea/workflows/container.yaml delete mode 100644 .woodpecker.yml rename Dockerfile => Containerfile (93%) diff --git a/.gitea/workflows/container.yaml b/.gitea/workflows/container.yaml new file mode 100644 index 0000000..e48b3fd --- /dev/null +++ b/.gitea/workflows/container.yaml @@ -0,0 +1,12 @@ +name: Build Multiarch Container Image +on: [push] +jobs: + call-reusable-workflow: + uses: container/multiarch-build-workflow/.gitea/workflows/build.yaml@main + with: + repository: ${{ gitea.repository }} + ref_name: ${{ gitea.ref_name }} + sha: ${{ gitea.sha }} + registry_url: ${{ secrets.REGISTRY_URL }} + registry_user: ${{ secrets.REGISTRY_USER }} + registry_pw: ${{ secrets.REGISTRY_PW }} diff --git a/.woodpecker.yml b/.woodpecker.yml deleted file mode 100644 index b4844fc..0000000 --- a/.woodpecker.yml +++ /dev/null @@ -1,11 +0,0 @@ -pipeline: - publish-docker-image: - image: plugins/kaniko - settings: - repo: docker.io/thallian/matrix-appservice-telegram - tags: latest,${CI_COMMIT_SHA:0:8},${CI_COMMIT_TAG=pre} - dockerfile: Dockerfile - username: - from_secret: DOCKER_USER - password: - from_secret: DOCKER_PW \ No newline at end of file diff --git a/Dockerfile b/Containerfile similarity index 93% rename from Dockerfile rename to Containerfile index 6ea6e67..5b19794 100644 --- a/Dockerfile +++ b/Containerfile @@ -1,6 +1,5 @@ -FROM docker.io/alpine:3.18 as builder +FROM docker.io/alpine:3.19 as builder -ENV VERSION=v0.14.2 RUN apk --no-cache add \ sed \ @@ -33,6 +32,8 @@ RUN apk --no-cache add \ py3-yarl \ py3-mako +ENV VERSION=v0.15.1 + RUN git clone https://github.com/mautrix/telegram.git WORKDIR /telegram RUN git checkout "$VERSION" @@ -41,7 +42,7 @@ RUN pip3 install --prefix=/install --upgrade -r optional-requirements.txt RUN cp -r mautrix_telegram /install/lib/python3.11/site-packages/ -FROM docker.io/thallian/confd-env:3.18-3.1.5.0 +FROM docker.io/thallian/confd-env:3.19-3.1.6.2 ENV FFMPEG_BINARY=/usr/bin/ffmpeg From 465e258968f6b15107ca90002a48d6728661621c Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Mon, 22 Apr 2024 21:52:24 +0200 Subject: [PATCH 17/18] ipv6 is not well supported so far --- Containerfile | 4 +- rootfs/etc/confd/templates/config.yaml.tmpl | 100 ++++++++++++++------ 2 files changed, 72 insertions(+), 32 deletions(-) diff --git a/Containerfile b/Containerfile index 5b19794..dab8f1c 100644 --- a/Containerfile +++ b/Containerfile @@ -1,6 +1,5 @@ FROM docker.io/alpine:3.19 as builder - RUN apk --no-cache add \ sed \ gcc \ @@ -32,7 +31,7 @@ RUN apk --no-cache add \ py3-yarl \ py3-mako -ENV VERSION=v0.15.1 +ENV VERSION=43d17a335b1dd45fc81f3bed8ad6a7ee9f7a708f RUN git clone https://github.com/mautrix/telegram.git WORKDIR /telegram @@ -92,4 +91,3 @@ RUN chown -R matrix-bridge:matrix-bridge /var/lib/matrix-bridge ENV HOME /var/lib/matrix-bridge EXPOSE 8080 - diff --git a/rootfs/etc/confd/templates/config.yaml.tmpl b/rootfs/etc/confd/templates/config.yaml.tmpl index c86ba0e..9a5fec2 100644 --- a/rootfs/etc/confd/templates/config.yaml.tmpl +++ b/rootfs/etc/confd/templates/config.yaml.tmpl @@ -1,4 +1,3 @@ -# Homeserver details homeserver: # The address that this appservice can use to connect to the homeserver. address: {{ getenv "SERVER_URL" }} @@ -32,7 +31,7 @@ appservice: tls_key: false # The hostname and port where this appservice should listen. - hostname: [::] + hostname: 0.0.0.0 port: 29317 # The maximum body size of appservice API requests (from the homeserver) in mebibytes # Usually 1 is enough, but on high-traffic bridges you might need to increase this to avoid 413s @@ -40,7 +39,7 @@ appservice: # The full URI to the database. SQLite and Postgres are supported. # Format examples: - # SQLite: sqlite:///filename.db + # SQLite: sqlite:filename.db # Postgres: postgres://username:password@hostname/dbname database: {{ getenv "DATABASE_DATASOURCE"}} # Additional arguments for asyncpg.create_pool() or sqlite3.connect() @@ -62,7 +61,7 @@ appservice: prefix: /public # The base URL where the public-facing endpoints are available. The prefix is not added # implicitly. - external: {{ getenv "SERVER_URL_PUBLIC" }} + external: https://example.com/public # Provisioning API part of the web server for automated portal creation and fetching information. # Used by things like mautrix-manager (https://github.com/tulir/mautrix-manager). @@ -78,7 +77,7 @@ appservice: # The unique ID of this appservice. id: telegram # Username of the appservice bot. - bot_username: telegrambot + bot_username: telegram_bot # Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty # to leave display name/avatar as-is. bot_displayname: Telegram bridge bot @@ -145,6 +144,9 @@ bridge: # as there's no way to determine whether an avatar is removed or just hidden from some users. If # you're on a single-user instance, this should be safe to enable. allow_avatar_remove: false + # Should contact names and profile pictures be allowed? + # This is only safe to enable on single-user instances. + allow_contact_info: false # Maximum number of members to sync per portal when starting up. Other members will be # synced when they send messages. The maximum is 10000, after which the Telegram server @@ -219,6 +221,11 @@ bridge: image_as_file_size: 10 # Maximum number of pixels in an image before sending to Telegram as a document. Defaults to 4096x4096 = 16777216. image_as_file_pixels: 16777216 + # Maximum size of Telegram documents before linking to Telegrm instead of bridge + # to Matrix media. + document_as_link_size: + channel: + bot: # Enable experimental parallel file transfer, which makes uploads/downloads much faster by # streaming from/to Matrix and using many connections for Telegram. # Note that generating HQ thumbnails for videos is not possible with streamed transfers. @@ -271,6 +278,27 @@ bridge: # Enable key sharing? If enabled, key requests for rooms where users are in will be fulfilled. # You must use a client that supports requesting keys from other users to use this feature. allow_key_sharing: true + # Options for deleting megolm sessions from the bridge. + delete_keys: + # Beeper-specific: delete outbound sessions when hungryserv confirms + # that the user has uploaded the key to key backup. + delete_outbound_on_ack: false + # Don't store outbound sessions in the inbound table. + dont_store_outbound: false + # Ratchet megolm sessions forward after decrypting messages. + ratchet_on_decrypt: false + # Delete fully used keys (index >= max_messages) after decrypting messages. + delete_fully_used_on_decrypt: false + # Delete previous megolm sessions from same device when receiving a new one. + delete_prev_on_new_session: false + # Delete megolm sessions received from a device when the device is deleted. + delete_on_device_delete: false + # Periodically delete megolm sessions when 2x max_age has passed since receiving the session. + periodically_delete_expired: false + # Delete inbound megolm sessions that don't have the received_at field used for + # automatic ratcheting and expired session deletion. This is meant as a migration + # to delete old keys prior to the bridge update. + delete_outdated_inbound: false # What level of device verification should be required from users? # # Valid levels: @@ -306,14 +334,27 @@ bridge: # default. messages: 100 - # Whether or not to explicitly set the avatar and room name for private - # chat portal rooms. This will be implicitly enabled if encryption.default is true. - private_chat_portal_meta: false + # Disable rotating keys when a user's devices change? + # You should not enable this option unless you understand all the implications. + disable_device_change_key_rotation: false + + # Whether to explicitly set the avatar and room name for private chat portal rooms. + # If set to `default`, this will be enabled in encrypted rooms and disabled in unencrypted rooms. + # If set to `always`, all DM rooms will have explicit names and avatars set. + # If set to `never`, DM rooms will never have names and avatars set. + private_chat_portal_meta: default + # Disable generating reply fallbacks? Some extremely bad clients still rely on them, + # but they're being phased out and will be completely removed in the future. + disable_reply_fallbacks: false + # Should cross-chat replies from Telegram be bridged? Most servers and clients don't support this. + cross_room_replies: false # Whether or not the bridge should send a read receipt from the bridge bot when a message has # been sent to Telegram. delivery_receipts: false # Whether or not delivery errors should be reported as messages in the Matrix room. delivery_error_reports: false + # Should errors in incoming message handling send a message to the Matrix room? + incoming_bridge_error_reports: false # Whether the bridge should send the message status as a custom com.beeper.message_send_status event. message_status_events: false # Set this to true to tell the bridge to re-send m.bridge events to all rooms on the next run. @@ -342,20 +383,6 @@ bridge: backfill: # Allow backfilling at all? enable: true - # Use MSC2716 for backfilling? - # - # This requires a server with MSC2716 support, which is currently an experimental feature in Synapse. - # It can be enabled by setting experimental_features -> msc2716_enabled to true in homeserver.yaml. - msc2716: false - # Use double puppets for backfilling? - # - # If using MSC2716, the double puppets must be in the appservice's user ID namespace - # (because the bridge can't use the double puppet access token with batch sending). - # - # Even without MSC2716, bridging old messages with correct timestamps requires the double - # puppets to be in an appservice namespace, or the server to be modified to allow - # overriding timestamps anyway. - double_puppet_backfill: false # Whether or not to enable backfilling in normal groups. # Normal groups have numerous technical problems in Telegram, and backfilling normal groups # will likely cause problems if there are multiple Matrix users in the group. @@ -365,17 +392,26 @@ bridge: # Set to -1 to let any chat be unread. unread_hours_threshold: 720 - # Forward backfilling limits. These apply to both MSC2716 and legacy backfill. + # Forward backfilling limits. # # Using a negative initial limit is not recommended, as it would try to backfill everything in a single batch. - # MSC2716 and the incremental settings are meant for backfilling everything incrementally rather than at once. - forward: + forward_limits: # Number of messages to backfill immediately after creating a portal. - initial_limit: 10 + initial: + user: 50 + normal_group: 100 + supergroup: 10 + channel: 10 # Number of messages to backfill when syncing chats. - sync_limit: 100 + sync: + user: 100 + normal_group: 100 + supergroup: 100 + channel: 100 + # Timeout for forward backfills in seconds. If you have a high limit, you'll have to increase this too. + forward_timeout: 900 - # Settings for incremental backfill of history. These only apply when using MSC2716. + # Settings for incremental backfill of history. These only apply to Beeper, as upstream abandoned MSC2716. incremental: # Maximum number of messages to backfill per batch. messages_per_batch: 100 @@ -453,7 +489,6 @@ bridge: # Filter rooms that can/can't be bridged. Can also be managed using the `filter` and # `filter-mode` management commands. # - # Filters do not affect direct chats. # An empty blacklist will essentially disable the filter. filter: # Filter mode to use. Either "blacklist" or "whitelist". @@ -462,6 +497,11 @@ bridge: mode: blacklist # The list of group/channel IDs to filter. list: [] + # How to handle direct chats: + # If users is "null", direct chats will follow the previous settings. + # If users is "true", direct chats will always be bridged. + # If users is "false", direct chats will never be bridged. + users: true # The prefix for commands. Only required in non-management rooms. command_prefix: "!tg" @@ -561,6 +601,8 @@ telegram: # is not recommended, since some requests can always trigger a call fail (such as searching # for messages). request_retries: 5 + # Use IPv6 for Telethon connection + use_ipv6: false # Device info sent to Telegram. device_info: From c1e59b8b63800dde58dd2584da880296ce4d66f6 Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Mon, 27 May 2024 13:21:42 +0200 Subject: [PATCH 18/18] push to f6cb26f7 --- Containerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Containerfile b/Containerfile index dab8f1c..1b6abae 100644 --- a/Containerfile +++ b/Containerfile @@ -1,4 +1,4 @@ -FROM docker.io/alpine:3.19 as builder +FROM docker.io/alpine:3.20 as builder RUN apk --no-cache add \ sed \ @@ -31,17 +31,17 @@ RUN apk --no-cache add \ py3-yarl \ py3-mako -ENV VERSION=43d17a335b1dd45fc81f3bed8ad6a7ee9f7a708f +ENV VERSION=f6cb26f7f53089488e085b45add5303fa283dc3e RUN git clone https://github.com/mautrix/telegram.git WORKDIR /telegram RUN git checkout "$VERSION" RUN pip3 install --prefix=/install --upgrade -r requirements.txt RUN pip3 install --prefix=/install --upgrade -r optional-requirements.txt -RUN cp -r mautrix_telegram /install/lib/python3.11/site-packages/ +RUN cp -r mautrix_telegram /install/lib/python3.12/site-packages/ -FROM docker.io/thallian/confd-env:3.19-3.1.6.2 +FROM docker.io/thallian/confd-env:3.20-3.1.6.2 ENV FFMPEG_BINARY=/usr/bin/ffmpeg @@ -79,7 +79,7 @@ RUN apk --no-cache add \ py3-mako \ py3-setuptools -ENV PYTHONPATH=/usr/lib/python3.11/site-packages:/py-pkgs/lib/python3.11/site-packages/ +ENV PYTHONPATH=/usr/lib/python3.12/site-packages:/py-pkgs/lib/python3.12/site-packages/ WORKDIR /var/lib/matrix-bridge