Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require 'sendgmail.rb'
- require 'yaml'
- @log_dir = "/path/to/log"
- @channels = %w{#xxxxx@freenode #xxxxx@twitter}
- @file_name = Time.now.strftime("%Y.%m.%d.txt")
- @keywords = "key1|key2|key3"
- @send_mail_address = "xxxxxx@gmail.com"
- @to_mail_address = "xxxx@xxxx.ne.jp"
- @mail_title = "IRC REPLY"
- @user = "user"
- @pass = "pass"
- @save_file = "readLabel.yaml"
- replys = []
- readLabel = YAML.load_file(@save_file)
- @channels.each do |channel|
- line_number = 0
- open("#{@log_dir}/#{channel}/#{@file_name}").each_line { |line|
- line_number += 1
- next if !readLabel[channel].nil? && line_number <= readLabel[channel]
- replys << line if line =~ /^[\d]{2}:[\d]{2}:[\d]{2}[\s]+[<].+?[>].+?(#{@keywords})/
- }
- readLabel[channel] = line_number
- end
- fw = File.open(@save_file,'w+')
- fw.puts readLabel.to_yaml
- fw.close
- if !replys.empty?s
- sendgmail(@send_mail_address, [@to_mail_address], @mail_title, replys.join, @user, @pass)
- end
Add Comment
Please, Sign In to add comment