irc: make channels configurable on a per-actor basis

This commit is contained in:
William Pitcock 2018-08-18 11:53:04 -05:00
parent 87a7789cd0
commit 5e9b2cd275
2 changed files with 10 additions and 2 deletions

View file

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

View file

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