Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 836a51a

Browse files
rhttimabbott
authored andcommitted
bridge_with_irc: Only forward stream messages at the specified topic.
1 parent 8ef0aba commit 836a51a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

zulip/integrations/bridge_with_irc/irc_mirror_backend.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,18 @@ def on_welcome(self, c, e):
4242

4343
def forward_to_irc(msg):
4444
# type: (Dict[str, Any]) -> None
45-
if msg["sender_email"] == self.zulip_client.email:
45+
not_from_zulip_bot = msg["sender_email"] != self.zulip_client.email
46+
if not not_from_zulip_bot:
4647
# Do not forward echo
4748
return
48-
if msg["type"] == "stream":
49-
send = lambda x: c.privmsg(self.channel, x)
49+
is_a_stream = msg["type"] == "stream"
50+
if is_a_stream:
51+
in_the_specified_stream = msg["display_recipient"] == self.stream
52+
at_the_specified_subject = msg["subject"].casefold() == self.topic.casefold()
53+
if in_the_specified_stream and at_the_specified_subject:
54+
send = lambda x: c.privmsg(self.channel, x)
55+
else:
56+
return
5057
else:
5158
recipients = [u["short_name"] for u in msg["display_recipient"] if
5259
u["email"] != msg["sender_email"]]

0 commit comments

Comments
 (0)