From a087e163d26dc11f7dd2bc66fecbc858db94ba18 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Mon, 17 Mar 2008 01:16:44 +0100 Subject: utils: Utils.check_location comfort method for :htmlinfo filters --- lib/rbot/core/utils/utils.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/rbot') diff --git a/lib/rbot/core/utils/utils.rb b/lib/rbot/core/utils/utils.rb index 25e5159b..e00b4079 100644 --- a/lib/rbot/core/utils/utils.rb +++ b/lib/rbot/core/utils/utils.rb @@ -581,6 +581,18 @@ module ::Irc return ds.merge(cur) if cur end + # HTML info filters often need to check if the webpage location + # of a passed DataStream _ds_ matches a given Regexp. + def Utils.check_location(ds, rx) + debug ds[:headers] + if h = ds[:headers] + loc = [h['x-rbot-location'],h['location']].flatten.grep(rx) + end + loc ||= [] + debug loc + return !loc.empty? + end + # This method extracts title and content (first par) # from the given HTML or XML document _text_, using # standard methods (String#ircify_html_title, -- cgit v1.2.3