From a53e39d34b6a297c8ea99f6faf96b08b7c8fbd0e Mon Sep 17 00:00:00 2001 From: Darks Date: Thu, 14 Apr 2022 19:10:15 +0200 Subject: [PATCH] Use source field instead of tag to filter incoming SB messages --- bridge.py | 2 +- shoutbox.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bridge.py b/bridge.py index 9317852..a5d92ea 100644 --- a/bridge.py +++ b/bridge.py @@ -23,7 +23,7 @@ def handle_irc(m): shoutbox.post(m.author, m.text, m.to[1:], USERS) -@shoutbox.on(lambda m: m.channel in channels and m.author != "IRC" and not m.text.endswith("[IRC]")) +@shoutbox.on(lambda m: m.channel in channels) def handle_shoutbox(m): author = Shoutbox.normalize(m.author) shoutbox.irc_clients[author][0].send(f"#{m.channel}", f"{m.text}") diff --git a/shoutbox.py b/shoutbox.py index 5f7e396..24dc4ea 100644 --- a/shoutbox.py +++ b/shoutbox.py @@ -84,6 +84,9 @@ class Shoutbox(object): logging.getLogger().setLevel(logging.DEBUG) for m in messages: logging.debug(m) + # If message comes from IRC, drop it (no loops allowed) + if m['source'] == "IRC": + continue # Get channel id, parse SBMessage self.channels[channel] = m['id'] message = SBMessage(m, channel)