Skip to content

Instantly share code, notes, and snippets.

@denysonique
Last active August 29, 2015 14:07
Show Gist options
  • Save denysonique/5079ccbd6a3659498b0e to your computer and use it in GitHub Desktop.
Save denysonique/5079ccbd6a3659498b0e to your computer and use it in GitHub Desktop.
From 68641f096d2a48ee3e1dfabd17c455a3a8d397c4 Mon Sep 17 00:00:00 2001
From: denysonique <dennisonic@gmail.com>
Date: Sun, 12 Oct 2014 02:46:57 +0100
Subject: [PATCH] implement Config[:scrape][:url_blacklist] blacklisting
---
plugins/scrape.rb | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/plugins/scrape.rb b/plugins/scrape.rb
index 0a2f92a..0dc8363 100644
--- a/plugins/scrape.rb
+++ b/plugins/scrape.rb
@@ -37,6 +37,10 @@ Client.register_trigger("PRIVMSG") do |msg|
return 0 if msg[:params][1].nil?
msg[:params][1].split.each do |word|
return 0 if word =~ /notitle/
+ return 0 if Config[:scrape][:url_blacklist].any? do |url|
+ url = Regexp.new Regexp.escape(url) unless url.is_a? Regexp
+ word =~ url
+ end
if word =~ /^https?:\/\// then
original_url = word
if word =~ /4cdn[.]org/ then
--
1.9.1
@denysonique
Copy link
Author

Example config setup:

 :scrape =>  {
    # list of urls to ignore either a String or Regexp
      :url_blacklist => [ %r!^(?:https?://)?github\.com/\S+!, 'onet.eu']
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment