From fe2a4d6fe85aacd95acdbd8f212382d4c57a036d Mon Sep 17 00:00:00 2001 From: rht Date: Sun, 9 Aug 2020 04:13:08 -0400 Subject: [PATCH] [BUGFIX] IRC bridge: Use connection initialized from aio_reactor. Additionally, pin the irc library version to 18.0 because the newer version has an error in the AioReactor: ``` File "/home/rht/code/venv/lib/python3.8/site-packages/irc/bot.py", line 108, in run self.bot.reactor.scheduler.execute_after(intvl, self.check) AttributeError: 'AioReactor' object has no attribute 'scheduler' ``` --- zulip/integrations/bridge_with_irc/irc_mirror_backend.py | 8 ++++---- zulip/integrations/bridge_with_irc/requirements.txt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/zulip/integrations/bridge_with_irc/irc_mirror_backend.py b/zulip/integrations/bridge_with_irc/irc_mirror_backend.py index cd2c02b..9b2ce00 100644 --- a/zulip/integrations/bridge_with_irc/irc_mirror_backend.py +++ b/zulip/integrations/bridge_with_irc/irc_mirror_backend.py @@ -30,7 +30,7 @@ class IRCBot(irc.bot.SingleServerIRCBot): # Taken from # https://github.com/jaraco/irc/blob/master/irc/client_aio.py, # in particular the method of AioSimpleIRCClient - self.reactor.loop.run_until_complete( + self.c = self.reactor.loop.run_until_complete( self.connection.connect(*args, **kwargs) ) print("Listening now. Please send an IRC message to verify operation") @@ -65,16 +65,16 @@ class IRCBot(irc.bot.SingleServerIRCBot): at_the_specified_subject = msg["subject"].casefold() == self.topic.casefold() if in_the_specified_stream and at_the_specified_subject: msg["content"] = ("@**%s**: " % msg["sender_full_name"]) + msg["content"] - send = lambda x: c.privmsg(self.channel, x) + send = lambda x: self.c.privmsg(self.channel, x) else: return else: recipients = [u["short_name"] for u in msg["display_recipient"] if u["email"] != msg["sender_email"]] if len(recipients) == 1: - send = lambda x: c.privmsg(recipients[0], x) + send = lambda x: self.c.privmsg(recipients[0], x) else: - send = lambda x: c.privmsg_many(recipients, x) + send = lambda x: self.c.privmsg_many(recipients, x) for line in msg["content"].split("\n"): send(line) diff --git a/zulip/integrations/bridge_with_irc/requirements.txt b/zulip/integrations/bridge_with_irc/requirements.txt index cb7fdec..085dd9a 100644 --- a/zulip/integrations/bridge_with_irc/requirements.txt +++ b/zulip/integrations/bridge_with_irc/requirements.txt @@ -1 +1 @@ -irc>=16.4 +irc==18.0