X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fautoop.rb;h=303e3d3ffc2545e867975bb6607305b73f79a544;hb=0f277c32dd269937fbbe6427b416214ae70c70e2;hp=c45419066a5bd585ec2cc56a1e48580ff1cc8ec8;hpb=d84c8bae9caef54dfd7d799836a03938939ea59b;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/autoop.rb b/data/rbot/plugins/autoop.rb index c4541906..303e3d3f 100644 --- a/data/rbot/plugins/autoop.rb +++ b/data/rbot/plugins/autoop.rb @@ -1,5 +1,5 @@ class AutoOP < Plugin - BotConfig.register BotConfigBooleanValue.new('autoop.on_nick', + Config.register Config::BooleanValue.new('autoop.on_nick', :default => true, :desc => "Determines if the bot should auto-op when someone changes nick and the new nick matches a listed netmask") @@ -38,8 +38,23 @@ class AutoOP < Plugin end def add(m, params) - @registry[params[:mask]] = params[:channels].dup - m.okay + if params[:channels].empty? || !@registry.has_key?(params[:mask]) + # if the channels parameter is omitted (meaning all channels), or the + # hostmask isn't present in the registry, we just (over)write the channels + # in the registry + @registry[params[:mask]] = params[:channels].dup + m.okay + else + # otherwise, merge the channels with the ones existing in the registry + current_channels = @registry[params[:mask]] + if current_channels.empty? + m.reply "#{params[:mask]} is already being auto-opped on all channels" + else + # merge the already set channels + @registry[params[:mask]] = (params[:channels] | current_channels).uniq + m.okay + end + end end def rm(m, params)