User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
matrix:telegram [2025/03/13 14:06] – [Matrix Telegram Bridge] willymatrix:telegram [2026/04/12 16:16] (current) willy
Line 3: Line 3:
 [[https://telegram.org/|Telegram]] is the well known chat app which started as the main competitor to Whatsapp and it's finally gaining some traction. Most known for it's piracy and porn angles, it's getting more and more popular to replace Whatsapp itself also for private chats. [[https://telegram.org/|Telegram]] is the well known chat app which started as the main competitor to Whatsapp and it's finally gaining some traction. Most known for it's piracy and porn angles, it's getting more and more popular to replace Whatsapp itself also for private chats.
  
-Telegram can be easily and fully bridged with Matrix using the Mautrix-Telegram bridge [[https://docs.mau.fi/bridges/python/setup.html?bridge=telegram|here]].+Telegram can be easily and fully bridged with Matrix using the Mautrix-Telegram bridge [[https://docs.mau.fi/bridges/go/telegram/index.html|here]].
  
-At the time of writing this page, full rewrite in Go of the bridge is undergoing but not yet officially released, so i will show you how to install the //older// python-based bridge. When the rewrite will be complete, the instructions will be a mirror of the ones for the Whatsapp and Signal bridges, which have already migrated to Go.+At the time of writing this page, the full rewrite in Go of the bridge is the way to go and the older python-based bridge is now officially deprecated.
  
  
Line 12: Line 12:
 I asusme you are installing the bridge directly together with the Matrix server, as user //conduwuit//. I asusme you are installing the bridge directly together with the Matrix server, as user //conduwuit//.
  
-Create a subfolder in which you need to initialize a Python venv inside (see [[gentoo:pip|PIP]]):+Create a subfolder to install the bridge:
 <code bash> <code bash>
 su - conduwuit su - conduwuit
 mkdir mautrix-telegram mkdir mautrix-telegram
 cd mautrix-telegram cd mautrix-telegram
-# Enable PIP like described in the link above: +wget -O mautrix-telegram.zip 'https://mau.dev/mautrix/telegram/-/jobs/artifacts/main/download?job=build%20amd64'  
-create ~/.config/pip/pip.conf +unzip mautrix-telegram.zip 
-# - add ~/.local/bin to the .bashrc +chmod +x mautrix-telegram
-python -m venv . # Note the dot at the end! +
-source ./bin/activate +
-# Now set "include-system-site-packages = true" in pyvenv.cfg +
-# Install: +
-pip install --upgrade mautrix-telegram[all]+
 </code> </code>
-Please follow the instructions to enable PIP venvs as described in the link above. 
- 
-This will install the bridge itself.  
  
  
Line 40: Line 32:
  
  
-===== Bridge Setup =====+===== Bridge setup =====
  
-Unfortunately, the python bridge doesn'generate the configuration file skeleton automatically and you need to download the example one from [[https://raw.githubusercontent.com/mautrix/telegram/refs/heads/master/mautrix_telegram/example-config.yaml|here]] and save it to the conduwuit data folder:+Let the bridge generate the basic configuration fileand move it to the /data/conduwuit folder:
 <code bash> <code bash>
-cd /data/conduwuit +./mautrix-telegram -
-wget -O /data/conduwuit/mautrix-telegram-config.yaml https://raw.githubusercontent.com/mautrix/telegram/refs/heads/master/mautrix_telegram/example-config.yaml+mv config.yaml /data/conduwuit/mautrix-telegram-config.yaml
 </code> </code>
  
-For an organizational reasoni prefer to keep all the stuff that needs to be backupped into /data/conduwuit instead of under /data/daemons/conduwuit. +Now edit it. You should take a good look at it, the following are only hints and pointers to what you aboslutely need to change: 
- +<code> 
-This file is huge, here are the most relevant changes needed: +network: 
-<file - config.yaml> +    # This is very important to have usernames instead of phone numbers! 
-appservice+    displayname_template: "{{or .FullName .BusinessName .PushName .Phone}} (Tg)"  
-    addresshttp://localhost:29317 +     
 +database
 +    typesqlite3-fk-wal 
 +    uri: file:/data/conduwuit/mautrix-telegram.db?_txlock=immediate 
 +  
 +homeserver:
     address: https://chat.mydomain.com     address: https://chat.mydomain.com
     domain: chat.mydomain.com     domain: chat.mydomain.com
-    verify_ssl: true + 
-    database: sqlite:/data/conduwuit/mautrix-telegram.db # place the database into the /data/conduwuit folder +appservice
-telegram+    hostname127.0.0.1
-    # Get your own API keys at https://my.telegram.org/apps +
-    api_id: << put your id here >> +
-    api_hash: << put your hash >> +
-    # (Optional) Create your own bot at https://t.me/BotFather +
-    bot_token: disabled +
-permissions: +
-  "*": "relaybot"                      # non-local users can only see messages +
-  "chat.mydomain.com": "full"          # full access to all local users +
-  "@myself:chat.mydomain.com": "admin" # who can admin the bot+
      
-  encryption:+permissions: # this is probably not needed, but anyway... 
 +  "*": "relay"                      # non-local users can only see messages 
 +  "chat.mydomain.com": "admin"          # full access to all local users 
 +  "@myself:chat.mydomain.com": "admin" # who can admin the bot 
 + 
 +backfill: 
 +    enabled: true  # to populate chats with older messages 
 +     
 +    encryption:
     # Whether to enable encryption at all. If false, the bridge will not function in encrypted rooms.     # Whether to enable encryption at all. If false, the bridge will not function in encrypted rooms.
     allow: true     allow: true
  
-  double_puppet_server_map+double_puppet: 
-        example.com: https://chat.gardiol.org +    # Servers to always allow double puppeting from. 
-  double_puppet_allow_discovery: false +    # This is only for other servers and should NOT contain the server the bridge is on. 
-  login_shared_secret_map+    servers
-      chat.gardiol.org: << here the double pupper as_token >> +        anotherserver.example.org: https://matrix.anotherserver.example.org 
-      +    # Whether to allow client API URL discovery for other servers. When using this option, 
 +    # users on other servers can use double puppeting even if their server URLs aren'
 +    # explicitly added to the servers map above. 
 +    allow_discovery: false 
 +    # Shared secrets for automatic double puppeting. 
 +    # See https://docs.mau.fi/bridges/general/double-puppeting.html for instructions. 
 +    secrets: 
 +        chat.mydomain.com: as_token:<< here the double-puppet token >> 
 +        
 logging: logging:
-    handlers: +      filename: /var/log/conduwuit/mautrix-telegram.log 
-        file: +</code> 
-            filename: /var/log/conduwuit/mautrix-telegram.log + 
-</file>+Note that backfill is disabled by default, you need to enable it to see older messages. Also note that messages **cannot** be backfilled for already created rooms, so don't forget to enable backfill before the first start!
  
-More details on configuration can be found [[https://docs.mau.fi/bridges/general/initial-config.html|here]]. To setup double-puppetingsee [[matrix:doublepuppeting|here]].+Since my server will have just a few usersi decided to use an SQLite database
  
-I choose to use SQLite as database because i only have a few users and don't want to spin a PostreSQL instance for that. 
  
 ===== Bridge Registration ===== ===== Bridge Registration =====
Line 96: Line 98:
 First of all, generate the //registration.yaml// file: First of all, generate the //registration.yaml// file:
 <code bash> <code bash>
-python -m mautrix_telegram -g -c /data/conduwuit/mautrix-telegram-config.yaml+./mautrix-telegram -c  /data/conduwuit/mautrix-telegram-config.yaml -g
 </code> </code>
  
Line 102: Line 104:
  
  
-===== Usage  =====+===== Usage =====
  
-You need to create the **telegrambot** user, again from the admin chat. this step could be skipped if the user has been already created, it seems to be hit and miss with these Python bridges +The **whatsappbot** user should have been created automatically.
- +
-In case the user is missing, from the Matrix server admin chat type: +
-<code> +
-!admin users create-user telegrambot +
-</code>+
  
 Good! Now you can run the bridge: Good! Now you can run the bridge:
 <code bash> <code bash>
-python -m mautrix_telegram -c /data/conduwuit/mautrix-telegram-config.yaml+/data/daemon/mautrix-telegram/mautrix-telegram -c /data/conduwuit/mautrix-telegram-config.yaml
 </code> </code>
  
Line 120: Line 117:
  
 ===== Login ===== ===== Login =====
- 
 To login into telegram you need to: To login into telegram you need to:
   * Start a chat with //@telegrambot:chat.mydomain.com//   * Start a chat with //@telegrambot:chat.mydomain.com//
Line 144: Line 140:
  
 name="conduwuit telegram bridge" name="conduwuit telegram bridge"
-description="Conduwuit Telegram Matrix Bridge"+description="Conduwuit telegram Matrix Bridge"
 pidfile="/run/conduwuit-telegram.pid" pidfile="/run/conduwuit-telegram.pid"
 command_background=true command_background=true
-command="/data/daemons/conduwuit/mautrix-telegram/bin/python+command="/data/daemons/conduwuit/mautrix-telegram/mautrix-telegram
-command_args=" -m mautrix_telegram -c /data/conduwuit/mautrix-telegram-config.yaml"+command_args="/data/conduwuit/mautrix-telegram-config.yaml"
 command_user="conduwuit:conduwuit" command_user="conduwuit:conduwuit"
 output_log="/var/log/conduwuit/conduwuit-telegram.log" output_log="/var/log/conduwuit/conduwuit-telegram.log"
Line 167: Line 163:
 rc-update add conduwuit-telegram default rc-update add conduwuit-telegram default
 </code> </code>
 +
 +
 +
 +