summaryrefslogtreecommitdiff
path: root/data/rbot/plugins
diff options
context:
space:
mode:
authorYaohan Chen <yaohan.chen@gmail.com>2007-06-15 16:39:25 +0000
committerYaohan Chen <yaohan.chen@gmail.com>2007-06-15 16:39:25 +0000
commit0153b9187f957fcfcea9cc996e21c8c8c92db468 (patch)
treea3ab376a5836c14e609a3fe3e38d6d70e87c0ee8 /data/rbot/plugins
parenta456a84088209c9bbfb087ffee81af0f34a0d066 (diff)
autoop plugin: make the "add" command add arguments to existing settings
Diffstat (limited to 'data/rbot/plugins')
-rw-r--r--data/rbot/plugins/autoop.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/data/rbot/plugins/autoop.rb b/data/rbot/plugins/autoop.rb
index c4541906..212da27b 100644
--- a/data/rbot/plugins/autoop.rb
+++ b/data/rbot/plugins/autoop.rb
@@ -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)