45 Bridge setup
Andrew Morgan edited this page 2020-12-07 00:18:23 +00:00

Requirements

  • Python 3.7 or higher with pip and virtualenv
  • A Matrix homeserver that supports application services (e.g. Synapse)
  • Telegram app ID and hash (get from my.telegram.org)
  • If installing optional dependencies, see the optional dependencies wiki page.

Production setup

  1. Create a directory for the bridge.
  2. Set up a virtual environment.
    1. Create with virtualenv -p /usr/bin/python3 .
    2. Activate with source ./bin/activate
  3. Install the bridge with pip install --upgrade mautrix-telegram[all]
    • [all] at the end will install all optional dependencies. Some of the optional dependencies may need additional native packages. See the optional dependencies wiki page for more info.
    • If you want the master branch instead of a release, use pip install --upgrade https://github.com/tulir/mautrix-telegram/tarball/master#egg=mautrix-telegram[all].
  4. Copy mautrix_telegram/example-config.yaml to config.yaml.
  5. Update the config to your liking. You'll at least need to change the homeserver settings and api_id/api_hash in the telegram section.
  6. Generate the appservice registration with python -m mautrix_telegram -g. You can use the -c and -r flags to change the location of the config and registration files. They default to config.yaml and registration.yaml respectively.
  7. Add the path to the registration file (registration.yaml by default) to your Synapse's homeserver.yaml under app_service_config_files. Restart Synapse to apply changes.
  8. Create the database with alembic upgrade head. If you have a custom config path, use alembic -x config=/path/to/config.yaml upgrade head
  9. Run the bridge python -m mautrix_telegram.

Upgrading

  1. Run the bridge install command again (install step #2).
  2. Update the database with the command in install step #7.

Development setup

  1. Clone the repository.
  2. Optional, but strongly recommended: Set up a virtual environment.
    1. Create with virtualenv -p /usr/bin/python3 .venv
    2. Activate with source .venv/bin/activate
  3. Install dependencies with pip install -r requirements.txt
    • Optionally, add -r optional-requirements.txt to install optional dependencies. Some of the optional dependencies may need additional native packages. See the optional dependencies wiki page for more info.
    • N.B. Dependency version ranges are not locked in requirements.txt. Use pip install . instead if you want dependencies that are guaranteed to work (pip install .[all] for optional dependencies).
  4. Continue from step #3 of production setup.

Upgrading

  1. Pull changes from Git.
  2. Update dependencies with pip install --upgrade -r requirements.txt.
    • If you installed optional dependencies, run the same pip command as when installing them, but with --upgrade
  3. Update the database with the command in install step #7.