File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
zulip/integrations/bridge_with_matrix Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,17 @@ def die(signal: int, frame: FrameType) -> None:
60
60
# We actually want to exit, so run os._exit (so as not to be caught and restarted)
61
61
os ._exit (1 )
62
62
63
+ def check_subscription_or_die (zulip_client , stream ):
64
+ # type: (zulip.Client, str) -> None
65
+ resp = zulip_client .list_subscriptions ()
66
+ if resp ["result" ] != "success" :
67
+ print ("ERROR: %s" % (resp ["msg" ],))
68
+ sys .exit (1 )
69
+ subs = [s ["name" ] for s in resp ["subscriptions" ]]
70
+ if stream not in subs :
71
+ print ("The bot is not yet subscribed to stream '%s'. Please subscribe the bot to the stream first." % (stream ,))
72
+ sys .exit (1 )
73
+
63
74
def matrix_to_zulip (
64
75
zulip_client : zulip .Client ,
65
76
zulip_config : Dict [str , Any ],
@@ -286,6 +297,8 @@ def main() -> None:
286
297
site = zulip_config ["site" ])
287
298
matrix_client = MatrixClient (matrix_config ["host" ])
288
299
300
+ # Check whether zulip bot is subscribed to stream or not
301
+ check_subscription_or_die (zulip_client , zulip_config ["stream" ])
289
302
# Login to Matrix
290
303
matrix_login (matrix_client , matrix_config )
291
304
# Join a room in Matrix
You can’t perform that action at this time.
0 commit comments