From a5027bf00aadb7859d19b58706c2b7e7eecb726f Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 14 Mar 2008 00:15:47 +0100 Subject: filters: method to get the global filter name of a grouped filter --- lib/rbot/core/utils/filters.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/rbot/core/utils/filters.rb b/lib/rbot/core/utils/filters.rb index 561d5ebf..b2864bf6 100644 --- a/lib/rbot/core/utils/filters.rb +++ b/lib/rbot/core/utils/filters.rb @@ -90,11 +90,17 @@ module ::Irc fs.inject(ds) { |mid, f| mid = f.call(mid) } end + # This method returns the global filter name for filter _name_ + # in group _group_ + def global_filter_name(name, group=nil) + (group ? "#{group}.#{name}" : name.to_s).intern + 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 = ( group ? "#{group}.#{name}" : name.to_s ).intern + tlkey = global_filter_name(name, group) key = name.to_sym if @filters.key?(tlkey) debug "Overwriting filter #{tlkey}" -- cgit v1.2.3