Lately I've been obsessed with checking my MillNic stats, so I thought I'd combine that with another obsession of mine..checking away messages. I wrote a jabber bot that grabs your MillNic stats for the day and sets it as the away message. It uses ruby, mechanize, and xmpp4r-simple. Here it is.
To use:
-save that code as millnic.rb
-install ruby
-install rubygems
-Run: sudo gem install mechanize xmpp4r-simple -y
-Get a jabber account (gtalk), and an im client that supports jabber (I use Adium)
-If you don't already have one, get a MillNic account. They're a great company that pays quickly and has some great promotions.
-Edit that file with your MillNic and Jabber credentials
-Finally, run the script:
ruby millnic.rb
(I have it setup as a cron job that restarts it each day in case something goes wrong.)
-Check the screenname from adium or some other client
-Patiently wait for your check...
Code:
#millnic.rb
require 'rubygems'
require 'mechanize'
require 'xmpp4r-simple'
millnic_user="yourjabbername@gmail.com"
millnic_pass="password"
jabber_user="yourmillnicaccount@gmail.com"
jabber_pass="password"
class Millnic
def self.stats(email, password)
if email.nil? || password.nil?
print "invalid-parameters"
end
agent = WWW::Mechanize.new
page = agent.get('http://www.millnicmedia.com')
form = page.forms.first
form.fields.name('DL_AUTH_USERNAME').value = email
form.fields.name('DL_AUTH_PASSWORD').value = password
result = agent.submit(form, form.buttons.first)
return result.body[/[\$0-9\.].*Earned Today/]
end
end
begin
im = Jabber::Simple.new(jabber_user, jabber_pass)
while true
stats = Millnic.stats(millnic_user, millnic_pass)
puts "set status to: '#{stats}'"
im.status(:away, stats)
sleep 60 * 60 # every 60 minutes
end
end
-save that code as millnic.rb
-install ruby
-install rubygems
-Run: sudo gem install mechanize xmpp4r-simple -y
-Get a jabber account (gtalk), and an im client that supports jabber (I use Adium)
-If you don't already have one, get a MillNic account. They're a great company that pays quickly and has some great promotions.
-Edit that file with your MillNic and Jabber credentials
-Finally, run the script:
ruby millnic.rb
(I have it setup as a cron job that restarts it each day in case something goes wrong.)
-Check the screenname from adium or some other client
-Patiently wait for your check...
