From 836a51a8bfacce8ab85acc84f65138100e9686ca Mon Sep 17 00:00:00 2001 From: rht Date: Sat, 18 Aug 2018 13:43:50 +0100 Subject: [PATCH] bridge_with_irc: Only forward stream messages at the specified topic. --- .../bridge_with_irc/irc_mirror_backend.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/zulip/integrations/bridge_with_irc/irc_mirror_backend.py b/zulip/integrations/bridge_with_irc/irc_mirror_backend.py index f4ef2b4..e78104f 100644 --- a/zulip/integrations/bridge_with_irc/irc_mirror_backend.py +++ b/zulip/integrations/bridge_with_irc/irc_mirror_backend.py @@ -42,11 +42,18 @@ class IRCBot(irc.bot.SingleServerIRCBot): def forward_to_irc(msg): # type: (Dict[str, Any]) -> None - if msg["sender_email"] == self.zulip_client.email: + not_from_zulip_bot = msg["sender_email"] != self.zulip_client.email + if not not_from_zulip_bot: # Do not forward echo return - if msg["type"] == "stream": - send = lambda x: c.privmsg(self.channel, x) + is_a_stream = msg["type"] == "stream" + if is_a_stream: + in_the_specified_stream = msg["display_recipient"] == self.stream + at_the_specified_subject = msg["subject"].casefold() == self.topic.casefold() + if in_the_specified_stream and at_the_specified_subject: + send = lambda x: c.privmsg(self.channel, x) + else: + return else: recipients = [u["short_name"] for u in msg["display_recipient"] if u["email"] != msg["sender_email"]]