Skip to content

Commit 72ef52d

Browse files
ro-itimabbott
authored andcommitted
integrations: Enhanced matrix bridge.
1 parent b290717 commit 72ef52d

File tree

8 files changed

+676
-251
lines changed

8 files changed

+676
-251
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ types-python-dateutil
1515
types-pytz
1616
types-requests
1717
gitlint>=0.13.0
18+
-r ./zulip/integrations/bridge_with_matrix/requirements.txt
Lines changed: 67 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
# Matrix <--> Zulip bridge
22

3-
This acts as a bridge between Matrix and Zulip. It also enables a
4-
Zulip topic to be federated between two Zulip servers.
3+
This acts as a bridge between Matrix and Zulip.
54

6-
## Usage
5+
### Enhanced Features
6+
- Supporting multiple (Zulip topic, Matrix channel)-pairs.
7+
- Handling files according to their mimetype.
78

8-
### For IRC bridges
99

10-
Matrix has been bridged to the listed
11-
[IRC networks](https://github.com/matrix-org/matrix-appservice-irc/wiki/Bridged-IRC-networks),
12-
where the 'Room alias format' refers to the `room_id` for the corresponding IRC channel.
10+
## Installation
1311

14-
For example, for the freenode channel `#zulip-test`, the `room_id` would be
15-
`#freenode_#zulip-test:matrix.org`.
12+
Run `pip install -r requirements.txt` in order to install the requirements.
13+
14+
In case you'd like encryption to work, you need pip to install the `matrix-nio`
15+
package with e2e support:
16+
- First, you need to make sure that the development files of the `libolm`
17+
C-library are installed on your system! See [the corresponding documentation
18+
of matrix-nio](https://github.com/poljar/matrix-nio#installation) for further
19+
information on this point.
20+
- `pip install matrix-nio[e2e]`
1621

17-
Hence, this can also be used as a IRC <--> Zulip bridge.
1822

1923
## Steps to configure the Matrix bridge
2024

@@ -27,19 +31,43 @@ details mentioned below. For example:
2731
* If you are running from the Zulip GitHub repo: `python matrix_bridge.py --write-sample-config matrix_bridge.conf`
2832

2933
### 1. Zulip endpoint
30-
1. Create a generic Zulip bot, with a full name like `IRC Bot` or `Matrix Bot`.
31-
2. Subscribe the bot user to the stream you'd like to bridge your IRC or Matrix
32-
channel into.
34+
1. Create a generic Zulip bot, with a full name such as `Matrix Bot`.
35+
2. The bot is able to subscribe to the necessary streams itself if they are
36+
public. (Note that the bridge will not try to create streams in case they
37+
do not already exist. In that case, the bridge will fail at startup.)
38+
Otherwise, you need to add the bot manually.
3339
3. In the `zulip` section of the configuration file, enter the bot's `zuliprc`
3440
details (`email`, `api_key`, and `site`).
3541
4. In the same section, also enter the Zulip `stream` and `topic`.
3642

3743
### 2. Matrix endpoint
38-
1. Create a user on [matrix.org](https://matrix.org/), preferably with
39-
a formal name like to `zulip-bot`.
40-
2. In the `matrix` section of the configuration file, enter the user's username
41-
and password.
42-
3. Also enter the `host` and `room_id` into the same section.
44+
1. Create a user on the matrix server of your choice, e.g. [matrix.org](https://matrix.org/),
45+
preferably with a descriptive name such as `zulip-bot`.
46+
2. In the `matrix` section of the configuration file, enter the user's Matrix
47+
user ID `mxid` and password. Please use the Matrix user ID ([MXID](https://matrix.org/faq/#what-is-a-mxid%3F))
48+
as format for the username!
49+
3. Create the Matrix room(s) to be bridged in case they do not exits yet.
50+
Remember to invite the bot to private rooms! Otherwise, this error will be
51+
thrown: `Matrix bridge error: JoinError: M_UNKNOWN No known servers`.
52+
4. Enter the `host` and `room_id` into the same section.
53+
In case the room is private you need to use the `Internal room ID` which has
54+
the format `!aBcDeFgHiJkLmNoPqR:example.org`.
55+
In the official Matrix client [Element](https://github.com/vector-im), you
56+
can find this `Internal room ID` in the `Room Settings` under `Advanced`.
57+
58+
### Adding more (Zulip topic, Matrix channel)-pairs
59+
1. Create a new section with a name starting with `additional_bridge`.
60+
2. Add a `room_id` for the Matrix side and a `stream` and a `topic` for the
61+
Zulip side.
62+
63+
Example:
64+
```
65+
[additional_bridge1]
66+
room_id = #zulip:matrix.org
67+
stream = matrix test
68+
topic = matrix test topic
69+
```
70+
4371

4472
## Running the bridge
4573

@@ -50,9 +78,29 @@ in a file called `matrix_bridge.conf`:
5078

5179
* If you are running from the Zulip GitHub repo: run `python matrix_bridge.py -c matrix_bridge.conf`
5280

53-
## Caveats for IRC mirroring
81+
82+
## Notes regarding IRC
83+
84+
### Usage for IRC bridges
85+
86+
This can also be used to indirectly bridge between IRC and Zulip.
87+
88+
Matrix has been bridged to the listed
89+
[IRC networks](https://matrix-org.github.io/matrix-appservice-irc/latest/bridged_networks.html),
90+
where the 'Room alias format' refers to the `room_id` for the corresponding IRC channel.
91+
92+
For example, for the Libera Chat channel `#zulip-test`, the `room_id` would be
93+
`#zulip-test:libera.chat`.
94+
95+
### Caveats for IRC mirroring
5496

5597
There are certain
5698
[IRC channels](https://github.com/matrix-org/matrix-appservice-irc/wiki/Channels-from-which-the-IRC-bridge-is-banned)
5799
where the Matrix.org IRC bridge has been banned for technical reasons.
58100
You can't mirror those IRC channels using this integration.
101+
102+
103+
## TODO
104+
105+
- Adding support for editing and deleting messages?
106+
- Handling encryption on the Matrix side (may need further discussion).
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[matrix]
2+
host = https://matrix.org
3+
mxid = @username:matrix.org
4+
password = password
5+
room_id = #zulip:matrix.org
6+
7+
[zulip]
8+
9+
api_key = aPiKeY
10+
site = https://chat.zulip.org
11+
stream = test here
12+
topic = matrix
13+
14+
[additional_bridge1]
15+
room_id = #example:matrix.org
16+
stream = new test
17+
topic = matrix
18+

0 commit comments

Comments
 (0)