bridge_with_irc: Improve user-friendliness.

Edit error and success messages of zulip-irc bridge to be more
user friendly.
This commit is contained in:
orientor 2020-03-27 19:39:39 +05:30 committed by showell
parent 87b57f879c
commit de40005f5e

View file

@ -35,15 +35,18 @@ class IRCBot(irc.bot.SingleServerIRCBot):
self.reactor.loop.run_until_complete( self.reactor.loop.run_until_complete(
self.connection.connect(*args, **kwargs) self.connection.connect(*args, **kwargs)
) )
print("Connected to IRC server.") print("Listening now. Please send an IRC message to verify operation")
def check_subscription_or_die(self): def check_subscription_or_die(self):
# type: () -> None # type: () -> None
resp = self.zulip_client.list_subscriptions() resp = self.zulip_client.list_subscriptions()
assert resp["result"] == "success" if resp["result"] != "success":
print("ERROR: %s" % (resp["msg"],))
exit(1)
subs = [s["name"] for s in resp["subscriptions"]] subs = [s["name"] for s in resp["subscriptions"]]
if self.stream not in subs: if self.stream not in subs:
raise Exception("The bot is not yet subscribed to the specified stream") print("The bot is not yet subscribed to stream '%s'. Please subscribe the bot to the stream first." % (self.stream,))
exit(1)
def on_nicknameinuse(self, c, e): def on_nicknameinuse(self, c, e):
# type: (ServerConnection, Event) -> None # type: (ServerConnection, Event) -> None