diff --git a/zulip/integrations/bridge_with_irc/irc-mirror.py b/zulip/integrations/bridge_with_irc/irc-mirror.py index 746d4d9..3e9d7f6 100755 --- a/zulip/integrations/bridge_with_irc/irc-mirror.py +++ b/zulip/integrations/bridge_with_irc/irc-mirror.py @@ -26,9 +26,6 @@ Example: Specify your Zulip API credentials and server in a ~/.zuliprc file or using the options. Note that "_zulip" will be automatically appended to the IRC nick provided - -Also note that at present you need to edit this code to do the Zulip => IRC side - """ if __name__ == "__main__": diff --git a/zulip/integrations/bridge_with_irc/irc_mirror_backend.py b/zulip/integrations/bridge_with_irc/irc_mirror_backend.py index 95c1a1a..46b2b93 100644 --- a/zulip/integrations/bridge_with_irc/irc_mirror_backend.py +++ b/zulip/integrations/bridge_with_irc/irc_mirror_backend.py @@ -2,6 +2,7 @@ import irc.bot import irc.strings from irc.client import ip_numstr_to_quad, ip_quad_to_numstr, Event, ServerConnection from irc.client_aio import AioReactor +import multiprocessing as mp from typing import Any, Dict @@ -41,7 +42,7 @@ class IRCBot(irc.bot.SingleServerIRCBot): def forward_to_irc(msg): # type: (Dict[str, Any]) -> None if msg["type"] == "stream": - send = lambda x: c.privmsg(msg["display_recipient"], x) + send = lambda x: c.privmsg(self.channel, x) else: recipients = [u["short_name"] for u in msg["display_recipient"] if u["email"] != msg["sender_email"]] @@ -52,10 +53,8 @@ class IRCBot(irc.bot.SingleServerIRCBot): for line in msg["content"].split("\n"): send(line) - ## Forwarding from Zulip => IRC is disabled; uncomment the next - ## line to make this bot forward in that direction instead. - # - # self.zulip_client.call_on_each_message(forward_to_irc) + z2i = mp.Process(target=self.zulip_client.call_on_each_message, args=(forward_to_irc,)) + z2i.start() def on_privmsg(self, c, e): # type: (ServerConnection, Event) -> None