X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Fcore%2Fconfig.rb;h=939b52991af568cb9c590aebe1cf2fb7e179effd;hb=87d2affc0fbe7cf864fdad4eca506d9d06a0de0c;hp=fc99fd8c961f5de8dae44dc89050362337a5ea0e;hpb=a0325f701d6a1a4284d251f8ca4cde5a5add7bec;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/core/config.rb b/lib/rbot/core/config.rb index fc99fd8c..939b5299 100644 --- a/lib/rbot/core/config.rb +++ b/lib/rbot/core/config.rb @@ -77,7 +77,7 @@ class ConfigModule < CoreBotModule if cfs.empty? m.reply _("no config key found matching %{r}") % { :r => params[:rx].to_s} else - m.reply _("possible keys: %{kl}") % { :kl => cfs.map { |c| c.first}.join(', ') } if cfs.length > 1 + m.reply _("possible keys: %{kl}") % { :kl => cfs.map { |c| c.first}.sort.join(', ') } if cfs.length > 1 m.reply cfs.map { |c| c.join(': ') }.join("\n") end end @@ -122,7 +122,7 @@ class ConfigModule < CoreBotModule def handle_add(m, params) key = params[:key].to_s.intern - value = params[:value] + values = params[:value].to_s.split(/,\s+/) unless @bot.config.items.has_key?(key) m.reply _("no such config key %{key}") % {:key => key} return @@ -132,11 +132,13 @@ class ConfigModule < CoreBotModule return end return if !@bot.auth.allow?(@bot.config.items[key].auth_path, m.source, m.replyto) - begin - @bot.config.items[key].add(value) - rescue ArgumentError => e - m.reply _("failed to add %{value} to %{key}: %{error}") % {:value => value, :key => key, :error => e.message} - return + values.each do |value| + begin + @bot.config.items[key].add(value) + rescue ArgumentError => e + m.reply _("failed to add %{value} to %{key}: %{error}") % {:value => value, :key => key, :error => e.message} + next + end end handle_get(m,{:key => key}) m.reply _("this config change will take effect on the next restart") if @bot.config.items[key].requires_restart @@ -145,7 +147,7 @@ class ConfigModule < CoreBotModule def handle_rm(m, params) key = params[:key].to_s.intern - value = params[:value] + values = params[:value].to_s.split(/,\s+/) unless @bot.config.items.has_key?(key) m.reply _("no such config key %{key}") % {:key => key} return @@ -155,11 +157,13 @@ class ConfigModule < CoreBotModule return end return if !@bot.auth.allow?(@bot.config.items[key].auth_path, m.source, m.replyto) - begin - @bot.config.items[key].rm(value) - rescue ArgumentError => e - m.reply _("failed to remove %{value} from %{key}: %{error}") % {:value => value, :key => key, :error => e.message} - return + values.each do |value| + begin + @bot.config.items[key].rm(value) + rescue ArgumentError => e + m.reply _("failed to remove %{value} from %{key}: %{error}") % {:value => value, :key => key, :error => e.message} + next + end end handle_get(m,{:key => key}) m.reply _("this config change will take effect on the next restart") if @bot.config.items[key].requires_restart @@ -181,6 +185,7 @@ class ConfigModule < CoreBotModule def bot_nick(m, param) @bot.nickchg(param[:nick]) + @bot.wanted_nick = param[:nick] end def bot_status(m, param) @@ -227,7 +232,7 @@ class ConfigModule < CoreBotModule when "desc" _("config desc => describe what key configures") when "add" - _("config add to => add value to key if is an array") + _("config add to => add values to key if is an array") when "rm" _("config rm from => remove value from key if is an array") else @@ -295,16 +300,19 @@ conf.map "version", conf.map 'config set :key *value', :action => 'handle_set', :auth_path => 'edit' -conf.map 'config add :value to :key', +conf.map 'config add *value to :key', :action => 'handle_add', :auth_path => 'edit' -conf.map 'config rm :value from :key', +conf.map 'config rm *value from :key', + :action => 'handle_rm', + :auth_path => 'edit' +conf.map 'config remove *value from :key', :action => 'handle_rm', :auth_path => 'edit' -conf.map 'config del :value from :key', +conf.map 'config del *value from :key', :action => 'handle_rm', :auth_path => 'edit' -conf.map 'config delete :value from :key', +conf.map 'config delete *value from :key', :action => 'handle_rm', :auth_path => 'edit' conf.map 'config unset :key',