Skip to content

Instantly share code, notes, and snippets.

@jeffmccune
Created November 20, 2010 20:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jeffmccune/708122 to your computer and use it in GitHub Desktop.
Save jeffmccune/708122 to your computer and use it in GitHub Desktop.
IRC Boxcar + Jabber notification
#!/usr/bin/env ruby
#
# This script reads lines from STDIN and sends a notification for each line.
# It's intended to be used with the fnotify.pl IRSSI script to write notices
# and hilights to a plain text file. tail -f links the two systems together.
require 'rubygems'
# For Jabber Notification
gem 'xmpp4r-simple'
require 'xmpp4r-simple'
# For BoxCar API Notification
require 'httparty'
@boxcar_auth = { :username => 'mccune.jeff@gmail.com', :password => 'sekret' }
NOTIFICATION_URL = 'https://boxcar.io/notifications'
# Change @jabber and @notify as appropriate
@jabber = { :username => 'mygooglebot@gmail.com',
:password => 'sekret' }
@notify = "mccune.jeff@gmail.com"
# JJM This establishes a jabber connection to the bot account.
im = Jabber::Simple.new(@jabber[:username], @jabber[:password])
Signal.trap(:TERM) { exit; }
# Event loop to read lines and send them out as notifications
$stdin.each_line do |line|
# Send Jabber Message
im.deliver(@notify, line)
# JJM Boxcar Setup
notification_params = {
:notification => {
:from_screen_name => 'IRSSI',
:message => line
}
}
resp = HTTParty.post(NOTIFICATION_URL,
:body => notification_params,
:basic_auth => @boxcar_auth)
puts resp
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment