Advertisement
Azure

timeban.rb (module) - 2011-07-08 00:08:30

Jul 7th, 2011
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.83 KB | None | 0 0
  1. require 'active_support/core_ext'
  2. require 'dm-core'
  3. require 'dm-types'
  4. require 'dm-timestamps'
  5. require 'time'
  6.  
  7. module Timebans
  8.         class Ban
  9.             include DataMapper::Resource
  10.             property :id, Serial
  11.             property :channel, String
  12.             property :hostname, String
  13.             property :datebanned, DateTime
  14.             property :dateunbanned, DateTime
  15.             property :reason, String
  16.             property :bannedby, String
  17.         end
  18.         DataMapper.finalize
  19.        
  20.         def Timebans.unbanned?
  21.             b = Ban.all
  22.             hostnames_to_unban = Hash.new
  23.             b.each {|e|
  24.                 break if e.dateunbanned.blank? # Infinite ban.
  25.                 if e.dateunbanned < Time.now
  26.                     hostnames_to_unban.store(e.channel, e.hostname)
  27.                 end
  28.             }
  29.             hostnames_to_unban
  30.         end
  31.    
  32.         def Timebans.remove_ban! channel, mask
  33.             the_ban = Ban.first( :channel => channel, :hostname => mask )
  34.             the_ban.destroy
  35.         end
  36.  
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement