Skip to content

Commit 96d53de

Browse files
authored
Merge pull request #6 from robsiemb/document-secret-vars
Add some documentation around configuration and setup
2 parents 8016157 + bca3beb commit 96d53de

File tree

3 files changed

+50
-17
lines changed

3 files changed

+50
-17
lines changed

README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Zulip / Slack / Groupme Bridge Bot
2+
3+
## Features
4+
5+
- Relays two-way between Zulip, Groupme, and Slack.
6+
- Logs all public relayed traffic to a single Zulip stream.
7+
- Logs private relayed traffic to a dedicated Zulip stream.
8+
9+
## Installation
10+
11+
1. Install redis. A simple way to do this if you have docker installed is:
12+
13+
```
14+
docker run -d --rm -p 6379:6379 --name redis_master redis:5.0
15+
```
16+
17+
2. Create a slack bot account with bot user, add that bot to the appropriate channel on a slack.
18+
3. Create a zulip bot account on the zulip instance you intend to run.
19+
4. If you are using Groupme, get a Groupme bot account.
20+
5. Edit `secrets.py` to configure the auth credentials for the above.
21+
6. Configure stream/channel/topic names into `PUBLIC_TWO_WAY`, `PUBLIC_TWO_WAY_STREAM`, `ZULIP_LOG_PUBLIC_STREAM`, `ZULIP_LOG_PRIVATE_STREAM`.
22+
7. If using Groupme, set `GROUPME_ENABLE` and the cert chain paths.

__init__.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@
1616
import zulip
1717

1818
from secrets import (PUBLIC_TWO_WAY, ZULIP_BOT_NAME, ZULIP_BOT_EMAIL,
19-
ZULIP_API_KEY, ZULIP_URL, ZULIP_STREAM, ZULIP_PUBLIC,
19+
ZULIP_API_KEY, ZULIP_URL, PUBLIC_TWO_WAY_STREAM,
2020
SLACK_BOT_ID, SLACK_TOKEN, REDIS_HOSTNAME, REDIS_PORT,
2121
REDIS_PASSWORD, SLACK_EDIT_UPDATE_ZULIP_TTL,
2222
REDIS_PREFIX, SLACK_ERR_CHANNEL, GROUPME_TWO_WAY,
2323
GROUPME_ENABLE, SSL_CERT_CHAIN_PATH, SSL_CERT_KEY_PATH,
24-
ZULIP_PRIVATE)
24+
ZULIP_LOG_PUBLIC_STREAM, ZULIP_LOG_PRIVATE_STREAM)
2525

2626
REDIS_USERS = REDIS_PREFIX + ':users:'
2727
REDIS_BOTS = REDIS_PREFIX + ':bots:'
2828
REDIS_CHANNELS = REDIS_PREFIX + ':channels:'
2929
REDIS_CHANNELS_BY_NAME = REDIS_PREFIX + ':channels.by.name:'
3030
REDIS_MSG_SLACK_TO_ZULIP = {
31-
ZULIP_STREAM: REDIS_PREFIX + ':msg.slack.to.zulip:',
32-
ZULIP_PUBLIC: REDIS_PREFIX + ':msg.slack.to.zulip.pub:',
33-
ZULIP_PRIVATE: REDIS_PREFIX + ':msg.slack.to.zulip.priv:'
31+
PUBLIC_TWO_WAY_STREAM: REDIS_PREFIX + ':msg.slack.to.zulip.pub:',
32+
ZULIP_LOG_PUBLIC_STREAM: REDIS_PREFIX + ':msg.slack.to.zulip:',
33+
ZULIP_LOG_PRIVATE_STREAM: REDIS_PREFIX + ':msg.slack.to.zulip.priv:'
3434
}
3535

3636
GROUP_UPDATES = ['channel_archive', 'channel_join', 'channel_leave',
@@ -576,11 +576,11 @@ def send_to_zulip(self, subject, msg, user=None, slack_id=None,
576576
attach_txt += "\n"
577577
attach_txt += '```'
578578

579-
to = ZULIP_STREAM
579+
to = ZULIP_LOG_PUBLIC_STREAM
580580
if send_public:
581-
to = ZULIP_PUBLIC
581+
to = PUBLIC_TWO_WAY_STREAM
582582
elif private:
583-
to = ZULIP_PRIVATE
583+
to = ZULIP_LOG_PRIVATE_STREAM
584584
if edit and slack_id:
585585
redis_key = REDIS_MSG_SLACK_TO_ZULIP[to] + slack_id
586586
zulip_id = self.redis.get(redis_key)

secrets.py

+20-9
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
1+
# Slack / Zulip / Groupe Bridge Config
12
# Please fill in all constants before operating
2-
SLACK_BOT_ID = 'U00000000'
3-
SLACK_ERR_CHANNEL = 'U00000000'
4-
ZULIP_STREAM = 'my stream'
5-
ZULIP_BOT_NAME = 'ack-bot'
6-
ZULIP_BOT_EMAIL = 'some-bot@site.zulipchat.com'
3+
4+
# Authentication / Authorization configuration
5+
SLACK_BOT_ID = 'U00000000' # User ID of Bot
6+
ZULIP_BOT_NAME = 'some-bot' # Localpart of bot email
7+
ZULIP_BOT_EMAIL = '[email protected]' # Bot Email for zulip config.
78
ZULIP_API_KEY = '000000000000000000'
89
ZULIP_URL = 'https://andrew.zulipchat.com'
910
SLACK_TOKEN = 'xoxb-000000000000000000000000000'
10-
TWO_WAY = ['social']
11-
ZULIP_PUBLIC = 'social'
12-
ZULIP_PRIVATE = 'my private stream'
1311

12+
# Slack Destination ID for Slack for bot error logs
13+
SLACK_ERR_CHANNEL = 'U00000000'
14+
15+
# List of topics / slack channels to relay publicly. They must be identically named on slack and zulip.
16+
# Bot must be added to these slack channels.
17+
PUBLIC_TWO_WAY = ['social']
18+
PUBLIC_TWO_WAY_STREAM = 'abtech' # Zulip stream for public two-way communications
19+
20+
# Configuration for zulip-side logging streams
21+
ZULIP_LOG_PUBLIC_STREAM = 'slack' # Public logging zulip stream
22+
ZULIP_LOG_PRIVATE_STREAM = 'slack-private' # Private logging zulip stream
23+
24+
# Redis configuration
1425
REDIS_HOSTNAME = '127.0.0.1'
1526
REDIS_PORT = 6379
1627
REDIS_PASSWORD = ''
1728
SLACK_EDIT_UPDATE_ZULIP_TTL = 60*60
1829
REDIS_PREFIX = 'zulip.slack'
1930

20-
31+
# Groupme configuration. If not using Groupme, just set GROUPME_ENABLE to False.
2132
GROUPME_ENABLE = False
2233
SSL_CERT_CHAIN_PATH = ''
2334
SSL_CERT_KEY_PATH = ''

0 commit comments

Comments
 (0)