Skip to content

Commit 67741ba

Browse files
committed
[WIP] Enhanced matrix bridge.
1 parent 1ca696e commit 67741ba

File tree

6 files changed

+604
-217
lines changed

6 files changed

+604
-217
lines changed
Lines changed: 72 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
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+
Please note that the `libmagic`-library is required to be installed on your
15+
system, which is usually the case on Linux systems. On Windows, you need to
16+
additionally run `pip install -r requirements_windows.txt` in order to add
17+
`python-magic-bin` which ships the necessary DLLs.
18+
19+
In case you'd like encryption to work, you need pip to install the `matrix-nio`
20+
package with e2e support:
21+
- First, you need to make sure that the development files of the `libolm`
22+
C-library are installed on your system! See [the corresponding documentation
23+
of matrix-nio](https://github.com/poljar/matrix-nio#installation) for further
24+
information on this point.
25+
- `pip install matrix-nio[e2e]`
1626

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

1928
## Steps to configure the Matrix bridge
2029

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

2938
### 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.
39+
1. Create a generic Zulip bot, with a full name such as `Matrix Bot`.
40+
2. The bot is able to subscribe to the necessary streams itself if they are
41+
public. (It may even create them if they do not exist and if the bot user
42+
has enough rights to create streams.)
43+
Otherwise, you need to add the bot manually.
3344
3. In the `zulip` section of the configuration file, enter the bot's `zuliprc`
3445
details (`email`, `api_key`, and `site`).
3546
4. In the same section, also enter the Zulip `stream` and `topic`.
3647

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

4477
## Running the bridge
4578

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

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

53-
## Caveats for IRC mirroring
86+
87+
## Notes regarding IRC
88+
89+
### Usage for IRC bridges
90+
91+
This can also be used to indirectly bridge between IRC and Zulip.
92+
93+
Matrix has been bridged to the listed
94+
[IRC networks](https://github.com/matrix-org/matrix-appservice-irc/wiki/Bridged-IRC-networks),
95+
where the 'Room alias format' refers to the `room_id` for the corresponding IRC channel.
96+
97+
For example, for the freenode channel `#zulip-test`, the `room_id` would be
98+
`#freenode_#zulip-test:matrix.org`.
99+
100+
### Caveats for IRC mirroring
54101

55102
There are certain
56103
[IRC channels](https://github.com/matrix-org/matrix-appservice-irc/wiki/Channels-from-which-the-IRC-bridge-is-banned)
57104
where the Matrix.org IRC bridge has been banned for technical reasons.
58105
You can't mirror those IRC channels using this integration.
106+
107+
108+
## TODO
109+
110+
- Adding support for editing and deleting messages?
111+
- 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)