Class: DoroParser::Parser_old

Inherits:
Object
  • Object
show all
Defined in:
lib/dorothy2/DEM.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Parser_old

Returns a new instance of Parser_old.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/dorothy2/DEM.rb', line 49

def initialize(data) 
  noutf = Iconv.new('US-ASCII//TRANSLIT', 'UTF-8')
  if data and data =~ /(USER |USERHOST |PRIVMSG |PASS |NICK |JOIN |MODE |MSG |KCIK |rssr )(.*)\n/
    @irc = true
    @command = $1
    begin
      #@command2 = noutf.iconv($2).gsub(/"|'|\\/, "-")
      rescue
      @command2 = "null" 
    end
    elsif data =~ /from\W*([0-9]{1,3}(\.[0-9]{1,3}){3}).*by\W*(([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}).*From:.*<(\S+)>\W*To:.*<(\S+)>.*Subject:(.*)\W*Date/m
    @mail = true
    @fromip = $1
    @by =$3
    @from = $6
    @to = $7
    @subj = $8.chomp.lstrip 
    
    
    elsif data and data =~ /^(GET|POST)\s+(\S+)/
    @http = true
    @method = $1
    @path = $2
    
  end  
end