rpg.pbem.online

#diaspora #spam #troll #ban #podmin

Sigh! #zlax is back again. New version of the script. I guess it is better to run it regularly until the guy gets tired.
# Load diaspora environment                                                                                                                                                                                                                                                                                                   
ENV["RAILS_ENV"] ||= "production" 
require_relative "config/environment" 

for toxic in [ '[email protected]', '[email protected] ', '[email protected]%', '[email protected]%' ] do 
  puts "Blocking and cleaning #{toxic}" 

  local_spammers, remote_spammers = Person.where("diaspora_handle LIKE ?", toxic).where(closed_account: false).partition(&:local?) 

# Retract all comments of local spammers and close their accounts                                                                                                                                                                                                                                                             
local_spammers.each do |spammer| 
  Comment.where(author_id: spammer.id).each do |comment| 
    puts "delete #{comment.guid} from post #{comment.parent.guid}" 
    spammer.owner.retract(comment) 
  end 
  spammer.owner.close_account! 
end 

# Retract all spam comments on posts of local users and delete the rest                                                                                                                                                                                                                                                       
Comment.where(author_id: remote_spammers.map(&:id)).each do |comment| 
  puts "delete #{comment.guid} from post #{comment.parent.guid}" 
  post_author = comment.parent.author 
  if post_author.local? 
    post_author.owner.retract(comment) 
  else 
    comment.destroy 
  end 
end 

# Close accounts of remote users if wanted                                                                                                                                                                                                                                                                                    
remote_spammers.each do |spammer| 
  puts "close account #{spammer.diaspora_handle}" 
  #AccountDeleter.new(spammer.diaspora_handle).perform!                                                                                                                                                                                                                                                                       
  spammer.update_column(:serialized_public_key, "BLOCKED") 
  puts "closed account #{spammer.diaspora_handle}" 
end 

end