From 5e9b2cd275a226b6afa6998a067c3edcc5c546fa Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 18 Aug 2018 11:53:04 -0500 Subject: [PATCH] irc: make channels configurable on a per-actor basis --- viera.yaml.example | 9 ++++++++- viera/irc.py | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/viera.yaml.example b/viera.yaml.example index 02d328a..ee1fb7f 100644 --- a/viera.yaml.example +++ b/viera.yaml.example @@ -25,10 +25,17 @@ irc: # channels for the bot to join channels: - '#mychannel' + - '#myotherchannel' # channels for the bot to relay AP posts to relay_channels: - - '#mychannel' + + # allow any AP actor to be relayed + '#mychannel': [] + + # allow only one AP actor to be relayed + '#myotherchannel': + - 'https://example.org/~alyssa' # IRC services credentials. sasl_username: viera diff --git a/viera/irc.py b/viera/irc.py index 16f951c..01be975 100644 --- a/viera/irc.py +++ b/viera/irc.py @@ -254,8 +254,9 @@ class IRCProtocol(asyncio.Protocol): if len(content) > 256: msgcontent += '...' + targets = [chan for chan, actors in IRC_CONFIG['relay_channels'].items() if not actors or actor['id'] in actors] message = fmt.format(name=actor['name'], content=msgcontent, url=obj['id']) - target = ','.join(IRC_CONFIG['relay_channels']) + target = ','.join(targets) self.say(target, message)