repost/plugins/scrape.rb
2014-03-09 19:59:42 +01:00

17 lines
517 B
Ruby

require 'open-uri'
require 'digest/md5'
include EventMachine::IRC::Commands
Client.register_trigger("PRIVMSG") do |msg|
msg[:params].each do |word|
if word =~ /4cdn[.]org/ then
ext = "." + word.sub(/.*[.]([^.]*)/, '\1') if word.match(/[^.]+[.][^.]+/)
content = open(word).read
md5 = Digest::MD5.hexdigest(content)
File.open(Config[:scrape][:basepath] + md5 + ext, 'w') do |file|
file.write(content)
end
end
end
end