@@ -9,6 +9,16 @@ import interrealm_bridge_config
9
9
10
10
from typing import Any , Callable , Dict
11
11
12
+ def check_subscription_or_die (zulip_client , stream ):
13
+ # type: (zulip.Client, str) -> None
14
+ resp = zulip_client .list_subscriptions ()
15
+ if resp ["result" ] != "success" :
16
+ print ("ERROR: %s" % (resp ["msg" ],))
17
+ sys .exit (1 )
18
+ subs = [s ["name" ] for s in resp ["subscriptions" ]]
19
+ if stream not in subs :
20
+ print ("The bot is not yet subscribed to stream '%s'. Please subscribe the bot to the stream first." % (stream ,))
21
+ sys .exit (1 )
12
22
13
23
def create_pipe_event (to_client : zulip .Client , from_bot : Dict [str , Any ],
14
24
to_bot : Dict [str , Any ], stream_wide : bool
@@ -84,6 +94,9 @@ if __name__ == "__main__":
84
94
site = bot1 ["site" ])
85
95
client2 = zulip .Client (email = bot2 ["email" ], api_key = bot2 ["api_key" ],
86
96
site = bot2 ["site" ])
97
+ # Check whether zulip bots are subscribed to their respective streams or not
98
+ check_subscription_or_die (client1 , bot1 ["stream" ])
99
+ check_subscription_or_die (client2 , bot2 ["stream" ])
87
100
# A bidirectional tunnel
88
101
pipe_event1 = create_pipe_event (client2 , bot1 , bot2 , args .stream )
89
102
p1 = mp .Process (target = client1 .call_on_each_event , args = (pipe_event1 , ["message" ]))
0 commit comments