+ def handle_add(m, params)
+ key = params[:key].to_s.intern
+ value = params[:value]
+ unless @@items.has_key?(key)
+ m.reply "no such config key #{key}"
+ return
+ end
+ unless @@items[key].class <= BotConfigArrayValue
+ m.reply "config key #{key} is not an array"
+ return
+ end
+ begin
+ @@items[key].add(value)
+ rescue ArgumentError => e
+ m.reply "failed to add #{value} to #{key}: #{e.message}"
+ return
+ end
+ handle_get(m,{:key => key})
+ m.reply "this config change will take effect on the next restart" if @@items[key].requires_restart
+ end
+
+ def handle_rm(m, params)
+ key = params[:key].to_s.intern
+ value = params[:value]
+ unless @@items.has_key?(key)
+ m.reply "no such config key #{key}"
+ return
+ end
+ unless @@items[key].class <= BotConfigArrayValue
+ m.reply "config key #{key} is not an array"
+ return
+ end
+ begin
+ @@items[key].rm(value)
+ rescue ArgumentError => e
+ m.reply "failed to remove #{value} from #{key}: #{e.message}"
+ return
+ end
+ handle_get(m,{:key => key})
+ m.reply "this config change will take effect on the next restart" if @@items[key].requires_restart
+ end
+