summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/scrape.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/plugins/scrape.rb b/plugins/scrape.rb
index d30e0fc..ff64661 100644
--- a/plugins/scrape.rb
+++ b/plugins/scrape.rb
@@ -33,6 +33,7 @@ end
DataMapper.auto_upgrade!
Client.register_trigger("PRIVMSG") do |msg|
+ titles = []
return 0 if msg[:params][1].nil?
msg[:params][1].split.each do |word|
return 0 if word =~ /notitle/
@@ -44,7 +45,7 @@ Client.register_trigger("PRIVMSG") do |msg|
url = Digest::MD5.hexdigest(word)
end
- title = Nokogiri::HTML(open(word).read(10240)).title().split(/\n/)[0]
+ title = Nokogiri::HTML(open(word).read(10240)).title().delete!('\n')
Scrape::Link.create(
:url => url,
@@ -53,8 +54,11 @@ Client.register_trigger("PRIVMSG") do |msg|
:nick => msg[:prefix].split('!').first
)
+ titles << title
+
Client.privmsg(msg[:params][0], Config[:scrape][:title_prefix] + title) if not title.nil?
- return 0
end
end
+
+ Client.privmsg(msg[:params][0], Config[:scrape][:title_prefix] + titles.join(' ')) if not titles.count < 1
end