bridge_with_irc: Initialize IRC bot after checking Zulip bot.

Confirm whether Zulip bot is subscribed to the required stream
first and then Initialize IRC bot object.
This commit is contained in:
orientor 2020-03-29 17:40:25 +05:30 committed by showell
parent de40005f5e
commit d8157d6b80

View file

@ -12,7 +12,6 @@ class IRCBot(irc.bot.SingleServerIRCBot):
def __init__(self, zulip_client, stream, topic, channel, def __init__(self, zulip_client, stream, topic, channel,
nickname, server, nickserv_password='', port=6667): nickname, server, nickserv_password='', port=6667):
# type: (Any, str, str, irc.bot.Channel, str, str, str, int) -> None # type: (Any, str, str, irc.bot.Channel, str, str, str, int) -> None
irc.bot.SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname)
self.channel = channel # type: irc.bot.Channel self.channel = channel # type: irc.bot.Channel
self.zulip_client = zulip_client self.zulip_client = zulip_client
self.stream = stream self.stream = stream
@ -21,6 +20,8 @@ class IRCBot(irc.bot.SingleServerIRCBot):
self.nickserv_password = nickserv_password self.nickserv_password = nickserv_password
# Make sure the bot is subscribed to the stream # Make sure the bot is subscribed to the stream
self.check_subscription_or_die() self.check_subscription_or_die()
# Initialize IRC bot after proper connection to Zulip server has been confirmed.
irc.bot.SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname)
def zulip_sender(self, sender_string): def zulip_sender(self, sender_string):
# type: (str) -> str # type: (str) -> str