super
@values = params[:values]
end
+ def values
+ if @values.instance_of?(Proc)
+ return @values.call(BotConfig.bot)
+ else
+ return @values
+ end
+ end
def parse(string)
unless @values.include?(string)
raise ArgumentError, "invalid value #{string}, allowed values are: " + @values.join(", ")
string
end
def desc
- "#{@desc} [valid values are: " + @values.join(", ") + "]"
+ "#{@desc} [valid values are: " + values.join(", ") + "]"
end
end
value = params[:value].to_s
unless @@items.has_key?(key)
m.reply "no such config key #{key}"
+ return
end
begin
@@items[key].set_string(value)
end
end
def usage(m,params)
- m.reply "incorrect usage, try '#{@bot.nick}: help config'"
+ m.reply "incorrect usage, try '#{@@bot.nick}: help config'"
end
# bot:: parent bot class