diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-03-14 00:22:31 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-03-14 00:27:15 +0100 |
commit | f1ce6d0a506b050ebbf498c6c91ef376a55cb720 (patch) | |
tree | cc40da83cc38807ec776ac375fdd52f1fbaa84c7 /lib/rbot | |
parent | a5027bf00aadb7859d19b58706c2b7e7eecb726f (diff) |
filters: has_filter? method
Diffstat (limited to 'lib/rbot')
-rw-r--r-- | lib/rbot/core/utils/filters.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/rbot/core/utils/filters.rb b/lib/rbot/core/utils/filters.rb index b2864bf6..4a831497 100644 --- a/lib/rbot/core/utils/filters.rb +++ b/lib/rbot/core/utils/filters.rb @@ -96,13 +96,19 @@ module ::Irc (group ? "#{group}.#{name}" : name.to_s).intern end + # This method checks if the bot has a filter named _name_ (in group + # _group_) + def has_filter?(name, group=nil) + @filters.key?(global_filter_name(name, group)) + end + # This method is used to register a new filter def register_filter(name, group=nil, &block) raise "No block provided" unless block_given? @filters ||= {} tlkey = global_filter_name(name, group) key = name.to_sym - if @filters.key?(tlkey) + if has_filter?(tlkey) debug "Overwriting filter #{tlkey}" end @filters[tlkey] = DataFilter.new &block |