diff -r 2266d6d73de3 -r d67cc4fbc3f1 mod_config.py --- a/mod_config.py Sun Nov 09 19:59:10 2014 +0200 +++ b/mod_config.py Mon Nov 10 02:06:06 2014 +0200 @@ -18,86 +18,11 @@ 'args': '', 'level': 'admin', }, - - { - 'name': 'chanattr', - 'description': 'Get or set a channel-specific attribute', - 'args': ' [value...]', - 'level': 'admin', - }, ] } def cmd_addchan (bot, args, **rest): - for channel in bot.channels: - if channel['name'].upper() == args['channel'].upper(): - command_error ('I already know of %s!' % args['channel']) - #done - - chan = {} - chan['name'] = args['channel'] - chan['logchannel'] = False - bot.channels.append (chan) - bot.write ('JOIN ' + chan['name']) - bot.save_config() -#enddef + bot.add_irc_channel (args['channel']) def cmd_delchan (bot, args, **rest): - for channel in bot.channels: - if channel['name'].upper() == args['channel'].upper(): - break; - else: - command_error ('unknown channel ' + args['channel']) - - bot.channels.remove (channel) - bot.write ('PART ' + args['channel']) - bot.save_config() -#enddef - -def bool_from_string (value): - if value != 'true' and value != 'false': - command_error ('expected true or false for value') - - return True if value == 'true' else False -#enddef - -def cmd_chanattr (bot, args, replyto, **rest): - for channel in bot.channels: - if channel['name'] == args['channel']: - break - else: - command_error ('I don\'t know of a channel named ' + args['channel']) - - key = args['key'] - value = args['value'] - - if value == '': - try: - bot.privmsg (replyto, '%s = %s' % (key, channel[key])) - except KeyError: - bot.privmsg (replyto, 'attribute %s is not set' % key) - return - #fi - - if key == 'name': - if replyto == channel['name']: - replyto = value - - bot.write ('PART ' + channel['name']) - channel['name'] = value - bot.write ('JOIN ' + channel['name'] + ' ' + (channel['password'] if hasattr (channel, 'password') else '')) - elif key == 'password': - channel['password'] = value - elif key == 'btannounce': - channel['btannounce'] = bool_from_string (value) - elif key == 'btprivate': - channel['btprivate'] = bool_from_string (value) - elif key == 'logchannel': - channel['logchannel'] = bool_from_string (value) - else: - command_error ('unknown key ' + key) - #fi - - bot.privmsg (replyto, '%s is now %s' % (key, channel[key])) - bot.save_config() -#enddef \ No newline at end of file + bot.remove_irc_channel (args['channel']) \ No newline at end of file