I've had a dramatic uprise in the amount of spam I get on RedHanded
lately. I've been putting off fixing it because I wasn't sure how to
solve it. I kind of wanted some kind of a filter and I looked at
Akismet, but no way. I also looked at integrating chongqed.org somehow,
but it's not really kept up as I'd hoped.
I don't mind moderating by hand, I really don't want to lose any
comments to a filter and I don't want people to need to jump through any
hoops.
-- comment-chops.rb --
So here's a wee little script and all it does is process the .comments
files in order of most recently modified. Place it in your weblog's
directory and just run it. It dumps a list of all comments for a post
to the screen with a number next to each comment.
If I notice spam from comment #12 on, I enter: 12<Enter>. It saves the
old file with .bak and writes a new comment file with all the spam
removed. Again: enter the number of the first spam comment.
If I don't see any spam, I just hit <Enter> to move on to the next post.
It's so brainless simple that I'm embarassed to even mention it, but it
fits perfectly into my routine of blogging from the command-line.
Anyway, if you guys have comments, maybe we can roll this into Hobix
proper soon.
_why
#!/usr/local/bin/ruby
require 'hobix/weblog'
comments =
Dir["entries/**/*.comments"].sort_by do |cpath|
File.mtime(cpath)
end.reverse
comments.each do |cpath|
puts "** Checking #{cpath} [last updated: #{File.mtime(cpath)}]"
objs = YAML::load_file(cpath)
puts " -- #{objs.size} comments found"
objs.inject(1) do |i, obj|
puts " -- #{i}. #{obj.author} #{obj.content[0..40]}"
i+1
end
if (idx = gets.strip).any?
puts " ++ DELETE UP TO #{idx}? [yN] "
if gets.strip =~ /^y$/i
File.copy(cpath, "#{cpath}.bak")
objs.slice!((idx.to_i - 1)..-1)
File.open(cpath, 'w') do |f|
f << objs.to_yaml
end
puts " ++ Wrote new #{cpath}"
end
end
end
_______________________________________________
Hobix-is-the-way mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/hobix-is-the-way