Created
March 18, 2009 18:05
-
-
Save snaka/81289 to your computer and use it in GitHub Desktop.
Simple biff program by ruby + growl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# biff.rb | |
# | |
require 'net/pop' | |
require 'nkf' | |
require 'rubygems' | |
require 'ruby-growl' | |
require 'pit' | |
config = Pit.get("mail", :require => { | |
"server" => "pop3 server", | |
"port" => "pop3 port", | |
"user" => "user account", | |
"pass" => "password" | |
}) | |
serv = config["server"] | |
port = config["port"].to_i | |
user = config["user"] | |
pass = config["pass"] | |
mails=[] | |
Net::POP3.start(serv, port, user, pass) {|pop| | |
mails = pop.mails.collect {|m| m.header} | |
} | |
exit if mails.empty? | |
growl = Growl.new("localhost", "Biff", ["Notify"]) | |
growl.notify("Notify", "Mail recieved", "#{mails.size} of mail(s) recived.") | |
sleep 5 | |
mails.each {|m| | |
subject = NKF.nkf('-Jw', m.match(/^Subject:\s+(.*)/)[1]) | |
from = NKF.nkf('-Jw', m.match(/^From:\s+(.*)/)[1]) | |
growl.notify("Notify", "#{from}", "#{subject}") | |
sleep 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment