diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-03-17 01:16:44 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-03-17 01:16:44 +0100 |
commit | a087e163d26dc11f7dd2bc66fecbc858db94ba18 (patch) | |
tree | a8d3bffc647aeaaed929c5c041c298508af76d27 /lib | |
parent | 1722077126d2b9407f0811dbe7298b730cabf178 (diff) |
utils: Utils.check_location comfort method for :htmlinfo filters
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rbot/core/utils/utils.rb | 12 |
1 files changed, 12 insertions, 0 deletions
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, |