support for manipulating the autojoin list

This commit is contained in:
Brian S. Stephan 2010-07-24 13:36:13 -05:00
parent c12dd27d81
commit 90df8db714
1 changed files with 16 additions and 0 deletions

View File

@ -55,6 +55,22 @@ def on_privmsg(connection, event):
connection.quit(' '.join(what.split(' ')[1:]))
with open('dr.botzo.cfg', 'w') as cfg:
config.write(cfg)
# add/remove channel to/from autojoin list
elif what.split(' ')[0] == 'autojoin' and admin_unlocked:
if what.split(' ')[1] == 'add':
try:
# get existing list
channelset = set(config.get('channels', 'autojoin').split(','))
channelset.add(what.split(' ')[2])
config.set('channels', 'autojoin', ','.join(channelset))
except NoOptionError: pass
elif what.split(' ')[1] == 'remove':
try:
# get existing list
channelset = set(config.get('channels', 'autojoin').split(','))
channelset.discard(what.split(' ')[2])
config.set('channels', 'autojoin', ','.join(channelset))
except NoOptionError: pass
#####
# init