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:
parent
87b57f879c
commit
de40005f5e
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue