Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
matrix:telegram [2025/03/10 14:34] – created willy | matrix:telegram [2025/03/12 07:23] (current) – [Bridge Setup] willy | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Matrix Telegram Bridge ===== | ====== Matrix Telegram Bridge ===== | ||
- | The Mautrix Telegram bridge is currently the best (only?) option. More info | + | [[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://docs.mau.fi/bridges/ | + | |
- | Create subfolder | + | Telegram can be easily and fully bridged with Matrix using the Mautrix-Telegram bridge [[https:// |
+ | |||
+ | At the time of writing this page, a 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. | ||
+ | |||
+ | |||
+ | ===== Installation ===== | ||
+ | |||
+ | I asusme you are installing the bridge directly together with the Matrix server, as user // | ||
+ | |||
+ | Create | ||
<code bash> | <code bash> | ||
su - conduwuit | su - conduwuit | ||
mkdir mautrix-telegram | mkdir mautrix-telegram | ||
cd mautrix-telegram | cd mautrix-telegram | ||
- | # Enable PIP like in the link above | + | # Enable PIP like described |
# - create ~/ | # - create ~/ | ||
# - add ~/ | # - add ~/ | ||
python -m venv . # Note the dot at the end! | python -m venv . # Note the dot at the end! | ||
source ./ | source ./ | ||
- | # Now flip include-system-site-packages = true in pyvenv.cfg | + | # Now set "include-system-site-packages = true" |
# Install: | # Install: | ||
pip install --upgrade mautrix-telegram[all] | pip install --upgrade mautrix-telegram[all] | ||
</ | </ | ||
+ | Please follow the instructions to enable PIP venvs as described in the link above. | ||
- | You need to create API keys to connect to Telegram. Go to [[https:// | + | This will install the bridge itself. |
- | Grab the example config | + | |
+ | |||
+ | ===== Telegram Setup ===== | ||
+ | |||
+ | First of all, you cannot create a new telegram account from the bridge, you need to do so from the official telegram app, it's the one and only way. | ||
+ | |||
+ | Now, assuming you have a Telegramn account, you need to create API keys to connect to Telegram. | ||
+ | |||
+ | From the page that pops up, generate and take note of **api_id** and **api_hash** as you will need to configure the bot. You should also give a name like // | ||
+ | |||
+ | |||
+ | ===== Bridge Setup ===== | ||
+ | |||
+ | Unfortunately, | ||
<code bash> | <code bash> | ||
- | wget -O / | + | cd / |
- | mv /data/daemons/conduwuit/mautrix-telegram/config.yaml | + | wget -O / |
</ | </ | ||
+ | |||
+ | For an organizational reason, i prefer to keep all the stuff that needs to be backupped into / | ||
This file is huge, here are the most relevant changes needed: | This file is huge, here are the most relevant changes needed: | ||
<file - config.yaml> | <file - config.yaml> | ||
+ | appservice: | ||
+ | address: http:// | ||
+ | |||
address: https:// | address: https:// | ||
domain: chat.mydomain.com | domain: chat.mydomain.com | ||
Line 43: | Line 70: | ||
" | " | ||
| | ||
- | 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 | + | double_puppet_server_map: |
+ | example.com: | ||
+ | double_puppet_allow_discovery: | ||
+ | login_shared_secret_map: | ||
+ | chat.gardiol.org: | ||
+ | |||
+ | logging: | ||
+ | handlers: | ||
+ | file: | ||
+ | filename: / | ||
</ | </ | ||
- | More details on configuration can be found [[https:// | + | |
+ | More details on configuration can be found [[https:// | ||
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. | 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. | ||
- | At this point you need to register the bridge: | + | ===== Bridge Registration ===== |
+ | |||
+ | At this point you need to register the bridge | ||
+ | |||
+ | First of all, generate the // | ||
<code bash> | <code bash> | ||
python -m mautrix_telegram -g -c / | python -m mautrix_telegram -g -c / | ||
</ | </ | ||
- | This step will create a **registration.yaml** file that you need to perform the registration | + | Then perform the actual appservice |
- | < | + | |
- | !admin | + | |
- | ``` << shift+enter >> | + | |
- | [ ... copy here the content of registration.yaml ... ] | + | |
- | ``` << enter >> | + | |
- | </ | + | |
- | When you see **<< shift enter >>** you need to press those two keys in order to create a new line in the same command. The three **```** (backthicks) are the markdown token to create a code block. | ||
- | The **<< autogenrated >>** are secret strings found in the // | ||
- | The chat should reply with a message like: | + | ===== Usage ===== |
- | < | + | |
- | Appservice registered with ID: telegram | + | |
- | </ | + | |
- | More details on registering | + | You need to create |
- | You need to create | + | In case the user is missing, from the Matrix server |
< | < | ||
!admin users create-user telegrambot | !admin users create-user telegrambot | ||
Line 87: | Line 117: | ||
If all is well, your bridge should be up and running now. | If all is well, your bridge should be up and running now. | ||
+ | |||
+ | |||
+ | ===== Login ===== | ||
To login into telegram you need to: | To login into telegram you need to: | ||
- | * Start a chat with telegrambot: | + | * Start a chat with //@telegrambot: |
* type " | * type " | ||
* when prompted, type your telegram registered phone number with country code | * when prompted, type your telegram registered phone number with country code | ||
Line 96: | Line 129: | ||
You will start seeing your telegram chats appear in Matrix now! It takes time, even hours, and also most chats will only appear the first time the other person messages you. | You will start seeing your telegram chats appear in Matrix now! It takes time, even hours, and also most chats will only appear the first time the other person messages you. | ||
- | |||
- | **Note:** Telegram does not allow registration from third party clients, so to register a **new** telegram account, you must use Telegram official app. | ||
General documentation on the Telegram bot can be found [[https:// | General documentation on the Telegram bot can be found [[https:// | ||
To manage animated sticker [[https:// | To manage animated sticker [[https:// | ||
+ | |||
+ | |||
+ | ===== Autostart ===== | ||
+ | |||
+ | Since i use OpenRC, simply drop the following script to / | ||
+ | <file - / | ||
+ | # | ||
+ | # Copyright 2025 Gentoo Authors | ||
+ | # Distributed under the terms of the GNU General Public License v2 | ||
+ | |||
+ | name=" | ||
+ | description=" | ||
+ | pidfile="/ | ||
+ | command_background=true | ||
+ | command="/ | ||
+ | command_args=" | ||
+ | command_user=" | ||
+ | output_log="/ | ||
+ | output_err="/ | ||
+ | |||
+ | start_pre() { | ||
+ | cd / | ||
+ | } | ||
+ | |||
+ | depend() { | ||
+ | need net | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Make it executable and add to the proper runlevel: | ||
+ | <code bash> | ||
+ | chmod +x / | ||
+ | rc-update add conduwuit-telegram default | ||
+ | </ | ||