Use source field instead of tag to filter incoming SB messages

This commit is contained in:
Darks 2022-04-14 19:10:15 +02:00
parent 8fb3434242
commit a53e39d34b
Signed by: Darks
GPG Key ID: 7515644268BE1433
2 changed files with 4 additions and 1 deletions

View File

@ -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}")

View File

@ -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)