Matrix: Make minor changes to README.md and config.

This commit is contained in:
Rhea Parekh 2018-05-21 20:48:30 +05:30 committed by Tim Abbott
parent afb964b65a
commit 4c9134815c
3 changed files with 9 additions and 8 deletions

View file

@ -18,13 +18,14 @@ Hence, this can also be used as a IRC <--> Zulip bridge.
## Steps to configure the Matrix bridge ## Steps to configure the Matrix bridge
### 1. Zulip endpoint ### 1. Zulip endpoint
1. Create a generic Zulip bot 1. Create a generic Zulip bot preferable with a formal name similar to `irc-bot`.
2. (don't forget this step!) Make sure the bot is subscribed to the relevant stream 2. (Don't forget this step!) Make sure the bot is subscribed to the relevant stream
2. Enter the bot's email and `api_key` into `matrix_bridge_config.py` 3. Enter the bot's email and `api_key` into `matrix_bridge_config.py`
3. Enter the destination subject, realm and site in `matrix_bridge_config.py` 4. Enter the destination topic, stream and site in `matrix_bridge_config.py`
### 2. Matrix endpoint ### 2. Matrix endpoint
1. Create a user on [matrix.org](https://matrix.org/) 1. Create a user on [matrix.org](https://matrix.org/) preferably with a formal name
similar to `zulip-bot`.
2. Enter the user's username and password into `matrix_bridge_config.py` 2. Enter the user's username and password into `matrix_bridge_config.py`
3. Enter the host and `room_id` into `matrix_bridge_config.py` 3. Enter the host and `room_id` into `matrix_bridge_config.py`

View file

@ -70,7 +70,7 @@ def matrix_to_zulip(zulip_client: zulip.Client, zulip_config: Dict[str, Any],
"sender": zulip_client.email, "sender": zulip_client.email,
"type": "stream", "type": "stream",
"to": zulip_config["stream"], "to": zulip_config["stream"],
"subject": zulip_config["subject"], "subject": zulip_config["topic"],
"content": content, "content": content,
}) })
except MatrixRequestError as e: except MatrixRequestError as e:
@ -137,7 +137,7 @@ def zulip_to_matrix(config: Dict[str, Any], room: Any) -> Callable[[Dict[str, An
def check_zulip_message_validity(msg: Dict[str, Any], config: Dict[str, Any]) -> bool: def check_zulip_message_validity(msg: Dict[str, Any], config: Dict[str, Any]) -> bool:
is_a_stream = msg["type"] == "stream" is_a_stream = msg["type"] == "stream"
in_the_specified_stream = msg["display_recipient"] == config["stream"] in_the_specified_stream = msg["display_recipient"] == config["stream"]
at_the_specified_subject = msg["subject"] == config["subject"] at_the_specified_subject = msg["subject"] == config["topic"]
# We do this to identify the messages generated from Matrix -> Zulip # We do this to identify the messages generated from Matrix -> Zulip
# and we make sure we don't forward it again to the Matrix. # and we make sure we don't forward it again to the Matrix.

View file

@ -10,6 +10,6 @@ config = {
"api_key": "aPiKeY", "api_key": "aPiKeY",
"site": "https://chat.zulip.org", "site": "https://chat.zulip.org",
"stream": "test here", "stream": "test here",
"subject": "matrix" "topic": "matrix"
} }
} }